Skip to content

Conversation

@Kami
Copy link
Member

@Kami Kami commented Oct 16, 2017

This pull request fixes a bug / non-consistent behavior reported in #3748.

It updates st2 apikey load command so it doesn't throw an updates an existing entry if input file contains id attribute for an item and item already exists on the server.

This way behavior is also consistent with st2 key load command.

See https://gist.github.com/Kami/bc7567c6b2b8a62f7680f64921cbf7fc for example output.

Resolves #3748

exists in the database.

This way the command is idempotent and consistent with "st2 key load"
command.

Keep in mind that update will only work if entries in JSON file contain
"id" attribute.
@Kami
Copy link
Member Author

Kami commented Oct 16, 2017

It's also worth noting that API operations exposed for /apikeys and /keys API endpoints are not the same.

datastore exposes get, set, delete while api key one supports get, create, update, delete so the actual CLI code is not 1:1 mapping and we can't simply just call update as we can do in datastore case.

@Kami Kami added this to the 2.5.0 milestone Oct 16, 2017
Copy link
Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

👍 Good thing!

Also have seen this behavior in our infra while importing api keys

@Kami Kami merged commit 85f9036 into master Oct 16, 2017
@Kami Kami deleted the api_key_load_update_if_exists branch October 16, 2017 16:13
@Kami
Copy link
Member Author

Kami commented Oct 16, 2017

Merged.

Will work on st2tests tests separately since there is really no other way to unit test this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request: option to skip duplicates when importing apikeys

3 participants