From 6b609a851a4e6d71094b3ab7e9b4f7265809b33a Mon Sep 17 00:00:00 2001 From: Anton Averchenkov Date: Sun, 26 Mar 2023 18:50:51 -0400 Subject: [PATCH 1/3] Add display attributes for OpenAPI --- path_check.go | 5 +++++ path_config.go | 12 ++++++++++++ path_creds.go | 5 +++++ path_roles.go | 8 ++++++++ 4 files changed, 30 insertions(+) diff --git a/path_check.go b/path_check.go index b592d2b..f4891bc 100644 --- a/path_check.go +++ b/path_check.go @@ -25,6 +25,11 @@ var envVarsToCheck = []string{k8sServiceHostEnv, k8sServicePortEnv} func (b *backend) pathCheck() *framework.Path { return &framework.Path{ Pattern: checkPath + "/?$", + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "kubernetes", + OperationVerb: "check", + OperationSuffix: "configuration", + }, Operations: map[logical.Operation]framework.OperationHandler{ logical.ReadOperation: &framework.PathOperation{ Callback: b.pathCheckRead, diff --git a/path_config.go b/path_config.go index 4e9d36d..0484e18 100644 --- a/path_config.go +++ b/path_config.go @@ -43,6 +43,9 @@ type kubeConfig struct { func (b *backend) pathConfig() *framework.Path { return &framework.Path{ Pattern: configPath, + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "kubernetes", + }, Fields: map[string]*framework.FieldSchema{ "disable_local_ca_jwt": { Type: framework.TypeBool, @@ -77,12 +80,21 @@ func (b *backend) pathConfig() *framework.Path { Operations: map[logical.Operation]framework.OperationHandler{ logical.UpdateOperation: &framework.PathOperation{ Callback: b.pathConfigWrite, + DisplayAttrs: &framework.DisplayAttributes{ + OperationVerb: "configure", + }, }, logical.ReadOperation: &framework.PathOperation{ Callback: b.pathConfigRead, + DisplayAttrs: &framework.DisplayAttributes{ + OperationSuffix: "configuration", + }, }, logical.DeleteOperation: &framework.PathOperation{ Callback: b.pathConfigDelete, + DisplayAttrs: &framework.DisplayAttributes{ + OperationSuffix: "configuration", + }, }, }, HelpSynopsis: "Configure the Kubernetes secret engine plugin.", diff --git a/path_creds.go b/path_creds.go index 34a25ea..1c8844b 100644 --- a/path_creds.go +++ b/path_creds.go @@ -55,6 +55,11 @@ func (b *backend) pathCredentials() *framework.Path { } return &framework.Path{ Pattern: pathCreds + framework.GenericNameRegex("name"), + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "kubernetes", + OperationVerb: "generate", + OperationSuffix: "credentials", + }, Fields: map[string]*framework.FieldSchema{ "name": { Type: framework.TypeLowerCaseString, diff --git a/path_roles.go b/path_roles.go index 354f5eb..d2c0b0f 100644 --- a/path_roles.go +++ b/path_roles.go @@ -53,6 +53,10 @@ func (b *backend) pathRoles() []*framework.Path { return []*framework.Path{ { Pattern: rolesPath + framework.GenericNameRegex("name"), + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "kubernetes", + OperationSuffix: "role", + }, Fields: map[string]*framework.FieldSchema{ "name": { Type: framework.TypeLowerCaseString, @@ -141,6 +145,10 @@ func (b *backend) pathRoles() []*framework.Path { }, { Pattern: rolesPath + "?$", + DisplayAttrs: &framework.DisplayAttributes{ + OperationPrefix: "kubernetes", + OperationSuffix: "roles", + }, Operations: map[logical.Operation]framework.OperationHandler{ logical.ListOperation: &framework.PathOperation{ Callback: b.pathRolesList, From 2f00596ec56802bb71c68bcff5d39305dee2c842 Mon Sep 17 00:00:00 2001 From: Anton Averchenkov Date: Tue, 28 Mar 2023 17:36:02 -0400 Subject: [PATCH 2/3] const --- backend.go | 3 +++ path_check.go | 2 +- path_config.go | 2 +- path_creds.go | 2 +- path_roles.go | 4 ++-- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/backend.go b/backend.go index d77cced..5c676d9 100644 --- a/backend.go +++ b/backend.go @@ -28,6 +28,9 @@ var ( // CA cert can be used, before reading it again from disk. caReloadPeriod = 1 * time.Hour + // operationPrefixKubernetes is used as a prefix for OpenAPI operation id's. + operationPrefixKubernetes = "kubernetes" + WALRollbackMinAge = "10m" ) diff --git a/path_check.go b/path_check.go index f4891bc..30590d1 100644 --- a/path_check.go +++ b/path_check.go @@ -26,7 +26,7 @@ func (b *backend) pathCheck() *framework.Path { return &framework.Path{ Pattern: checkPath + "/?$", DisplayAttrs: &framework.DisplayAttributes{ - OperationPrefix: "kubernetes", + OperationPrefix: operationPrefixKubernetes, OperationVerb: "check", OperationSuffix: "configuration", }, diff --git a/path_config.go b/path_config.go index 0484e18..27d83b1 100644 --- a/path_config.go +++ b/path_config.go @@ -44,7 +44,7 @@ func (b *backend) pathConfig() *framework.Path { return &framework.Path{ Pattern: configPath, DisplayAttrs: &framework.DisplayAttributes{ - OperationPrefix: "kubernetes", + OperationPrefix: operationPrefixKubernetes, }, Fields: map[string]*framework.FieldSchema{ "disable_local_ca_jwt": { diff --git a/path_creds.go b/path_creds.go index 1c8844b..a594d36 100644 --- a/path_creds.go +++ b/path_creds.go @@ -56,7 +56,7 @@ func (b *backend) pathCredentials() *framework.Path { return &framework.Path{ Pattern: pathCreds + framework.GenericNameRegex("name"), DisplayAttrs: &framework.DisplayAttributes{ - OperationPrefix: "kubernetes", + OperationPrefix: operationPrefixKubernetes, OperationVerb: "generate", OperationSuffix: "credentials", }, diff --git a/path_roles.go b/path_roles.go index d2c0b0f..fa5eb77 100644 --- a/path_roles.go +++ b/path_roles.go @@ -54,7 +54,7 @@ func (b *backend) pathRoles() []*framework.Path { { Pattern: rolesPath + framework.GenericNameRegex("name"), DisplayAttrs: &framework.DisplayAttributes{ - OperationPrefix: "kubernetes", + OperationPrefix: operationPrefixKubernetes, OperationSuffix: "role", }, Fields: map[string]*framework.FieldSchema{ @@ -146,7 +146,7 @@ func (b *backend) pathRoles() []*framework.Path { { Pattern: rolesPath + "?$", DisplayAttrs: &framework.DisplayAttributes{ - OperationPrefix: "kubernetes", + OperationPrefix: operationPrefixKubernetes, OperationSuffix: "roles", }, Operations: map[logical.Operation]framework.OperationHandler{ From 57d06677554b757e79232160cd76f3bdda27a74d Mon Sep 17 00:00:00 2001 From: Anton Averchenkov Date: Sat, 8 Apr 2023 17:53:15 -0400 Subject: [PATCH 3/3] go mod --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index b837200..8081e4f 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ require ( github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 github.com/hashicorp/go-version v1.6.0 github.com/hashicorp/vault/api v1.9.0 - github.com/hashicorp/vault/sdk v0.8.1 + github.com/hashicorp/vault/sdk v0.9.0 github.com/mitchellh/mapstructure v1.5.0 github.com/stretchr/testify v1.8.2 gopkg.in/square/go-jose.v2 v2.6.0 @@ -40,7 +40,7 @@ require ( github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0 // indirect - github.com/hashicorp/go-kms-wrapping/v2 v2.0.7 // indirect + github.com/hashicorp/go-kms-wrapping/v2 v2.0.8 // indirect github.com/hashicorp/go-plugin v1.4.5 // indirect github.com/hashicorp/go-retryablehttp v0.6.6 // indirect github.com/hashicorp/go-rootcerts v1.0.2 // indirect @@ -70,7 +70,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect go.uber.org/atomic v1.9.0 // indirect - golang.org/x/crypto v0.5.0 // indirect + golang.org/x/crypto v0.6.0 // indirect golang.org/x/net v0.8.0 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect golang.org/x/sys v0.6.0 // indirect diff --git a/go.sum b/go.sum index 063d0c0..ff0532c 100644 --- a/go.sum +++ b/go.sum @@ -182,8 +182,8 @@ github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJ github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0 h1:pSjQfW3vPtrOTcasTUKgCTQT7OGPPTTMVRrOfU6FJD8= github.com/hashicorp/go-kms-wrapping/entropy/v2 v2.0.0/go.mod h1:xvb32K2keAc+R8DSFG2IwDcydK9DBQE+fGA5fsw6hSk= -github.com/hashicorp/go-kms-wrapping/v2 v2.0.7 h1:P+dh3M6k5aNl2wXrA9s6zquMHWPaYIkotCffiMIYt6U= -github.com/hashicorp/go-kms-wrapping/v2 v2.0.7/go.mod h1:sDQAfwJGv25uGPZA04x87ERglCG6avnRcBT9wYoMII8= +github.com/hashicorp/go-kms-wrapping/v2 v2.0.8 h1:9Q2lu1YbbmiAgvYZ7Pr31RdlVonUpX+mmDL7Z7qTA2U= +github.com/hashicorp/go-kms-wrapping/v2 v2.0.8/go.mod h1:qTCjxGig/kjuj3hk1z8pOUrzbse/GxB1tGfbrq8tGJg= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= @@ -220,8 +220,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/vault/api v1.9.0 h1:ab7dI6W8DuCY7yCU8blo0UCYl2oHre/dloCmzMWg9w8= github.com/hashicorp/vault/api v1.9.0/go.mod h1:lloELQP4EyhjnCQhF8agKvWIVTmxbpEJj70b98959sM= -github.com/hashicorp/vault/sdk v0.8.1 h1:bdlhIpxBmJuOZ5Anumao1xeiLocR2eQrBRuJynZfTac= -github.com/hashicorp/vault/sdk v0.8.1/go.mod h1:kEpyfUU2ECGWf6XohKVFzvJ97ybSnXvxsTsBkbeVcQg= +github.com/hashicorp/vault/sdk v0.9.0 h1:Cbu9ezaZafZTXnen98QKVmufEPquhZ+r1ORZ7csNLFU= +github.com/hashicorp/vault/sdk v0.9.0/go.mod h1:VX9d+xF62YBNtiEc4l3Z2aea9HVtAS49EoniuXzHtC4= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -357,8 +357,8 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= -golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= +golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= +golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=