MCPcopy Index your code
hub / github.com/docker/cli / runCreate

Function runCreate

cli/command/config/create.go:68–97  ·  view source on GitHub ↗

runCreate creates a config with the given options.

(ctx context.Context, dockerCLI command.Cli, options createOptions)

Source from the content-addressed store, hash-verified

66
67// runCreate creates a config with the given options.
68func runCreate(ctx context.Context, dockerCLI command.Cli, options createOptions) error {
69 apiClient := dockerCLI.Client()
70
71 configData, err := readConfigData(dockerCLI.In(), options.file)
72 if err != nil {
73 return fmt.Errorf("error reading content from %q: %v", options.file, err)
74 }
75
76 spec := swarm.ConfigSpec{
77 Annotations: swarm.Annotations{
78 Name: options.name,
79 Labels: opts.ConvertKVStringsToMap(options.labels.GetSlice()),
80 },
81 Data: configData,
82 }
83 if options.templateDriver != "" {
84 spec.Templating = &swarm.Driver{
85 Name: options.templateDriver,
86 }
87 }
88 r, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{
89 Spec: spec,
90 })
91 if err != nil {
92 return err
93 }
94
95 _, _ = fmt.Fprintln(dockerCLI.Out(), r.ID)
96 return nil
97}
98
99// maxConfigSize is the maximum byte length of the [swarm.ConfigSpec.Data] field,
100// as defined by [MaxConfigSize] in SwarmKit.

Callers 1

newConfigCreateCommandFunction · 0.70

Calls 6

readConfigDataFunction · 0.85
GetSliceMethod · 0.80
ClientMethod · 0.65
InMethod · 0.65
OutMethod · 0.65
ConfigCreateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…