Skip to content

Commit

Permalink
Error out on secret/config templates for older API
Browse files Browse the repository at this point in the history
Makes sure if the user specifies an older API version that we don't pass
through templating options for versions that templating was not
supported.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
  • Loading branch information
cpuguy83 committed Feb 15, 2018
1 parent d8881e7 commit 4d3d211
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions api/server/router/swarm/cluster_routes.go
Expand Up @@ -372,6 +372,10 @@ func (sr *swarmRouter) createSecret(ctx context.Context, w http.ResponseWriter,
if err := json.NewDecoder(r.Body).Decode(&secret); err != nil {
return err
}
version := httputils.VersionFromContext(ctx)
if secret.Templating != nil && versions.LessThan(version, "1.36") {
return errdefs.InvalidParameter(errors.Errorf("secret templating is not supported on the specified API version: %s", version))
}

id, err := sr.backend.CreateSecret(secret)
if err != nil {
Expand Down Expand Up @@ -440,6 +444,11 @@ func (sr *swarmRouter) createConfig(ctx context.Context, w http.ResponseWriter,
return err
}

version := httputils.VersionFromContext(ctx)
if config.Templating != nil && versions.LessThan(version, "1.36") {
return errdefs.InvalidParameter(errors.Errorf("config templating is not supported on the specified API version: %s", version))
}

id, err := sr.backend.CreateConfig(config)
if err != nil {
return err
Expand Down

0 comments on commit 4d3d211

Please sign in to comment.