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

Function createConfigs

cli/command/stack/deploy_composefile.go:141–170  ·  view source on GitHub ↗
(ctx context.Context, dockerCLI command.Cli, configs []swarm.ConfigSpec)

Source from the content-addressed store, hash-verified

139}
140
141func createConfigs(ctx context.Context, dockerCLI command.Cli, configs []swarm.ConfigSpec) error {
142 apiClient := dockerCLI.Client()
143
144 for _, configSpec := range configs {
145 res, err := apiClient.ConfigInspect(ctx, configSpec.Name, client.ConfigInspectOptions{})
146 switch {
147 case err == nil:
148 // config already exists, then we update that
149 _, err := apiClient.ConfigUpdate(ctx, res.Config.ID, client.ConfigUpdateOptions{
150 Version: res.Config.Meta.Version,
151 Spec: configSpec,
152 })
153 if err != nil {
154 return fmt.Errorf("failed to update config %s: %w", configSpec.Name, err)
155 }
156 case errdefs.IsNotFound(err):
157 // config does not exist, then we create a new one.
158 _, _ = fmt.Fprintln(dockerCLI.Out(), "Creating config", configSpec.Name)
159 _, err := apiClient.ConfigCreate(ctx, client.ConfigCreateOptions{
160 Spec: configSpec,
161 })
162 if err != nil {
163 return fmt.Errorf("failed to create config %s: %w", configSpec.Name, err)
164 }
165 default:
166 return err
167 }
168 }
169 return nil
170}
171
172func createNetworks(ctx context.Context, dockerCLI command.Cli, namespace convert.Namespace, networks map[string]client.NetworkCreateOptions) error {
173 apiClient := dockerCLI.Client()

Callers 1

deployComposeFunction · 0.85

Calls 5

ConfigUpdateMethod · 0.80
ClientMethod · 0.65
OutMethod · 0.65
ConfigInspectMethod · 0.45
ConfigCreateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…