Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nicholasSUSE
Copy link
Collaborator

@nicholasSUSE nicholasSUSE commented Oct 7, 2024

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.

@nicholasSUSE nicholasSUSE marked this pull request as ready for review October 7, 2024 19:43
@nicholasSUSE nicholasSUSE requested a review from a team as a code owner October 7, 2024 19:43
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")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fmt.Printf("failed to update oci registry: %v \n", err)
fmt.Println("failed to update oci registry: ", err.Error())

Comment on lines +128 to +148
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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants