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

Use StoreOpts for secret store API #1150

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

ashley-cui
Copy link
Member

Clean up store code by using StoreOpts instead of multiple args as opts for storing secrets.

Signed-off-by: Ashley Cui acui@redhat.com

Mentioned in: #1147 (comment)

@ashley-cui
Copy link
Member Author

Putting in WIP until I get the Podman half done, so this PR doesn't break Podman

@rhatdan
Copy link
Member

rhatdan commented Sep 9, 2022

LGTM
@vrothberg PTAL

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

Just a nit. Feel free to merge once the nit is addressed and you feel ready to merge from the Podman/Buildah side.

Thank you, @ashley-cui !

@@ -102,6 +102,12 @@ type SecretsDriver interface {
Delete(id string) error
}

type StoreOptions struct {
Copy link
Member

Choose a reason for hiding this comment

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

Please add comments to the type and the fields.

@ashley-cui
Copy link
Member Author

@containers/podman-maintainers PTAL and merge, I'm blocking vendoring ATM and this should unblock it

@rhatdan
Copy link
Member

rhatdan commented Sep 9, 2022

/lgtm
/hold

Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Just some small nits, non blocking.

Comment on lines +183 to +190
if options.Metadata == nil {
options.Metadata = make(map[string]string)
}
if options.Labels == nil {
options.Labels = make(map[string]string)
}
if options.DriverOpts == nil {
options.DriverOpts = make(map[string]string)
Copy link
Member

Choose a reason for hiding this comment

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

Is there any specific reason why they cannot be nil? If these are optional I always prefer nil pointers vs empty maps.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's either we check here and store empty maps, or later on, when getting a secret, checking if the maps != nil each time. I feel like storing empty maps are a little less error prone, but thats also personal preference.

Comment on lines 107 to 110
// DriverOptions is other metadata needed to use the driver
DriverOpts map[string]string
// Metadata stores other metadata on the secret
Metadata map[string]string
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// DriverOptions is other metadata needed to use the driver
DriverOpts map[string]string
// Metadata stores other metadata on the secret
Metadata map[string]string
// DriverOptions are extra options used to run this driver
DriverOpts map[string]string
// Metadata stores extra metadata on the secret
Metadata map[string]string

Maybe something like this?

Clean up store code by using StoreOpts instead of multiple args as opts
for storing secrets.

Signed-off-by: Ashley Cui <acui@redhat.com>
@ashley-cui
Copy link
Member Author

@containers/podman-maintainers Once again looking for a slash lgtm :')

@cevich
Copy link
Member

cevich commented Sep 9, 2022

/lgtm

@ashley-cui
Copy link
Member Author

/approve

@cevich
Copy link
Member

cevich commented Sep 9, 2022

/approve

2 similar comments
@edsantiago
Copy link
Member

/approve

@giuseppe
Copy link
Member

giuseppe commented Sep 9, 2022

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Sep 9, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ashley-cui, cevich, edsantiago, giuseppe

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Sep 9, 2022
@openshift-merge-robot openshift-merge-robot merged commit e568579 into containers:main Sep 9, 2022
@ashley-cui ashley-cui deleted the secretsapi branch October 4, 2022 14:01
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.

8 participants