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

Add secret-ref flag to create source git #350

Merged
merged 1 commit into from
Oct 19, 2020
Merged

Add secret-ref flag to create source git #350

merged 1 commit into from
Oct 19, 2020

Conversation

allymparker
Copy link

@allymparker allymparker commented Oct 16, 2020

What?

Add secret-ref flag to create source options

Why?

This allows passing the name of an existing secret that already exists in the cluster (perhaps created with terraform)

Tested?

make test is passing
Manually tested with --export

Comment on lines +247 to +256
secretName := name
if sourceGitSecretRef != "" {
secretName = sourceGitSecretRef
}
Copy link
Member

@hiddeco hiddeco Oct 16, 2020

Choose a reason for hiding this comment

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

Instead of overwriting the generated secret here, I would expect the command to not generate and upsert a secret at all if an existing secret name is given.

Copy link
Author

Choose a reason for hiding this comment

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

So drop scenario 2 above? Can do if that's what you prefer!

Copy link
Member

@hiddeco hiddeco Oct 16, 2020

Choose a reason for hiding this comment

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

It does not do scenario 2 at the moment, as on L234 the secret that is upserted does not take the configured value into account. If you make it do this, I am fine with the change.

Copy link
Author

Choose a reason for hiding this comment

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

🤦 Oops missed it, sorry. Gimme a mo

Copy link
Member

Choose a reason for hiding this comment

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

Adding just the name in there would not be sufficient by the way, as this would result in the overwrite of existing data.

It would require some additional logic to only create (and not update) a secret with the given name if it does not exist yet.

Copy link
Author

Choose a reason for hiding this comment

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

What's the current behaviour if a secret with the same name as the git source exists? Would that not have the same behavior?

Maybe I should just simplify this to just scenario 1?

Copy link
Author

Choose a reason for hiding this comment

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

Let me know what you would prefer :)

Copy link
Member

@stefanprodan stefanprodan Oct 16, 2020

Choose a reason for hiding this comment

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

Please drop option 2. I see no reason why would you want to setup a name for the generated secret. When secret-ref is specified, then we assume it's up to the user to create it on the cluster by other means than gotk. If we make this change then it should be for all create source commands not only Git.

@@ -105,6 +106,7 @@ func init() {
createSourceGitCmd.Flags().Var(&sourceGitKeyAlgorithm, "ssh-key-algorithm", sourceGitKeyAlgorithm.Description())
createSourceGitCmd.Flags().Var(&sourceGitRSABits, "ssh-rsa-bits", sourceGitRSABits.Description())
createSourceGitCmd.Flags().Var(&sourceGitECDSACurve, "ssh-ecdsa-curve", sourceGitECDSACurve.Description())
createSourceGitCmd.Flags().StringVarP(&sourceGitSecretRef, "secret-ref", "s", "", "the name to use for the source secret, or an existing secret containing SSH or basic credentials")
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the s shorthand, this conflict with --silent.

@allymparker
Copy link
Author

Hope you all had a good weekend!

I've removed changing the name of generated secrets and added the same flag to Helm and Bucket sources.

Let me know if you need any other changes

@stefanprodan
Copy link
Member

@allymparker you need to rerun the docs gen make docs

@allymparker
Copy link
Author

I think that's sorted @stefanprodan

@hiddeco
Copy link
Member

hiddeco commented Oct 19, 2020

@allymparker any idea why cbba648 seems to touch all LOC? Is it a disguised merge commit?

Copy link
Member

@stefanprodan stefanprodan left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @allymparker can you please squash all your commits into one and rebase please?

@stefanprodan stefanprodan added area/source Source API related issues and pull requests enhancement New feature or request hacktoberfest-accepted labels Oct 19, 2020
Add secret-ref flag to Helm source

Add secret-ref to bucket source
@allymparker
Copy link
Author

@stefanprodan done, thanks! @hiddeco sorry, I wasn't sure, might have been the rebases, but it seems to be happier after squashing

@stefanprodan stefanprodan merged commit 55b8544 into fluxcd:main Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/source Source API related issues and pull requests enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants