Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@awilliams-fastly
Copy link
Collaborator

@awilliams-fastly awilliams-fastly commented May 10, 2023

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-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.

@awilliams-fastly awilliams-fastly marked this pull request as draft May 10, 2023 22:37
@Integralist
Copy link
Collaborator

@awilliams-fastly https://github.com/fastly/go-fastly/releases/tag/v8.2.0

Required: false,
})
c.RegisterFlagBool(cmd.BoolFlagOpts{
Name: "recreate-must",
Copy link
Collaborator

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"

Copy link
Collaborator Author

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.
@awilliams-fastly awilliams-fastly force-pushed the awilliams/secret-store-upsert branch from 070c438 to 31a3f35 Compare May 26, 2023 16:34
@awilliams-fastly awilliams-fastly marked this pull request as ready for review May 26, 2023 16:46
wantError: "unable to read from STDIN",
},
{
args: fmt.Sprintf("create --store-id %s --name %s --stdin --recreate --recreate-must", storeID, secretName),
Copy link
Collaborator

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.

@awilliams-fastly awilliams-fastly merged commit 70d4c68 into main May 26, 2023
@awilliams-fastly awilliams-fastly deleted the awilliams/secret-store-upsert branch May 26, 2023 17:22
@Integralist Integralist added the enhancement New feature or request label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants