From 5cc553ce71499a5217dc74af5e404681d76af856 Mon Sep 17 00:00:00 2001 From: Aaron Prindle Date: Wed, 22 Feb 2023 22:39:18 +0000 Subject: [PATCH] chore: delete unused helm fields and methods from v1 -> v2 migration --- docs-v2/content/en/schemas/v4beta3.json | 55 ------------------- pkg/skaffold/deploy/helm/helm_test.go | 71 ------------------------- pkg/skaffold/deploy/helm/util.go | 52 ------------------ pkg/skaffold/schema/latest/config.go | 21 -------- 4 files changed, 199 deletions(-) delete mode 100644 pkg/skaffold/deploy/helm/util.go diff --git a/docs-v2/content/en/schemas/v4beta3.json b/docs-v2/content/en/schemas/v4beta3.json index 037357e216b..e3a4dad2c58 100755 --- a/docs-v2/content/en/schemas/v4beta3.json +++ b/docs-v2/content/en/schemas/v4beta3.json @@ -2063,23 +2063,6 @@ "description": "defines the manifests from helm releases.", "x-intellij-html-description": "defines the manifests from helm releases." }, - "HelmConventionConfig": { - "properties": { - "explicitRegistry": { - "type": "boolean", - "description": "separates `image.registry` to the image config syntax. Useful for some charts e.g. `postgresql`.", - "x-intellij-html-description": "separates image.registry to the image config syntax. Useful for some charts e.g. postgresql.", - "default": "false" - } - }, - "preferredOrder": [ - "explicitRegistry" - ], - "additionalProperties": false, - "type": "object", - "description": "image config in the syntax of image.repository and image.tag.", - "x-intellij-html-description": "image config in the syntax of image.repository and image.tag." - }, "HelmDeployFlags": { "properties": { "global": { @@ -2120,44 +2103,6 @@ "description": "additional option flags that are passed on the command line to `helm`.", "x-intellij-html-description": "additional option flags that are passed on the command line to helm." }, - "HelmFQNConfig": { - "properties": { - "property": { - "type": "string", - "description": "defines the image config.", - "x-intellij-html-description": "defines the image config." - } - }, - "preferredOrder": [ - "property" - ], - "additionalProperties": false, - "type": "object", - "description": "image config to use the FullyQualifiedImageName as param to set.", - "x-intellij-html-description": "image config to use the FullyQualifiedImageName as param to set." - }, - "HelmImageConfig": { - "properties": { - "fqn": { - "$ref": "#/definitions/HelmFQNConfig", - "description": "image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`.", - "x-intellij-html-description": "image configuration uses the syntax IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG." - }, - "helm": { - "$ref": "#/definitions/HelmConventionConfig", - "description": "image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`.", - "x-intellij-html-description": "image configuration uses the syntax IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG." - } - }, - "preferredOrder": [ - "fqn", - "helm" - ], - "additionalProperties": false, - "type": "object", - "description": "describes an image configuration.", - "x-intellij-html-description": "describes an image configuration." - }, "HelmPackaged": { "properties": { "appVersion": { diff --git a/pkg/skaffold/deploy/helm/helm_test.go b/pkg/skaffold/deploy/helm/helm_test.go index cee6efb35f6..781f7e266a6 100644 --- a/pkg/skaffold/deploy/helm/helm_test.go +++ b/pkg/skaffold/deploy/helm/helm_test.go @@ -1148,77 +1148,6 @@ func TestHelmDependencies(t *testing.T) { } } -func TestImageSetFromConfig(t *testing.T) { - tests := []struct { - description string - valueName string - tag string - expected string - strategy *latest.HelmConventionConfig - shouldErr bool - }{ - { - description: "Helm set values with no convention config", - valueName: "image", - tag: "skaffold-helm:1.0.0", - expected: "image=skaffold-helm:1.0.0", - strategy: nil, - shouldErr: false, - }, - { - description: "Helm set values with helm conventions", - valueName: "image", - tag: "skaffold-helm:1.0.0", - expected: "image.repository=skaffold-helm,image.tag=1.0.0", - strategy: &latest.HelmConventionConfig{}, - shouldErr: false, - }, - { - description: "Helm set values with helm conventions and explicit registry value", - valueName: "image", - tag: "docker.io/skaffold-helm:1.0.0", - expected: "image.registry=docker.io,image.repository=skaffold-helm,image.tag=1.0.0", - strategy: &latest.HelmConventionConfig{ - ExplicitRegistry: true, - }, - shouldErr: false, - }, - { - description: "Invalid tag with helm conventions", - valueName: "image", - tag: "skaffold-helm:1.0.0,0", - expected: "", - strategy: &latest.HelmConventionConfig{}, - shouldErr: true, - }, - { - description: "Helm set values with helm conventions and explicit registry value, but missing in tag", - valueName: "image", - tag: "skaffold-helm:1.0.0", - expected: "", - strategy: &latest.HelmConventionConfig{ - ExplicitRegistry: true, - }, - shouldErr: true, - }, - { - description: "Helm set values using digest", - valueName: "image", - tag: "skaffold-helm:stable@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2", - expected: "image.repository=skaffold-helm,image.tag=stable@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2", - strategy: &latest.HelmConventionConfig{}, - shouldErr: false, - }, - } - for _, test := range tests { - testutil.Run(t, test.description, func(t *testutil.T) { - values, err := imageSetFromConfig(test.strategy, test.valueName, test.tag) - t.CheckError(test.shouldErr, err) - t.CheckDeepEqual(test.expected, values) - }) - } -} - func TestHelmRender(t *testing.T) { tests := []struct { description string diff --git a/pkg/skaffold/deploy/helm/util.go b/pkg/skaffold/deploy/helm/util.go deleted file mode 100644 index f5077c36912..00000000000 --- a/pkg/skaffold/deploy/helm/util.go +++ /dev/null @@ -1,52 +0,0 @@ -/* -Copyright 2020 The Skaffold Authors - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package helm - -import ( - "fmt" - - "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/docker" - "github.com/GoogleContainerTools/skaffold/v2/pkg/skaffold/schema/latest" -) - -// imageSetFromConfig calculates the --set-string value from the helm config -func imageSetFromConfig(cfg *latest.HelmConventionConfig, valueName string, tag string) (string, error) { - if cfg == nil { - return fmt.Sprintf("%s=%s", valueName, tag), nil - } - - ref, err := docker.ParseReference(tag) - if err != nil { - return "", fmt.Errorf("cannot parse the image reference %q: %w", tag, err) - } - - var imageTag string - if ref.Digest != "" { - imageTag = fmt.Sprintf("%s@%s", ref.Tag, ref.Digest) - } else { - imageTag = ref.Tag - } - - if cfg.ExplicitRegistry { - if ref.Domain == "" { - return "", fmt.Errorf("image reference %s has no domain", tag) - } - return fmt.Sprintf("%[1]s.registry=%[2]s,%[1]s.repository=%[3]s,%[1]s.tag=%[4]s", valueName, ref.Domain, ref.Path, imageTag), nil - } - - return fmt.Sprintf("%[1]s.repository=%[2]s,%[1]s.tag=%[3]s", valueName, ref.BaseName, imageTag), nil -} diff --git a/pkg/skaffold/schema/latest/config.go b/pkg/skaffold/schema/latest/config.go index 82fda813b00..6f56ca86b46 100644 --- a/pkg/skaffold/schema/latest/config.go +++ b/pkg/skaffold/schema/latest/config.go @@ -912,27 +912,6 @@ type HelmPackaged struct { AppVersion string `yaml:"appVersion,omitempty"` } -// HelmImageConfig describes an image configuration. -type HelmImageConfig struct { - // HelmFQNConfig is the image configuration uses the syntax `IMAGE-NAME=IMAGE-REPOSITORY:IMAGE-TAG`. - HelmFQNConfig *HelmFQNConfig `yaml:"fqn,omitempty" yamltags:"oneOf=helmImageStrategy"` - - // HelmConventionConfig is the image configuration uses the syntax `IMAGE-NAME.repository=IMAGE-REPOSITORY, IMAGE-NAME.tag=IMAGE-TAG`. - HelmConventionConfig *HelmConventionConfig `yaml:"helm,omitempty" yamltags:"oneOf=helmImageStrategy"` -} - -// HelmFQNConfig is the image config to use the FullyQualifiedImageName as param to set. -type HelmFQNConfig struct { - // Property defines the image config. - Property string `yaml:"property,omitempty"` -} - -// HelmConventionConfig is the image config in the syntax of image.repository and image.tag. -type HelmConventionConfig struct { - // ExplicitRegistry separates `image.registry` to the image config syntax. Useful for some charts e.g. `postgresql`. - ExplicitRegistry bool `yaml:"explicitRegistry,omitempty"` -} - // LogsConfig configures how container logs are printed as a result of a deployment. type LogsConfig struct { // Prefix defines the prefix shown on each log line. Valid values are