From fd26f046f74d6b52d9b962072f4d6b04a1d60992 Mon Sep 17 00:00:00 2001 From: Suleiman Dibirov <3595194+idsulik@users.noreply.github.com> Date: Tue, 12 Nov 2024 18:02:12 +0200 Subject: [PATCH] fix(config): Replace json tag with yaml for VerifyEnvVar (#9558) * fix(config): Replace json tag with yaml for VerifyEnvVar Signed-off-by: Suleiman Dibirov * fixed modify_test.go Signed-off-by: Suleiman Dibirov --------- Signed-off-by: Suleiman Dibirov --- docs-v2/content/en/schemas/v4beta12.json | 31 ++++++++++++++++++- .../inspect/jobManifestPaths/modify_test.go | 15 +++++---- pkg/skaffold/schema/latest/config.go | 8 ++--- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/docs-v2/content/en/schemas/v4beta12.json b/docs-v2/content/en/schemas/v4beta12.json index ab8e0e9c3fe..c44c32fb60f 100755 --- a/docs-v2/content/en/schemas/v4beta12.json +++ b/docs-v2/content/en/schemas/v4beta12.json @@ -4639,6 +4639,14 @@ "x-intellij-html-description": "entrypoint array. Not executed within a shell. The container image's ENTRYPOINT is used if this is not provided.", "default": "[]" }, + "env": { + "items": { + "$ref": "#/definitions/VerifyEnvVar" + }, + "type": "array", + "description": "list of environment variables to set in the container.", + "x-intellij-html-description": "list of environment variables to set in the container." + }, "image": { "type": "string", "description": "container image name.", @@ -4654,7 +4662,8 @@ "name", "image", "command", - "args" + "args", + "env" ], "additionalProperties": false, "type": "object", @@ -4662,6 +4671,26 @@ "x-intellij-html-description": "a list of tests to run on images that Skaffold builds." }, "VerifyEnvVar": { + "required": [ + "name" + ], + "properties": { + "name": { + "type": "string", + "description": "of the environment variable. Must be a C_IDENTIFIER.", + "x-intellij-html-description": "of the environment variable. Must be a C_IDENTIFIER." + }, + "value": { + "type": "string", + "description": "of the environment variable.", + "x-intellij-html-description": "of the environment variable." + } + }, + "preferredOrder": [ + "name", + "value" + ], + "additionalProperties": false, "type": "object", "description": "represents an environment variable present in a Container.", "x-intellij-html-description": "represents an environment variable present in a Container." diff --git a/pkg/skaffold/inspect/jobManifestPaths/modify_test.go b/pkg/skaffold/inspect/jobManifestPaths/modify_test.go index 296544a0539..d2c84e540c8 100644 --- a/pkg/skaffold/inspect/jobManifestPaths/modify_test.go +++ b/pkg/skaffold/inspect/jobManifestPaths/modify_test.go @@ -45,7 +45,9 @@ verify: container: name: foo image: foo - env: [] + env: + - name: key + value: value executionMode: kubernetesCluster: jobManifestPath: modified-foo.yaml @@ -60,6 +62,12 @@ verify: Container: latest.VerifyContainer{ Name: "foo", Image: "foo", + Env: []latest.VerifyEnvVar{ + { + Name: "key", + Value: "value", + }, + }, }, ExecutionMode: latest.VerifyExecutionModeConfig{ VerifyExecutionModeType: latest.VerifyExecutionModeType{ @@ -88,7 +96,6 @@ verify: container: name: foo image: foo - env: [] executionMode: kubernetesCluster: jobManifestPath: verify-manifest.yaml @@ -100,7 +107,6 @@ customActions: containers: - name: task1 image: task1-img - env: [] - name: action2 executionMode: kubernetesCluster: @@ -108,7 +114,6 @@ customActions: containers: - name: task2 image: task2-img - env: [] `, originalCfg: latest.SkaffoldConfig{ APIVersion: "skaffold/v4beta5", @@ -177,7 +182,6 @@ verify: container: name: foo image: foo - env: [] executionMode: kubernetesCluster: jobManifestPath: modified-foo.yaml @@ -189,7 +193,6 @@ customActions: containers: - name: task1 image: task1-img - env: [] `, originalCfg: latest.SkaffoldConfig{ APIVersion: "skaffold/v4beta5", diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index c6cef437592..950d121843d 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -724,16 +724,16 @@ type VerifyContainer struct { // The container image's CMD is used if this is not provided. Args []string `yaml:"args,omitempty"` // Env is the list of environment variables to set in the container. - Env []VerifyEnvVar `json:"env,omitempty"` + Env []VerifyEnvVar `yaml:"env,omitempty"` } // VerifyEnvVar represents an environment variable present in a Container. type VerifyEnvVar struct { // Name of the environment variable. Must be a C_IDENTIFIER. - Name string `json:"name" yamltags:"required"` + Name string `yaml:"name" yamltags:"required"` - // Value of the environment variable - Value string `json:"value"` + // Value of the environment variable. + Value string `yaml:"value"` } // RenderConfig contains all the configuration needed by the render steps.