-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update oci registry #151
base: master
Are you sure you want to change the base?
Update oci registry #151
Conversation
func updateOCIRegistry(c *cli.Context) { | ||
|
||
if OciDNS == "" || OciUser == "" || OciPassword == "" { | ||
fmt.Printf("OCI_DNS, OCI_USER, OCI_PASS environment variables must be set to run update-oci-registry\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("OCI_DNS, OCI_USER, OCI_PASS environment variables must be set to run update-oci-registry\n") | |
fmt.Println("OCI_DNS, OCI_USER, OCI_PASS environment variables must be set to run update-oci-registry") |
|
||
rootFs := filesystem.GetFilesystem(getRepoRoot()) | ||
if err := auto.UpdateOCI(rootFs, OciDNS, OciUser, OciPassword, DebugMode); err != nil { | ||
fmt.Printf("failed to update oci registry: %v \n", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fmt.Printf("failed to update oci registry: %v \n", err) | |
fmt.Println("failed to update oci registry: ", err.Error()) |
fmt.Printf("Failed to load asset: %s; error: %s \n", asset, err.Error()) | ||
return pushedAssets, err | ||
} | ||
|
||
// Check if the asset version already exists in the OCI registry | ||
// Never overwrite a previously released chart! | ||
exists, err := o.checkAsset(o.helmClient, o.DNS, chart, version) | ||
if err != nil { | ||
fmt.Printf("Failed to check registry for %s; error: %s \n", asset, err.Error()) | ||
return pushedAssets, err | ||
} | ||
if exists { | ||
fmt.Printf("Asset %s already exists in the OCI registry \n", asset) | ||
return pushedAssets, fmt.Errorf("asset %s already exists in the OCI registry", asset) | ||
} | ||
|
||
fmt.Printf("Pushing asset to OCI Registry: %s \n", asset) | ||
if err := o.push(o.helmClient, assetData, buildPushURL(o.DNS, chart, version)); err != nil { | ||
err = fmt.Errorf("failed to push %s; error: %w ", asset, err) | ||
fmt.Printf(err.Error()) | ||
return pushedAssets, err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if we could make an atomic transaction and push all assets or push none, but if this isn't possible, you should do the same as you're doing in the last err check block, composing the errors instead of just logging them
Issue: rancher/ecm-distro-tools#476
Imeplementing a cli command to be called by a GHA job on every chart release that will push the released chart to an OCI registry.