From 5484dab802590fe306f7afdf3238d9917ecd1c9a Mon Sep 17 00:00:00 2001 From: Fredrik Hatletvedt <32248439+Pespiri@users.noreply.github.com> Date: Tue, 19 Dec 2023 13:53:10 +0100 Subject: [PATCH] Fix swagger spec enum (#572) * fix typo * fix SecretType swagger definition --- Makefile | 4 +-- api/secrets/models/secret.go | 2 +- api/secrets/models/secret_parameters.go | 1 - swaggerui/html/swagger.json | 36 ++++++++++++++++++++----- 4 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index bca17f61..0ffa1dbc 100644 --- a/Makefile +++ b/Makefile @@ -69,14 +69,14 @@ docker-push: $(addsuffix -push,$(IMAGES)) HAS_SWAGGER := $(shell command -v swagger;) HAS_STATICCHECK := $(shell command -v staticcheck;) HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;) -HAS_MOCKGEN := $(shell command -v golangci-lint;) +HAS_MOCKGEN := $(shell command -v mockgen;) bootstrap: ifndef HAS_SWAGGER go install github.com/go-swagger/go-swagger/cmd/swagger@v0.30.5 endif ifndef HAS_GOLANGCI_LINT - go install github.com/golangci/golangci-lint/cmd/golangci-lint@1.55.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.2 endif ifndef HAS_STATICCHECK go install honnef.co/go/tools/cmd/staticcheck@v0.4.6 diff --git a/api/secrets/models/secret.go b/api/secrets/models/secret.go index 98014428..b3d7aba3 100644 --- a/api/secrets/models/secret.go +++ b/api/secrets/models/secret.go @@ -20,7 +20,6 @@ type Secret struct { // Type of the secret // // required: false - // enum: generic,client-cert,azure-blob-fuse-volume,csi-azure-blob-volume,csi-azure-key-vault-creds,csi-azure-key-vault-item,client-cert-auth,oauth2-proxy // example: client-cert Type SecretType `json:"type,omitempty"` @@ -64,6 +63,7 @@ type Secret struct { TLSCertificates []TLSCertificate `json:"tlsCertificates,omitempty"` } +// swagger:enum SecretType type SecretType string const ( diff --git a/api/secrets/models/secret_parameters.go b/api/secrets/models/secret_parameters.go index 6d35b323..1e79cfe2 100644 --- a/api/secrets/models/secret_parameters.go +++ b/api/secrets/models/secret_parameters.go @@ -12,7 +12,6 @@ type SecretParameters struct { // Type of the secret // // required: false - // enum: generic,client-cert,azure-blob-fuse-volume,csi-azure-blob-volume,csi-azure-key-vault-creds,csi-azure-key-vault-item,client-cert-auth,oauth2-proxy // example: azure-blob-fuse-volume Type SecretType `json:"type,omitempty"` } diff --git a/swaggerui/html/swagger.json b/swaggerui/html/swagger.json index 96c53f36..5374a0e0 100644 --- a/swaggerui/html/swagger.json +++ b/swaggerui/html/swagger.json @@ -7180,7 +7180,21 @@ "x-go-name": "TLSCertificates" }, "type": { - "$ref": "#/definitions/SecretType" + "description": "Type of the secret\ngeneric SecretTypeGeneric\nclient-cert SecretTypeClientCert\nazure-blob-fuse-volume SecretTypeAzureBlobFuseVolume\ncsi-azure-blob-volume SecretTypeCsiAzureBlobVolume\ncsi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds\ncsi-azure-key-vault-item SecretTypeCsiAzureKeyVaultItem\nclient-cert-auth SecretTypeClientCertificateAuth\noauth2-proxy SecretTypeOAuth2Proxy", + "type": "string", + "enum": [ + "generic", + "client-cert", + "azure-blob-fuse-volume", + "csi-azure-blob-volume", + "csi-azure-key-vault-creds", + "csi-azure-key-vault-item", + "client-cert-auth", + "oauth2-proxy" + ], + "x-go-enum-desc": "generic SecretTypeGeneric\nclient-cert SecretTypeClientCert\nazure-blob-fuse-volume SecretTypeAzureBlobFuseVolume\ncsi-azure-blob-volume SecretTypeCsiAzureBlobVolume\ncsi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds\ncsi-azure-key-vault-item SecretTypeCsiAzureKeyVaultItem\nclient-cert-auth SecretTypeClientCertificateAuth\noauth2-proxy SecretTypeOAuth2Proxy", + "x-go-name": "Type", + "example": "client-cert" } }, "x-go-package": "github.com/equinor/radix-api/api/secrets/models" @@ -7199,15 +7213,25 @@ "example": "p4$sW0rDz" }, "type": { - "$ref": "#/definitions/SecretType" + "description": "Type of the secret\ngeneric SecretTypeGeneric\nclient-cert SecretTypeClientCert\nazure-blob-fuse-volume SecretTypeAzureBlobFuseVolume\ncsi-azure-blob-volume SecretTypeCsiAzureBlobVolume\ncsi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds\ncsi-azure-key-vault-item SecretTypeCsiAzureKeyVaultItem\nclient-cert-auth SecretTypeClientCertificateAuth\noauth2-proxy SecretTypeOAuth2Proxy", + "type": "string", + "enum": [ + "generic", + "client-cert", + "azure-blob-fuse-volume", + "csi-azure-blob-volume", + "csi-azure-key-vault-creds", + "csi-azure-key-vault-item", + "client-cert-auth", + "oauth2-proxy" + ], + "x-go-enum-desc": "generic SecretTypeGeneric\nclient-cert SecretTypeClientCert\nazure-blob-fuse-volume SecretTypeAzureBlobFuseVolume\ncsi-azure-blob-volume SecretTypeCsiAzureBlobVolume\ncsi-azure-key-vault-creds SecretTypeCsiAzureKeyVaultCreds\ncsi-azure-key-vault-item SecretTypeCsiAzureKeyVaultItem\nclient-cert-auth SecretTypeClientCertificateAuth\noauth2-proxy SecretTypeOAuth2Proxy", + "x-go-name": "Type", + "example": "azure-blob-fuse-volume" } }, "x-go-package": "github.com/equinor/radix-api/api/secrets/models" }, - "SecretType": { - "type": "string", - "x-go-package": "github.com/equinor/radix-api/api/secrets/models" - }, "SlackConfig": { "description": "SlackConfig configuration options for Slack", "type": "object",