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
Add acceptance test for bug #810 and update how secret names are generated #1066
Add acceptance test for bug #810 and update how secret names are generated #1066
Conversation
…rated so the same app automation manifests will work across clusters
9268655
to
002c369
Compare
@@ -268,7 +268,7 @@ var _ = Describe("Add Gitlab", func() { | |||
Expect(name).To(Equal("bar")) | |||
Expect(url.String()).To(Equal("ssh://git@gitlab.com/foo/bar.git")) | |||
Expect(branch).To(Equal("main")) | |||
Expect(secretRef).To(Equal("wego-test-cluster-bar")) | |||
Expect(secretRef).To(Equal("wego-gitlab-bar")) |
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.
👍
pkg/services/automation/generator.go
Outdated
func CreateRepoSecretName(targetName string, gitSourceURL gitproviders.RepoURL) GeneratedSecretName { | ||
return GeneratedSecretName(hashNameIfTooLong(fmt.Sprintf("wego-%s-%s", targetName, GenerateResourceName(gitSourceURL)))) | ||
func CreateRepoSecretName(gitSourceURL gitproviders.RepoURL) GeneratedSecretName { | ||
return GeneratedSecretName(hashNameIfTooLong(fmt.Sprintf("wego-%s-%s", string(gitSourceURL.Provider()), replaceUnderscores(gitSourceURL.RepositoryName())))) |
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.
💡 This is getting a little tough to read. Can we break this up with some variable names to demystify it a bit:
return GeneratedSecretName(hashNameIfTooLong(fmt.Sprintf("wego-%s-%s", string(gitSourceURL.Provider()), replaceUnderscores(gitSourceURL.RepositoryName())))) | |
provder := gitSourceURL.Provider() | |
cleanRepoName := replaceUnderscores(gitSourceURL.RepositoryName()) | |
baseName := fmt.Sprintf("wego-%s-%s", provider, cleanRepoName) | |
nameOrHash := hashNameIfTooLong(baseName) | |
return GeneratedSecretName(nameOrHash) |
Not terribly elegant but it might make it easier to understand what's happening.
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.
Okay
Closes: #810
What changed?
In the past, we attempted to remove deploy keys that were no longer being used so we included the cluster name in the deploy key name (allowing the deploy key for a single cluster to be removed while leaving others intact). We no longer remove deploy keys and all generated deploy keys have the same name:
wego-deploy-key
. The name genericizing (generification?) process was never extended to the secret names themselves, however, which still included cluster names. This caused no problems until we started trying to deploy an application into multiple clusters from the same repository. Initial testing of the multi-cluster scenario used two applications in the same repository (one with path./
and one with another path). This worked because the applications did not share automation manifests. With a single application, though, we only have one copy of each automation manifest and aGitRepository
manifest for a private repository contains a name reference to the secret. If the secret name includes the cluster name, deployment to one of the clusters will fail as theGitRepository
manifest will have one or the other secret name. This PR removes the cluster name from a generated secret name.Why?
To allow a single application to be deployed to multiple clusters from a common source repository.
How did you test it?
Manual tests and new acceptance test
Release notes
No, since we don't currently claim to support multi-cluster
Documentation Changes
No, since we don't discuss the secrets in the current documentation.