|
40 | 40 | authHeader string |
41 | 41 | contextPath string |
42 | 42 | forceUpload bool |
| 43 | + ignoreAlreadyExistsError bool |
43 | 44 | useHTTP bool |
44 | 45 | checkHelmVersion bool |
45 | 46 | caFile string |
@@ -121,6 +122,7 @@ func newPushCmd(args []string) *cobra.Command { |
121 | 122 | f.StringVar(&p.keyring, "keyring", defaultKeyring(), "location of a public keyring") |
122 | 123 | f.BoolVarP(&p.insecureSkipVerify, "insecure", "", false, "Connect to server with an insecure way by skipping certificate verification [$HELM_REPO_INSECURE]") |
123 | 124 | f.BoolVarP(&p.forceUpload, "force", "f", false, "Force upload even if chart version exists") |
| 125 | + f.BoolVarP(&p.ignoreAlreadyExistsError, "ignore-already-exists", "", false, "Skip the already exisits error if chart version exists") |
124 | 126 | f.BoolVarP(&p.dependencyUpdate, "dependency-update", "d", false, `update dependencies from "requirements.yaml" to dir "charts/" before packaging`) |
125 | 127 | f.BoolVarP(&p.checkHelmVersion, "check-helm-version", "", false, `outputs either "2" or "3" indicating the current Helm major version`) |
126 | 128 |
|
@@ -328,7 +330,7 @@ func (p *pushCmd) push() error { |
328 | 330 | return err |
329 | 331 | } |
330 | 332 |
|
331 | | - return handlePushResponse(resp) |
| 333 | + return p.handlePushResponse(resp) |
332 | 334 | } |
333 | 335 |
|
334 | 336 | func (p *pushCmd) download(fileURL string) error { |
@@ -384,13 +386,18 @@ func (p *pushCmd) download(fileURL string) error { |
384 | 386 | return handleDownloadResponse(resp) |
385 | 387 | } |
386 | 388 |
|
387 | | -func handlePushResponse(resp *http.Response) error { |
| 389 | +func (p *pushCmd) handlePushResponse(resp *http.Response) error { |
388 | 390 | if resp.StatusCode != 201 { |
389 | 391 | b, err := ioutil.ReadAll(resp.Body) |
390 | 392 | if err != nil { |
391 | 393 | return err |
392 | 394 | } |
393 | | - return getChartmuseumError(b, resp.StatusCode) |
| 395 | + err = getChartmuseumError(b, resp.StatusCode) |
| 396 | + if p.ignoreAlreadyExistsError && resp.StatusCode == 409 { |
| 397 | + fmt.Printf("Got the following error: %s \nSkipping.\n", err) |
| 398 | + return nil |
| 399 | + } |
| 400 | + return err |
394 | 401 | } |
395 | 402 | fmt.Println("Done.") |
396 | 403 | return nil |
|
0 commit comments