| 109 | } |
| 110 | |
| 111 | func (helm *execer) AddRepo(name, repository, cafile, certfile, keyfile, username, password string, managed string, passCredentials string, skipTLSVerify string) error { |
| 112 | var args []string |
| 113 | var out []byte |
| 114 | var err error |
| 115 | if name == "" && repository != "" { |
| 116 | helm.logger.Infof("empty field name\n") |
| 117 | return fmt.Errorf("empty field name") |
| 118 | } |
| 119 | switch managed { |
| 120 | case "acr": |
| 121 | helm.logger.Infof("Adding repo %v (acr)", name) |
| 122 | out, err = helm.azcli(name) |
| 123 | case "": |
| 124 | args = append(args, "repo", "add", name, repository) |
| 125 | |
| 126 | // See https://github.com/helm/helm/pull/8777 |
| 127 | if cons, err := semver.NewConstraint(">= 3.3.2"); err == nil { |
| 128 | if cons.Check(&helm.version) { |
| 129 | args = append(args, "--force-update") |
| 130 | } |
| 131 | } else { |
| 132 | panic(err) |
| 133 | } |
| 134 | |
| 135 | if certfile != "" && keyfile != "" { |
| 136 | args = append(args, "--cert-file", certfile, "--key-file", keyfile) |
| 137 | } |
| 138 | if cafile != "" { |
| 139 | args = append(args, "--ca-file", cafile) |
| 140 | } |
| 141 | if username != "" && password != "" { |
| 142 | args = append(args, "--username", username, "--password", password) |
| 143 | } |
| 144 | if passCredentials == "true" { |
| 145 | args = append(args, "--pass-credentials") |
| 146 | } |
| 147 | if skipTLSVerify == "true" { |
| 148 | args = append(args, "--insecure-skip-tls-verify") |
| 149 | } |
| 150 | helm.logger.Infof("Adding repo %v %v", name, repository) |
| 151 | out, err = helm.exec(args, map[string]string{}) |
| 152 | default: |
| 153 | helm.logger.Errorf("ERROR: unknown type '%v' for repository %v", managed, name) |
| 154 | out = nil |
| 155 | err = nil |
| 156 | } |
| 157 | helm.info(out) |
| 158 | return err |
| 159 | } |
| 160 | |
| 161 | func (helm *execer) UpdateRepo() error { |
| 162 | helm.logger.Info("Updating repo") |