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 API documentation for plugable secret backends #34202

Merged
merged 1 commit into from
Aug 1, 2017

Conversation

thaJeztah
Copy link
Member

Documents the API changes introduced in

0304c98 (#34157) and 08f7cf0 (#34123)

- What I did

- How I did it

- How to verify it

run make swagger-docs and visit http://localhost:9000 to view the docs

ping @liron-l @cpuguy83 @vdemeester PTAL

api/swagger.yaml Outdated
Driver:
description: "Driver represents a driver (network, logging, secrets)."
type: "object"
required: [Name, Data]
Copy link
Contributor

Choose a reason for hiding this comment

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

janky failure looks related.

09:58:42 - The swagger spec at "api/swagger.yaml" is invalid against swagger specification 2.0. see errors :
09:58:42 - "Data" is present in required but not defined as property in definition "Driver"
09:58:42 - /secrets/{id}.Spec.Driver.Data in body is required

Q: I haven't looked at the swagger.yaml before, but I'm guessing Data is supposed to Options here, which is based off

// Driver represents a driver (network, logging).
right?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, hm, looks like I may have copy/pasted the Data yes thanks, I'll check

Copy link
Member Author

Choose a reason for hiding this comment

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

Don't think Data / Options is required here, so I'll remove

@thaJeztah
Copy link
Member Author

ping @liron-l @cpuguy83 @vdemeester PTAL

api/swagger.yaml Outdated
type: "string"
x-nullable: false
example: "some-driver"
Options:
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider
description: "key/value map of driver specific options." (same as DriverConfig.Options)

@@ -19,6 +19,14 @@ keywords: "API, Docker, rcli, REST, documentation"

* `DELETE /secrets/(name)` now returns status code 404 instead of 500 when the secret does not exist.
* `POST /secrets/create` now returns status code 409 instead of 500 when creating an already existing secret.
* `POST /secrets/create` now accepts a `Driver` struct, allowing the
`Name` and diver-specific `Options` to be passed to store a secrets
Copy link
Contributor

Choose a reason for hiding this comment

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

diver-specific -> driver-specific (here and below)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch :)

@liron-l
Copy link
Contributor

liron-l commented Jul 25, 2017

LGTM @thaJeztah, left some minor comments inline.

@thaJeztah thaJeztah force-pushed the swagger-external-secrets-store branch from 22c654e to 9f19ba7 Compare July 25, 2017 09:09
@thaJeztah
Copy link
Member Author

@liron-l thanks, I updated.

Question: do you know;

  • What are the name restrictions on Secrets drivers? (e.g., only a-zA-Z0-9_.-)
  • Is there a maximum length?
  • Are Secrets driver names case-sensitive?
  • If none of the above; can we add such validation? (We've been bitten by people relying on no restrictions being there, and once we wanted to add validation, it was a breaking change)

TL;DR I'd like to document what are acceptable values for the Name field :)

@liron-l
Copy link
Contributor

liron-l commented Jul 25, 2017

Thanks @thaJeztah.
Technically, the restrictions should be on the secrets plugin name, since the driver name is only a reference to the name of the plugin. Also, we should enforce that the specified secret's plugin exist as part of the docker secret create flow (and then we don't need additional name validation).

Finally, if we do add such restrictions on the name, I know that plguins names need to have versioning support (:).
@cpuguy83 does this makes sense?

@thaJeztah
Copy link
Member Author

Ah, right, yes, these are managed plugins (installed through docker plugin install)? (sorry, I may be slow, ha!) in that case, we should probably be covered here (can add some information in future)

@liron-l
Copy link
Contributor

liron-l commented Jul 25, 2017

Yes, @thaJeztah, secret plugins are managed plugins. We will add dedicated documentation and examples after all relevant commits are merged.
docker/cli#366
moby/swarmkit#2326

api/swagger.yaml Outdated
additionalProperties:
type: "string"
example:
"value for driver-specific option"
Copy link
Member

Choose a reason for hiding this comment

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

This formatting seems wrong. I think there's a key missing here on the newline?

Copy link
Member Author

Choose a reason for hiding this comment

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

oh, this is odd, yes, definitely should be fixed 👍

data to store as secret.

This field is only used to _create_ a secret, and is not returned by
other endpoints.
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, we should probably have two different types then. One without this field. Since this already exited we can wait for another PR

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes; while working on these changes in the Swagger, I found other types that are reused and don't make sense

I think this is an "omitempty" (so in practice it's not there), but yes, probably should have a separate type

@thaJeztah thaJeztah force-pushed the swagger-external-secrets-store branch 2 times, most recently from 422c690 to 417a9a7 Compare July 27, 2017 21:58
Data:
description: "Base64-url-safe-encoded secret data"
type: "array"
Copy link
Member Author

Choose a reason for hiding this comment

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

FWIW I changed this from an array to just string; I guess this was because in go it's a []byte

screen shot 2017-07-27 at 23 53 47

Documents the API changes introduced in

0304c98 and
08f7cf0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the swagger-external-secrets-store branch from 417a9a7 to c8dad44 Compare July 27, 2017 22:01
@thaJeztah
Copy link
Member Author

@dnephin updated PTAL

Copy link
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐸

@vdemeester vdemeester merged commit 0fd90c4 into moby:master Aug 1, 2017
@thaJeztah thaJeztah deleted the swagger-external-secrets-store branch August 1, 2017 11:41
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.

None yet

6 participants