-
Notifications
You must be signed in to change notification settings - Fork 70
secret store: Add --recreate and --recreate-must options #930
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
Conversation
| Required: false, | ||
| }) | ||
| c.RegisterFlagBool(cmd.BoolFlagOpts{ | ||
| Name: "recreate-must", |
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.
I'm not really a fan of the naming of these flags because of the overloaded nature of the first one.
To me "recreate" means the thing exists and I want it to be recreated. The fact that it will internally behave like a "create", if by chance I happen to have misspelt the name, is more of an unexpected side-effect I think.
It makes recreate-must a bit confusing.
I wonder if we rename recreate to recreate-allowed and recreate-must to recreate, like so...
fastly secrets-store-entry create
# Create secret but error if secret name already exists (i.e. POST)
# e.g. I think the secret doesn't exist, so I'm OK getting an error back telling me it does
fastly secrets-store-entry create --recreate
# Recreate secret but error if secret name doesn't already exists (i.e. PATCH)
# e.g. I think the secret already exists, so I explicitly state my expectation is a recreate.
fastly secrets-store-entry create --recreate-allowed
# Create or Recreate secret (i.e. PUT)
# e.g. I don't know if the secret already exists, so I'm saying "allow a replacement to happen"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.
I've made your suggested change in 263ef62
This works in combination with fastly/go-fastly#433 which adds support for the `CreateSecretInput.Method` field. Secret names must be unique within a store. The method effects how duplicate names are handled: - `POST`: Default. Create a secret; error if one already exists with the same name. - `PUT` / `--recreate`: Create or recreate a secret. - `PATCH` / `--recreate-must`: Recreate a secret and error if one does not already exist with the same name.
070c438 to
31a3f35
Compare
| wantError: "unable to read from STDIN", | ||
| }, | ||
| { | ||
| args: fmt.Sprintf("create --store-id %s --name %s --stdin --recreate --recreate-must", storeID, secretName), |
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.
I think this test is referencing the old flag name and I expect CI to fail.
This works in combination with fastly/go-fastly#433 which adds support for the
CreateSecretInput.Methodfield.Secret names must be unique within a store.
The method effects how duplicate names are handled:
POST: Default. Create a secret; error if one already exists with the same name.PUT/--recreate-allow: Create or recreate a secret.PATCH/--recreate: Recreate a secret and error if one does not already exist with the same name.DRAFT until fastly/go-fastly#433 is merged and a new release is created.