EnsurePullSecrets creates the image pull secrets
(ctx devspacecontext.Context, dockerClient docker.Client, pullSecrets []string)
| 71 | |
| 72 | // EnsurePullSecrets creates the image pull secrets |
| 73 | func (r *client) EnsurePullSecrets(ctx devspacecontext.Context, dockerClient docker.Client, pullSecrets []string) (err error) { |
| 74 | defer func() { |
| 75 | if err != nil { |
| 76 | // execute on error pull secrets hooks |
| 77 | pluginErr := hook.ExecuteHooks(ctx, map[string]interface{}{ |
| 78 | "PULL_SECRETS": pullSecrets, |
| 79 | "error": err, |
| 80 | }, "error:createPullSecrets") |
| 81 | if pluginErr != nil { |
| 82 | return |
| 83 | } |
| 84 | } |
| 85 | }() |
| 86 | |
| 87 | // execute before pull secrets hooks |
| 88 | pluginErr := hook.ExecuteHooks(ctx, map[string]interface{}{ |
| 89 | "PULL_SECRETS": pullSecrets, |
| 90 | }, "before:createPullSecrets") |
| 91 | if pluginErr != nil { |
| 92 | return pluginErr |
| 93 | } |
| 94 | |
| 95 | // create pull secrets |
| 96 | for _, pullSecretConf := range ctx.Config().Config().PullSecrets { |
| 97 | if len(pullSecrets) > 0 && !stringutil.Contains(pullSecrets, pullSecretConf.Name) { |
| 98 | continue |
| 99 | } |
| 100 | |
| 101 | ctx := ctx.WithLogger(ctx.Log().WithPrefix("pullsecret:" + pullSecretConf.Name + " ")) |
| 102 | err = r.ensurePullSecret(ctx, dockerClient, ctx.KubeClient().Namespace(), pullSecretConf) |
| 103 | if err != nil { |
| 104 | return err |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // execute after pull secrets hooks |
| 109 | pluginErr = hook.ExecuteHooks(ctx, map[string]interface{}{ |
| 110 | "PULL_SECRETS": pullSecrets, |
| 111 | }, "after:createPullSecrets") |
| 112 | if pluginErr != nil { |
| 113 | return pluginErr |
| 114 | } |
| 115 | |
| 116 | return nil |
| 117 | } |
| 118 | |
| 119 | func (r *client) addPullSecretsToServiceAccount(ctx devspacecontext.Context, namespace, pullSecretName string, serviceAccount string) error { |
| 120 | if serviceAccount == "" { |
nothing calls this directly
no test coverage detected