From 1783efdf96976d9f6c2e2dd9ccce60ecc63bc9ed Mon Sep 17 00:00:00 2001 From: rohitagg2020 Date: Tue, 14 Nov 2023 16:06:04 +0530 Subject: [PATCH] Breaking cli release package Signed-off-by: rohitagg2020 --- cli/pkg/kctrl/cmd/package/release/release.go | 5 +++-- .../{ => schemagenerator}/helm_openapi_schema_gen.go | 2 +- .../helm_openapi_schema_gen_test.go | 10 +++++----- .../{ => schemagenerator}/openapi_schema_gen.go | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) rename cli/pkg/kctrl/cmd/package/release/{ => schemagenerator}/helm_openapi_schema_gen.go (99%) rename cli/pkg/kctrl/cmd/package/release/{ => schemagenerator}/helm_openapi_schema_gen_test.go (94%) rename cli/pkg/kctrl/cmd/package/release/{ => schemagenerator}/openapi_schema_gen.go (98%) diff --git a/cli/pkg/kctrl/cmd/package/release/release.go b/cli/pkg/kctrl/cmd/package/release/release.go index 6a2ce4c74..c899a4417 100644 --- a/cli/pkg/kctrl/cmd/package/release/release.go +++ b/cli/pkg/kctrl/cmd/package/release/release.go @@ -14,6 +14,7 @@ import ( cmdapprelease "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/app/release" cmdcore "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/core" cmdpkg "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/package" + "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/package/release/schemagenerator" "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/local" buildconfigs "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/local/buildconfigs" "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/logger" @@ -175,9 +176,9 @@ func generateValuesSchema(pkgBuild buildconfigs.PackageBuild) (*kcdatav1alpha1.V templateStage := pkgBuild.Spec.Template.Spec.App.Spec.Template[0] switch { case templateStage.HelmTemplate != nil: - return NewHelmValuesSchemaGen(templateStage.HelmTemplate.Path).Schema() + return schemagenerator.NewHelmValuesSchemaGen(templateStage.HelmTemplate.Path).Schema() case templateStage.Ytt != nil: - return NewValuesSchemaGen(templateStage.Ytt.Paths).Schema() + return schemagenerator.NewValuesSchemaGen(templateStage.Ytt.Paths).Schema() } } return nil, nil diff --git a/cli/pkg/kctrl/cmd/package/release/helm_openapi_schema_gen.go b/cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen.go similarity index 99% rename from cli/pkg/kctrl/cmd/package/release/helm_openapi_schema_gen.go rename to cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen.go index a45a42bb2..83d8469c4 100644 --- a/cli/pkg/kctrl/cmd/package/release/helm_openapi_schema_gen.go +++ b/cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen.go @@ -1,7 +1,7 @@ // Copyright 2022 VMware, Inc. // SPDX-License-Identifier: Apache-2.0 -package release +package schemagenerator import ( "fmt" diff --git a/cli/pkg/kctrl/cmd/package/release/helm_openapi_schema_gen_test.go b/cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen_test.go similarity index 94% rename from cli/pkg/kctrl/cmd/package/release/helm_openapi_schema_gen_test.go rename to cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen_test.go index a105e4d36..571b83c35 100644 --- a/cli/pkg/kctrl/cmd/package/release/helm_openapi_schema_gen_test.go +++ b/cli/pkg/kctrl/cmd/package/release/schemagenerator/helm_openapi_schema_gen_test.go @@ -1,7 +1,7 @@ // Copyright 2022 VMware, Inc. // SPDX-License-Identifier: Apache-2.0 -package release_test +package schemagenerator_test import ( "io/fs" @@ -10,7 +10,7 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/package/release" + "github.com/vmware-tanzu/carvel-kapp-controller/cli/pkg/kctrl/cmd/package/release/schemagenerator" "sigs.k8s.io/yaml" ) @@ -225,7 +225,7 @@ type: object fileName := "values.yaml" err = os.WriteFile(filepath.Join(dirName, fileName), []byte(test.input), fs.ModePerm) require.NoError(t, err) - valuesSchema, err := release.NewHelmValuesSchemaGen("tmp").Schema() + valuesSchema, err := schemagenerator.NewHelmValuesSchemaGen("tmp").Schema() output, err := yaml.JSONToYAML(valuesSchema.OpenAPIv3.Raw) require.NoError(t, err) require.Equal(t, test.want, string(output), "Expected valuesSchema to match") @@ -242,7 +242,7 @@ func TestHelmValuesSchemaGen_Schema_EmptyFile(t *testing.T) { fileName := "values.yaml" err = os.WriteFile(filepath.Join(dirName, fileName), []byte(""), fs.ModePerm) require.NoError(t, err) - valuesSchema, err := release.NewHelmValuesSchemaGen("tmp").Schema() + valuesSchema, err := schemagenerator.NewHelmValuesSchemaGen("tmp").Schema() require.NoError(t, err) require.Equal(t, 0, len(valuesSchema.OpenAPIv3.Raw), "Expected valuesSchema.OpenAPIv3.Raw to be empty") } @@ -254,7 +254,7 @@ func TestHelmValuesSchemaGen_Schema_File_Not_Present(t *testing.T) { dirName := "tmp" err := os.Mkdir(dirName, fs.ModePerm) require.NoError(t, err) - valuesSchema, err := release.NewHelmValuesSchemaGen("tmp").Schema() + valuesSchema, err := schemagenerator.NewHelmValuesSchemaGen("tmp").Schema() require.NoError(t, err) require.Equal(t, 0, len(valuesSchema.OpenAPIv3.Raw), "Expected valuesSchema.OpenAPIv3.Raw to be empty") } diff --git a/cli/pkg/kctrl/cmd/package/release/openapi_schema_gen.go b/cli/pkg/kctrl/cmd/package/release/schemagenerator/openapi_schema_gen.go similarity index 98% rename from cli/pkg/kctrl/cmd/package/release/openapi_schema_gen.go rename to cli/pkg/kctrl/cmd/package/release/schemagenerator/openapi_schema_gen.go index 338503abe..98a90e191 100644 --- a/cli/pkg/kctrl/cmd/package/release/openapi_schema_gen.go +++ b/cli/pkg/kctrl/cmd/package/release/schemagenerator/openapi_schema_gen.go @@ -1,7 +1,7 @@ // Copyright 2022 VMware, Inc. // SPDX-License-Identifier: Apache-2.0 -package release +package schemagenerator import ( "bytes"