(ctx devspacecontext.Context, dockerClient docker.Client, namespace string, pullSecretConf *latest.PullSecretConfig)
| 38 | } |
| 39 | |
| 40 | func (r *client) ensurePullSecret(ctx devspacecontext.Context, dockerClient docker.Client, namespace string, pullSecretConf *latest.PullSecretConfig) error { |
| 41 | displayRegistryURL := pullSecretConf.Registry |
| 42 | if displayRegistryURL == "" { |
| 43 | displayRegistryURL = "hub.docker.com" |
| 44 | } |
| 45 | if pullSecretConf.Secret == "" { |
| 46 | pullSecretConf.Secret = GetRegistryAuthSecretName(pullSecretConf.Registry) |
| 47 | } |
| 48 | |
| 49 | ctx.Log().Info("Ensuring image pull secret for registry: " + displayRegistryURL + "...") |
| 50 | err := r.createPullSecret(ctx, dockerClient, pullSecretConf) |
| 51 | if err != nil { |
| 52 | return errors.Errorf("failed to create pull secret for registry: %v", err) |
| 53 | } |
| 54 | |
| 55 | if len(pullSecretConf.ServiceAccounts) > 0 { |
| 56 | for _, serviceAccount := range pullSecretConf.ServiceAccounts { |
| 57 | err = r.addPullSecretsToServiceAccount(ctx, namespace, pullSecretConf.Secret, serviceAccount) |
| 58 | if err != nil { |
| 59 | return errors.Wrap(err, "add pull secrets to service account") |
| 60 | } |
| 61 | } |
| 62 | } else { |
| 63 | err = r.addPullSecretsToServiceAccount(ctx, namespace, pullSecretConf.Secret, "default") |
| 64 | if err != nil { |
| 65 | return errors.Wrap(err, "add pull secrets to service account") |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | return nil |
| 70 | } |
| 71 | |
| 72 | // EnsurePullSecrets creates the image pull secrets |
| 73 | func (r *client) EnsurePullSecrets(ctx devspacecontext.Context, dockerClient docker.Client, pullSecrets []string) (err error) { |
no test coverage detected