Repository: carvel-dev/kapp-controller
Pull request #1399 (2023-11-14 10:42:56)

Splitting cli release package
<!--  Thanks for sending a pull request!  Here are some tips for you:

If this is your first time, please read our contributor guidelines: https://github.com/carvel-dev/kapp-controller/blob/develop/CONTRIBUTING.md and developer guide https://github.com/carvel-dev/kapp-controller/blob/develop/docs/dev.md
-->

#### What this PR does / why we need it:

#### Which issue(s) this PR fixes:
<!--
If no issue exists for this change, please create an issue and link it here.
-->
Fixes #

#### Does this PR introduce a user-facing change?
<!--
If no, just write "NONE" in the release-note block below.
If yes, a release note is required:
Enter your extended release note in the block below. 

-->
```release-note

```

#### Additional Notes for your reviewer:

##### Review Checklist:

- [ ] Follows the [developer guidelines](https://carvel.dev/shared/docs/latest/development_guidelines/)
- [ ] Relevant tests are added or updated
- [ ] Relevant docs in this repo added or updated
- [ ] Relevant carvel.dev docs added or updated in a separate PR and there's
  a link to that PR
- [ ] Code is at least as readable and maintainable as it was before this
  change

#### Additional documentation e.g., Proposal, usage docs, etc.:

```docs

```



Patch:
diff --git a/cli/pkg/kctrl/cmd/package/release/release.go b/cli/pkg/kctrl/cmd/package/release/release.go
index 6a2ce4c7..c899a441 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 a45a42bb..83d8469c 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/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 338503ab..98a90e19 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"


Test patch:
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 a105e4d3..571b83c3 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")
 }