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

Implement update profile to patch a profile's HelmRelease #1445

Merged
merged 8 commits into from
Feb 16, 2022

Conversation

nikimanoledaki
Copy link

@nikimanoledaki nikimanoledaki commented Feb 14, 2022

Closes: #1138

What changed?

This PR implements gitops update profile.

Why?
Minimum/required flags:
gitops update profile --name=podinfo --cluster=prod --config-repo=ssh://git@github.com/owner/config-repo.git --version=6.0.0

Optional flags:

  • --namespace defaults to wego-system
  • --version defaults to latest
  • --profiles-port for the Profiles API port
  • --auto-merge
  • --kubeconfig

Implementation Notes

  • This PR refactors some of the work done as part of add profile to reuse some of its functionality.
  • It refactors some of it to use a different decoder to split the YAML manifest that contains HelmReleases (separated by ---) directly into a list of HelmReleases, rather than [][]bytes.
  • It uses a strings.Builder to append the new and existing HelmReleases as a string to write the profiles.yaml file's content.

How did you test it?

Install gitops on a local kind cluster. Then, add a profile to the cluster:

./bin/gitops add profile --name podinfo --config-repo ssh://git@github.com/nikimanoledaki/fun-times.git --cluster kind-test-01 --version 6.0.0 --auto-merge

Wait for the pod to appear in the cluster. Wait for ~5 minutes (likely because the Github API caches the results). Then update the profile installation's version:

./bin/gitops update profile --name podinfo --config-repo ssh://git@github.com/nikimanoledaki/fun-times.git --cluster kind-test-01 --version 6.0.1 --auto-merge
► getting available profiles in kind-hi/wego-system
► created Pull Request: https://github.com/nikimanoledaki/fun-times/pull/22
► auto-merge=true; merging PR number 22
Updating profile:

Name: podinfo
Version: 6.0.0
Cluster: kind-hi
Namespace: wego-system

Example PR: https://github.com/nikimanoledaki/fun-times/pull/22

Release notes

Documentation Changes

nikimanoledaki added 3 commits February 14, 2022 19:25
- Add cobra CLI command func and required flags
- Refactor Add Profile func to re-use some functionality for Update Profile
- Add acceptance test
- Refactor profiles funcs to fail if profiles.yaml contains no HelmReleases
- Refactor func that appends HelmRelease to file so that update fails if HelmRelease does not exist
@nikimanoledaki nikimanoledaki changed the title Implement update profile to patch a profile's HelmRelease [WIP] Implement update profile to patch a profile's HelmRelease Feb 14, 2022
@nikimanoledaki nikimanoledaki changed the title [WIP] Implement update profile to patch a profile's HelmRelease Implement update profile to patch a profile's HelmRelease Feb 15, 2022
@nikimanoledaki nikimanoledaki marked this pull request as ready for review February 15, 2022 11:33
pkg/helm/releases.go Outdated Show resolved Hide resolved
pkg/helm/releases.go Outdated Show resolved Hide resolved
pkg/helm/releases.go Outdated Show resolved Hide resolved
pkg/helm/releases.go Outdated Show resolved Hide resolved
Copy link
Contributor

@aclevername aclevername left a comment

Choose a reason for hiding this comment

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

lgtm couple comments

@@ -37,3 +43,58 @@ func MakeHelmRelease(name, version, cluster, namespace string, helmRepository ty
},
}
}

// AppendHelmReleaseToString appends a HelmRelease to a string.
Copy link
Contributor

Choose a reason for hiding this comment

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

:D Can you be a tiny bit more descriptive please? :) Why? How? What's the purpose of the append?

Copy link
Contributor

@Skarlso Skarlso left a comment

Choose a reason for hiding this comment

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

Well done! :)

Copy link
Contributor

@Himangini Himangini left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@nikimanoledaki nikimanoledaki merged commit 4a48d1e into main Feb 16, 2022
@ozamosi ozamosi deleted the update-profile branch May 12, 2022 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gitops update profile/profiles command
4 participants