From 805e2a36c28bc60d5e73511b1f05add2cbd2f99d Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Wed, 19 Feb 2025 14:32:59 +0100 Subject: [PATCH 1/7] Ignore vendor and ginkgo coverage Signed-off-by: Gloria Ciavarrini --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 19ae4e30..37b308ae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,7 @@ .idea/ env.local + +vendor/ +**/coverage/* +**/ginkgo.report \ No newline at end of file From ddc7da78a32990ecb8d92242d15fa82e77fd76b6 Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Wed, 19 Feb 2025 14:36:28 +0100 Subject: [PATCH 2/7] Add asset generation discover cmd Signed-off-by: Jordi Gil Signed-off-by: Gloria Ciavarrini --- .../cloud_foundry/cloud_foundry_suite_test.go | 13 + .../discover/cloud_foundry/discover.go | 73 ++++++ .../discover/cloud_foundry/discover_test.go | 235 ++++++++++++++++++ cmd/asset_generation/discover/discover.go | 46 ++++ .../discover/discover_suite_test.go | 13 + .../discover/discover_test.go | 68 +++++ cmd/root.go | 8 + go.mod | 31 ++- go.sum | 62 +++-- 9 files changed, 513 insertions(+), 36 deletions(-) create mode 100644 cmd/asset_generation/discover/cloud_foundry/cloud_foundry_suite_test.go create mode 100644 cmd/asset_generation/discover/cloud_foundry/discover.go create mode 100644 cmd/asset_generation/discover/cloud_foundry/discover_test.go create mode 100644 cmd/asset_generation/discover/discover.go create mode 100644 cmd/asset_generation/discover/discover_suite_test.go create mode 100644 cmd/asset_generation/discover/discover_test.go diff --git a/cmd/asset_generation/discover/cloud_foundry/cloud_foundry_suite_test.go b/cmd/asset_generation/discover/cloud_foundry/cloud_foundry_suite_test.go new file mode 100644 index 00000000..a3a619c8 --- /dev/null +++ b/cmd/asset_generation/discover/cloud_foundry/cloud_foundry_suite_test.go @@ -0,0 +1,13 @@ +package cloud_foundry_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestCloudFoundry(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "CloudFoundry Suite") +} diff --git a/cmd/asset_generation/discover/cloud_foundry/discover.go b/cmd/asset_generation/discover/cloud_foundry/discover.go new file mode 100644 index 00000000..13cfebf8 --- /dev/null +++ b/cmd/asset_generation/discover/cloud_foundry/discover.go @@ -0,0 +1,73 @@ +package cloud_foundry + +import ( + "fmt" + "io" + "os" + + discover "github.com/gciavarrini/cf-application-discovery/pkg/discover/cloud_foundry" + "github.com/go-logr/logr" + "github.com/spf13/cobra" + "gopkg.in/yaml.v2" +) + +var ( + useLive bool + input string + output string +) + +func NewDiscoverCloudFoundryCommand(log logr.Logger) (string, *cobra.Command) { + + cmd := &cobra.Command{ + Aliases: []string{"cf"}, + Use: "cloud-foundry", + Short: "Discover Cloud Foundry applications", + PreRunE: func(cmd *cobra.Command, args []string) error { + if err := cmd.ParseFlags(args); err != nil { + return err + } + return nil + }, + RunE: func(cmd *cobra.Command, args []string) error { + return discoverManifest(cmd.OutOrStdout()) + }, + } + cmd.Flags().StringVar(&input, "input", "", "specify the location of the manifest.yaml to analyze.") + cmd.Flags().StringVar(&output, "output", "", "output file (default: standard output).") + cmd.Flags().BoolVar(&useLive, "use-live-connection", false, "uses live platform connections for real-time discovery (not implemented)") + cmd.MarkFlagFilename("input", "yaml", "yml") + cmd.MarkFlagFilename("output") + cmd.MarkFlagRequired("input") + + return "Cloud Foundry V3 (local manifest)", cmd +} + +func discoverManifest(writer io.Writer) error { + b, err := os.ReadFile(input) + if err != nil { + return err + } + + ma := discover.AppManifest{} + err = yaml.Unmarshal(b, &ma) + if err != nil { + return err + } + a, err := discover.Discover(ma, "1", "default") + if err != nil { + return err + + } + + b, err = yaml.Marshal(a) + if err != nil { + return err + + } + if output == "" { + fmt.Fprintf(writer, "%s\n", b) + return nil + } + return os.WriteFile(output, b, 0444) +} diff --git a/cmd/asset_generation/discover/cloud_foundry/discover_test.go b/cmd/asset_generation/discover/cloud_foundry/discover_test.go new file mode 100644 index 00000000..98dd73e1 --- /dev/null +++ b/cmd/asset_generation/discover/cloud_foundry/discover_test.go @@ -0,0 +1,235 @@ +package cloud_foundry + +import ( + "bufio" + "bytes" + "os" + "path/filepath" + + "github.com/go-logr/logr" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/spf13/cobra" +) + +var _ = Describe("Discover Manifest", func() { + var ( + out bytes.Buffer + writer *bufio.Writer = bufio.NewWriter(&out) + tempDir string + manifestPath string + // useLive bool + ) + + BeforeEach(func() { + tempDir, err := os.MkdirTemp("", "cloud_foundry_test") + Expect(err).NotTo(HaveOccurred()) + manifestPath = filepath.Join(tempDir, "manifest.yaml") + input = manifestPath + output = "" + // Reset buffers before each test + writer.Reset(&out) + }) + + AfterEach(func() { + os.RemoveAll(tempDir) + }) + + DescribeTable("Manifest validation", + func(manifestContent string, expectedErrorMessage string) { + err := helperCreateTestManifest(manifestPath, manifestContent, 0644) + Expect(err).ToNot(HaveOccurred(), "Unable to create manifest.yaml") + input = manifestPath + output = "" + err = discoverManifest(writer) + writer.Flush() + if expectedErrorMessage != "" { + Expect(err).ToNot(BeNil(), "Expected an error due to invalid manifest content, got none") + Expect(err.Error()).To(ContainSubstring(expectedErrorMessage)) + } else { + Expect(err).To(BeNil(), "Expected no error for invalid manifest, but got one") + } + }, + Entry("with an empty manifest", "", "field validation for 'Name' failed on the 'required' tag"), + Entry("with invalid YAML content", "invalid content", "cannot unmarshal !!str `invalid...` into cloud_foundry.AppManifest"), + Entry("with a valid manifest", `name: test-app`, ""), + ) + + DescribeTable("Manifest creation", + func(manifestContent string, perm os.FileMode, expectedErrorMessage string) { + err := helperCreateTestManifest(manifestPath, manifestContent, perm) + Expect(err).ToNot(HaveOccurred(), "Unable to create manifest.yaml") + + err = discoverManifest(writer) + if expectedErrorMessage != "" { + Expect(err).ToNot(BeNil(), "Expected an error due to invalid manifest content, got none") + Expect(err.Error()).To(ContainSubstring(expectedErrorMessage)) + } else { + Expect(err).To(BeNil(), "Expected no error for valid manifest, but got one") + } + }, + Entry("with readonly permission", `name: test-app`, os.FileMode(0444), ""), + Entry("withouth read permission", `name: test-app`, os.FileMode(0000), "manifest.yaml: permission denied"), + ) +}) +var _ = Describe("Discover command", func() { + + var ( + log logr.Logger + out bytes.Buffer + err bytes.Buffer + writer *bufio.Writer = bufio.NewWriter(&out) + + tempDir string + cmd *cobra.Command + outputPath string + manifestContent []byte + manifestPath string + ) + + BeforeEach(func() { + log = logr.Discard() + + // Reset buffers before each test + writer.Reset(&out) + + // Create a temporary directory for test files + tempDir, err := os.MkdirTemp("", "cloud_foundry_test") + Expect(err).NotTo(HaveOccurred()) + + manifestContent = []byte(`--- +name: test-app +memory: 256M +instances: 1 +`) + + manifestPath = filepath.Join(tempDir, "manifest.yaml") + Expect(os.WriteFile(manifestPath, manifestContent, 0644)).To(Succeed()) + Expect(manifestPath).ToNot(BeEmpty()) + outputPath = filepath.Join(tempDir, "output.yaml") + }) + + AfterEach(func() { + os.RemoveAll(tempDir) + }) + + type flagFile struct { + setFlag bool + filePath string + } + type flagTest struct { + Input flagFile + Output flagFile + ExpectSuccess bool + ExpectedOut string + ExpectErr bool + ExpectedErrMessage string + OutputFileVerification bool + } + + DescribeTable("flag behavior", + func(flags flagTest) { + _, cmd = NewDiscoverCloudFoundryCommand(log) + + cmd.SetOut(&out) + cmd.SetErr(&err) + args := []string{} + + if flags.Input.setFlag { + args = append(args, "--input") + if len(flags.Input.filePath) != 0 { + args = append(args, flags.Input.filePath) + } else { + // Default + args = append(args, manifestPath) + } + } + if flags.Output.setFlag { + args = append(args, "--output") + if len(flags.Output.filePath) != 0 { + args = append(args, flags.Output.filePath) + defer os.Remove(flags.Output.filePath) + } else { + // Default + args = append(args, outputPath) + } + } + + cmd.SetArgs(args) + + e := cmd.Execute() + writer.Flush() + + if flags.ExpectSuccess { + Expect(e).To(Succeed()) + } else { + Expect(e).To(HaveOccurred()) + } + + if flags.ExpectErr { + Expect(err.String()).To(ContainSubstring(flags.ExpectedErrMessage)) // Check STDERR for errors + } + + if flags.OutputFileVerification { + outputContent, err := os.ReadFile(outputPath) + Expect(err).NotTo(HaveOccurred()) + Expect(string(outputContent)).To(ContainSubstring(flags.ExpectedOut)) + Expect(out.String()).To(BeEmpty()) // Standard output should be empty + } else { + Expect(out.String()).To(ContainSubstring(flags.ExpectedOut)) // Check STDOUT for normal output + } + }, + + Entry("discovers manifest and prints output to standard output when flags are valid", + flagTest{ + Input: flagFile{setFlag: true}, + Output: flagFile{setFlag: false}, + ExpectSuccess: true, + ExpectedOut: "test-app", + ExpectErr: false, + ExpectedErrMessage: "", + OutputFileVerification: false}, + ), + + Entry("writes to output file when --output flag is given", + flagTest{ + Input: flagFile{setFlag: true}, + Output: flagFile{setFlag: true}, + ExpectSuccess: true, + ExpectedOut: "", + ExpectErr: false, + ExpectedErrMessage: "", + OutputFileVerification: false}, + ), + Entry("returns an error when input file is missing", + flagTest{ + Input: flagFile{setFlag: false}, + Output: flagFile{setFlag: false}, + ExpectSuccess: false, + ExpectedOut: "", + ExpectErr: true, + ExpectedErrMessage: "required flag", + OutputFileVerification: false}, + ), + + Entry("returns an error when input file does not exist", + + flagTest{ + Input: flagFile{setFlag: true, filePath: "nonexistent.yaml"}, + Output: flagFile{setFlag: false}, + ExpectSuccess: false, + ExpectedOut: "", + ExpectErr: true, + ExpectedErrMessage: "no such file or directory", + OutputFileVerification: false}, + ), + ) +}) + +func helperCreateTestManifest(manifestPAth string, content string, perm os.FileMode) error { + err := os.WriteFile(manifestPAth, []byte(content), perm) //0644 + if err != nil { + return err + } + return nil +} diff --git a/cmd/asset_generation/discover/discover.go b/cmd/asset_generation/discover/discover.go new file mode 100644 index 00000000..0fcb0439 --- /dev/null +++ b/cmd/asset_generation/discover/discover.go @@ -0,0 +1,46 @@ +package discover + +import ( + "fmt" + "io" + + "github.com/go-logr/logr" + "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/discover/cloud_foundry" + "github.com/spf13/cobra" +) + +var ( + platforms []string +) + +func NewDiscoverCommand(log logr.Logger) *cobra.Command { + var ( + showSupportedPlatforms bool + ) + cmd := &cobra.Command{ + Use: "discover", + GroupID: "assetGeneration", + Short: "Discover application outputs a YAML representation of source platform resources", + Run: func(cmd *cobra.Command, _ []string) { + if showSupportedPlatforms { + listPlatforms(cmd.OutOrStdout()) + } else { + cmd.Help() + } + }, + } + cmd.Flags().BoolVar(&showSupportedPlatforms, "list-platforms", false, "List available supported discovery platform.") + + // Cloud Foundry V3 + p, c := cloud_foundry.NewDiscoverCloudFoundryCommand(log) + cmd.AddCommand(c) + platforms = append(platforms, p) + return cmd +} + +func listPlatforms(out io.Writer) { + fmt.Fprintln(out, "Supported platforms:") + for _, p := range platforms { + fmt.Fprintf(out, "- %s\n", p) + } +} diff --git a/cmd/asset_generation/discover/discover_suite_test.go b/cmd/asset_generation/discover/discover_suite_test.go new file mode 100644 index 00000000..24b69792 --- /dev/null +++ b/cmd/asset_generation/discover/discover_suite_test.go @@ -0,0 +1,13 @@ +package discover_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestDiscover(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Discover CloudFoundry Suite") +} diff --git a/cmd/asset_generation/discover/discover_test.go b/cmd/asset_generation/discover/discover_test.go new file mode 100644 index 00000000..ed811e4b --- /dev/null +++ b/cmd/asset_generation/discover/discover_test.go @@ -0,0 +1,68 @@ +package discover + +import ( + "bufio" + "bytes" + + "github.com/bombsimon/logrusr/v3" + "github.com/go-logr/logr" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +var _ = Describe("Discover Command", func() { + + Context("Flag Behavior Verification", func() { + var ( + logger logr.Logger + out bytes.Buffer + err bytes.Buffer + writer *bufio.Writer = bufio.NewWriter(&out) + c *cobra.Command + ) + BeforeEach(func() { + // Reset buffers before each test + writer.Reset(&out) + + // Set up logger + logrusLog := logrus.StandardLogger() + logrusLog.SetOutput(writer) + logger = logrusr.New(logrusLog) + + // Create command instance + c = NewDiscoverCommand(logger) + c.SetOut(writer) + c.SetErr(&err) + }) + + DescribeTable("Command Flag Behavior", + func(args []string, expectedOutput string, expectError bool, expectedError string) { + c.SetArgs(args) + err := c.Execute() + writer.Flush() + if expectError { + Expect(err).To(HaveOccurred()) + Expect(err).Should(MatchError(expectedError)) + } else { + Expect(err).NotTo(HaveOccurred()) + } + Expect(out.String()).To(ContainSubstring(expectedOutput)) + + }, + + Entry("should display help message when no flags are provided", + []string{}, "Discover application outputs a YAML representation of source platform resources", false, ""), + + Entry("should return an error message for an invalid command", + []string{"invalid-command"}, "", true, "unknown command \"invalid-command\" for \"discover\""), + + Entry("should return an error message for an invalid flag", + []string{"--invalid-flag"}, "Usage:\n", true, "unknown flag: --invalid-flag"), + + Entry("should list supported platforms when --list-platforms flag is used", + []string{"--list-platforms"}, "Supported platforms:", false, ""), + ) + }) +}) diff --git a/cmd/root.go b/cmd/root.go index ec1927cc..31e3d912 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -9,6 +9,7 @@ import ( "os" "github.com/bombsimon/logrusr/v3" + "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/discover" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -43,11 +44,18 @@ func init() { logrusLog.SetOutput(os.Stdout) logrusLog.SetFormatter(&logrus.TextFormatter{}) + assertGenerationGroup := cobra.Group{ + ID: "assetGeneration", + Title: "Asset Generation", + } + rootCmd.AddGroup(&assertGenerationGroup) + logger := logrusr.New(logrusLog) rootCmd.AddCommand(NewTransformCommand(logger)) rootCmd.AddCommand(NewAnalyzeCmd(logger)) rootCmd.AddCommand(NewTestCommand(logger)) rootCmd.AddCommand(NewVersionCommand()) + rootCmd.AddCommand(discover.NewDiscoverCommand(logger)) } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/go.mod b/go.mod index 2e3aea4d..65eda57e 100644 --- a/go.mod +++ b/go.mod @@ -1,13 +1,14 @@ module github.com/konveyor-ecosystem/kantra -go 1.21.13 - -toolchain go1.22.9 +go 1.23.3 require ( github.com/devfile/alizer v1.6.1 + github.com/gciavarrini/cf-application-discovery v0.0.0-20250212150920-7c54782f247e github.com/getkin/kin-openapi v0.108.0 github.com/go-logr/logr v1.4.2 + github.com/onsi/ginkgo/v2 v2.22.2 + github.com/onsi/gomega v1.36.2 github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 github.com/spf13/cobra v1.8.1 go.lsp.dev/uri v0.3.0 @@ -24,15 +25,19 @@ require ( github.com/bufbuild/protocompile v0.10.0 // indirect github.com/cbroglie/mustache v1.4.0 // indirect github.com/containerd/typeurl/v2 v2.1.1 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect - github.com/go-openapi/jsonpointer v0.20.2 // indirect - github.com/go-openapi/swag v0.22.8 // indirect + github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/swag v0.23.0 // indirect + github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/pprof v0.0.0-20250208200701-d0013a598941 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect github.com/invopop/yaml v0.2.0 // indirect @@ -43,6 +48,7 @@ require ( github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/nxadm/tail v1.4.11 // indirect github.com/pkg/errors v0.9.1 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect github.com/swaggest/jsonschema-go v0.3.72 // indirect github.com/swaggest/openapi-go v0.2.54 // indirect @@ -53,12 +59,13 @@ require ( go.opentelemetry.io/otel/sdk v1.29.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect - golang.org/x/mod v0.20.0 // indirect - golang.org/x/net v0.34.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect - golang.org/x/sys v0.29.0 // indirect - golang.org/x/text v0.21.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + golang.org/x/mod v0.23.0 // indirect + golang.org/x/net v0.35.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect + golang.org/x/sys v0.30.0 // indirect + golang.org/x/text v0.22.0 // indirect + golang.org/x/tools v0.30.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect google.golang.org/grpc v1.68.0-dev // indirect google.golang.org/protobuf v1.36.3 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect @@ -77,5 +84,5 @@ require ( github.com/shopspring/decimal v1.4.0 // indirect github.com/sirupsen/logrus v1.9.3 github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 ) diff --git a/go.sum b/go.sum index 85bb3457..91c7b632 100644 --- a/go.sum +++ b/go.sum @@ -26,8 +26,9 @@ github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9Fqctt github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/devfile/alizer v1.6.1 h1:5G0SHFAcFNTwqsaZu5pir2pBJ04hg/F6d/lfQeAs7YY= github.com/devfile/alizer v1.6.1/go.mod h1:RHcz/nRPIlHNIfG3wTmVLrS8IyM+4CB841S/WKFXDiw= github.com/fabianvf/windup-rulesets-yaml v0.5.3 h1:CiOdTNIggt2NHwSpuCAJWKO5/X7t+Hq9+qXZ7lziGK8= @@ -35,6 +36,8 @@ github.com/fabianvf/windup-rulesets-yaml v0.5.3/go.mod h1:rv/Pzx5zMXKHbexpa8AeAI github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/gciavarrini/cf-application-discovery v0.0.0-20250212150920-7c54782f247e h1:oHUJXglRsqYck0nPwUFp/OElqPWspHQRr8OgEG+yiSo= +github.com/gciavarrini/cf-application-discovery v0.0.0-20250212150920-7c54782f247e/go.mod h1:GOEaqmYOZJhDMUOv3iKClVPzTYK8Md4R9gUErX0CD/8= github.com/getkin/kin-openapi v0.108.0 h1:EYf0GtsKa4hQNIlplGS+Au7NEfGQ1F7MoHD2kcVevPQ= github.com/getkin/kin-openapi v0.108.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -45,11 +48,13 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= -github.com/go-openapi/jsonpointer v0.20.2 h1:mQc3nmndL8ZBzStEo3JYF8wzmeWffDH4VbXz58sAx6Q= -github.com/go-openapi/jsonpointer v0.20.2/go.mod h1:bHen+N0u1KEO3YlmqOjTT9Adn1RfD91Ar825/PuiRVs= +github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= +github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.22.8 h1:/9RjDSQ0vbFR+NyjGMkFTsA1IA0fmhKSThmfGZjicbw= -github.com/go-openapi/swag v0.22.8/go.mod h1:6QT22icPLEqAM/z/TChgb4WAveCHF92+2gF0CNjHpPI= +github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= +github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= +github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= +github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= @@ -63,6 +68,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/pprof v0.0.0-20250208200701-d0013a598941 h1:43XjGa6toxLpeksjcxs1jIoIyr+vUfOqY2c6HB4bpoc= +github.com/google/pprof v0.0.0-20250208200701-d0013a598941/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= @@ -102,12 +109,17 @@ github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9 github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= +github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU= +github.com/onsi/ginkgo/v2 v2.22.2/go.mod h1:oeMosUL+8LtarXBHu/c0bx2D/K9zyQ6uX3cTyztHwsk= +github.com/onsi/gomega v1.36.2 h1:koNYke6TVk6ZmnyHrCXba/T/MoLBXFjeC1PtvYgw0A8= +github.com/onsi/gomega v1.36.2/go.mod h1:DdwyADRjrc825LhMEkD76cHR5+pUnjhUN8GlHlRPHzY= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5 h1:Ii+DKncOVM8Cu1Hc+ETb5K+23HdAMvESYE3ZJ5b5cMI= github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= @@ -135,8 +147,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/swaggest/assertjson v1.9.0 h1:dKu0BfJkIxv/xe//mkCrK5yZbs79jL7OVf9Ija7o2xQ= github.com/swaggest/assertjson v1.9.0/go.mod h1:b+ZKX2VRiUjxfUIal0HDN85W0nHPAYUbYH5WkkSsFsU= github.com/swaggest/jsonschema-go v0.3.72 h1:IHaGlR1bdBUBPfhe4tfacN2TGAPKENEGiNyNzvnVHv4= @@ -176,13 +188,13 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 h1:Di6/M8l0O2lCLc6VVRWhgCiApHV8MnQurBnFSHsQtNY= -golang.org/x/exp v0.0.0-20230725093048-515e97ebf090/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= -golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.23.0 h1:Zb7khfcRGKk+kqfxFaP5tZqCnDZMjC5VtUBs87Hr6QM= +golang.org/x/mod v0.23.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -190,16 +202,16 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= -golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8= +golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w= +golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -210,8 +222,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc= +golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -219,19 +231,21 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= +golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.30.0 h1:BgcpHewrV5AUp2G9MebG4XPFI1E2W41zU1SaqVA9vJY= +golang.org/x/tools v0.30.0/go.mod h1:c347cR/OJfw5TI+GfX7RUPNMdDRRbjvYTS0jPyvsVtY= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 h1:2035KHhUv+EpyB+hWgJnaWKJOdX1E95w2S8Rr4uWKTs= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= google.golang.org/grpc v1.68.0-dev h1:Qao/m2HpklhJt2QbpdRutxyNfRuwM8nGPpmi2UkuEHw= google.golang.org/grpc v1.68.0-dev/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= From 34f75c39767a49234789b41c5f5fae0f21674d95 Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Wed, 19 Feb 2025 14:39:13 +0100 Subject: [PATCH 3/7] Add asset generation generate cmd Signed-off-by: Jordi Gil Signed-off-by: Gloria Ciavarrini --- cmd/asset_generation/generate/generate.go | 21 ++ .../generate/generate_suite_test.go | 13 + .../generate/generate_test.go | 68 ++++ cmd/asset_generation/generate/helm/helm.go | 192 ++++++++++ .../generate/helm/helm_suite_test.go | 13 + .../generate/helm/helm_test.go | 327 ++++++++++++++++++ cmd/root.go | 2 + go.mod | 42 ++- go.sum | 96 +++++ test-data/asset_generation/helm/discover.yaml | 2 + .../helm/k8s_only/.helmignore | 23 ++ .../asset_generation/helm/k8s_only/Chart.yaml | 24 ++ .../helm/k8s_only/templates/configmap.yaml | 9 + .../helm/mixed_templates/.helmignore | 23 ++ .../helm/mixed_templates/Chart.yaml | 24 ++ .../mixed_templates/files/konveyor/Dockerfile | 6 + .../mixed_templates/templates/configmap.yaml | 9 + 17 files changed, 893 insertions(+), 1 deletion(-) create mode 100644 cmd/asset_generation/generate/generate.go create mode 100644 cmd/asset_generation/generate/generate_suite_test.go create mode 100644 cmd/asset_generation/generate/generate_test.go create mode 100644 cmd/asset_generation/generate/helm/helm.go create mode 100644 cmd/asset_generation/generate/helm/helm_suite_test.go create mode 100644 cmd/asset_generation/generate/helm/helm_test.go create mode 100644 test-data/asset_generation/helm/discover.yaml create mode 100644 test-data/asset_generation/helm/k8s_only/.helmignore create mode 100644 test-data/asset_generation/helm/k8s_only/Chart.yaml create mode 100644 test-data/asset_generation/helm/k8s_only/templates/configmap.yaml create mode 100644 test-data/asset_generation/helm/mixed_templates/.helmignore create mode 100644 test-data/asset_generation/helm/mixed_templates/Chart.yaml create mode 100644 test-data/asset_generation/helm/mixed_templates/files/konveyor/Dockerfile create mode 100644 test-data/asset_generation/helm/mixed_templates/templates/configmap.yaml diff --git a/cmd/asset_generation/generate/generate.go b/cmd/asset_generation/generate/generate.go new file mode 100644 index 00000000..5421128f --- /dev/null +++ b/cmd/asset_generation/generate/generate.go @@ -0,0 +1,21 @@ +package generate + +import ( + "github.com/go-logr/logr" + "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/generate/helm" + "github.com/spf13/cobra" +) + +func NewGenerateCommand(log logr.Logger) *cobra.Command { + cmd := &cobra.Command{ + Use: "generate", + GroupID: "assetGeneration", + Short: "Analyze the source platform and/or application and output discovery manifest.", + Run: func(cmd *cobra.Command, _ []string) { + cmd.Help() + }, + } + cmd.AddCommand(helm.NewGenerateHelmCommand(log)) + + return cmd +} diff --git a/cmd/asset_generation/generate/generate_suite_test.go b/cmd/asset_generation/generate/generate_suite_test.go new file mode 100644 index 00000000..74f9f8dd --- /dev/null +++ b/cmd/asset_generation/generate/generate_suite_test.go @@ -0,0 +1,13 @@ +package generate_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestGenerate(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Generate Suite") +} diff --git a/cmd/asset_generation/generate/generate_test.go b/cmd/asset_generation/generate/generate_test.go new file mode 100644 index 00000000..6fb09951 --- /dev/null +++ b/cmd/asset_generation/generate/generate_test.go @@ -0,0 +1,68 @@ +package generate_test + +import ( + "bufio" + "bytes" + + "github.com/bombsimon/logrusr/v3" + "github.com/go-logr/logr" + "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/generate" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +var _ = Describe("Generate Command", func() { + + var _ = Context("Flag Behavior Verification", func() { + + var ( + logger logr.Logger + out bytes.Buffer + err bytes.Buffer + writer *bufio.Writer = bufio.NewWriter(&out) + c *cobra.Command + ) + + var _ = BeforeEach(func() { + // Reset buffers before each test + writer.Reset(&out) + + // Set up logger + logrusLog := logrus.New() + logrusLog.SetOutput(&out) + logrusLog.SetFormatter(&logrus.TextFormatter{}) + logger = logrusr.New(logrusLog) + + // Create command instance + c = generate.NewGenerateCommand(logger) + c.SetOut(writer) + c.SetErr(&err) + }) + + DescribeTable("Command Flag Behavior", + func(args []string, expectedOutput string, expectError bool, expectedError string) { + c.SetArgs(args) + err := c.Execute() + writer.Flush() + if expectError { + Expect(err).To(HaveOccurred()) + Expect(err).Should(MatchError(expectedError)) + } else { + Expect(err).NotTo(HaveOccurred()) + } + Expect(out.String()).To(ContainSubstring(expectedOutput)) + + }, + Entry("should print the help message when no flags are used containing entries for each template engine", + []string{}, "helm generate the helm template manifests", false, ""), + + Entry("should return an error message for an invalid command", + []string{"invalid-command"}, "", true, "unknown command \"invalid-command\" for \"generate\""), + + Entry("should return an error message for an invalid flag", + []string{"--invalid-flag"}, "Usage:\n", true, "unknown flag: --invalid-flag"), + ) + }) +}) diff --git a/cmd/asset_generation/generate/helm/helm.go b/cmd/asset_generation/generate/helm/helm.go new file mode 100644 index 00000000..8e3031ce --- /dev/null +++ b/cmd/asset_generation/generate/helm/helm.go @@ -0,0 +1,192 @@ +package helm + +import ( + "fmt" + "io" + "maps" + "os" + "path/filepath" + "strings" + + "github.com/go-logr/logr" + "github.com/spf13/cobra" + "gopkg.in/yaml.v3" + "k8s.io/helm/pkg/strvals" + + "helm.sh/helm/v3/pkg/chart" + "helm.sh/helm/v3/pkg/chart/loader" + "helm.sh/helm/v3/pkg/chartutil" + "helm.sh/helm/v3/pkg/engine" +) + +const ( + konveyorDirectoryName = "files/konveyor" +) + +var ( + input string + outputDir string + chartDir string + nonK8SOnly bool + setValues []string +) + +func NewGenerateHelmCommand(log logr.Logger) *cobra.Command { + cmd := &cobra.Command{ + Use: "helm", + Short: "generate the helm template manifests", + RunE: func(cmd *cobra.Command, args []string) error { + return helm(cmd.OutOrStdout()) + }, + } + cmd.Flags().StringVar(&chartDir, "chart-dir", "", "Directory to the Helm chart to use for chart generation.") + cmd.Flags().StringVar(&input, "input", "", "Specifies the discover manifest file") + cmd.Flags().StringVar(&outputDir, "output-dir", "", "Directory to save the generated Helm chart. Defaults to stdout") + cmd.Flags().BoolVar(&nonK8SOnly, "non-k8s-only", false, "Render only the non-Kubernetes templates located in the files/konveyor directory of the chart") + cmd.Flags().StringArrayVar(&setValues, "set", []string{}, "Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") + + // Validation + cmd.MarkFlagDirname("chart-dir") + cmd.MarkFlagDirname("output-dir") + cmd.MarkFlagFilename("input") + // Required + cmd.MarkFlagRequired("chart-dir") + cmd.MarkFlagRequired("input") + + return cmd +} + +func helm(out io.Writer) error { + chart, err := loadChart() + if err != nil { + return err + } + values, err := loadDiscoverManifest() + if err != nil { + return err + } + if len(setValues) > 0 { + v, err := parseValues() + if err != nil { + return err + } + maps.Copy(values, v) + } + chart.Values = values + rendered := make(map[string]string) + if !nonK8SOnly { + rendered, err = generateK8sTemplates(*chart) + if err != nil { + return err + } + } + r, err := generateNonK8sTemplates(*chart) + if err != nil { + return err + } + maps.Copy(rendered, r) + + o := output{out: out} + print := o.toStdout + if outputDir != "" { + err = os.MkdirAll(outputDir, 0755) + if err != nil { + return err + } + print = toFile + } + for f, c := range rendered { + err = print(f, c) + if err != nil { + return err + } + } + return nil +} + +type output struct { + out io.Writer +} + +func (o output) toStdout(filename, contents string) error { + fmt.Fprintf(o.out, "---\n# Source: %s\n%s", filename, contents) + return nil +} + +func toFile(filename, contents string) error { + fn := filepath.Base(filename) + dst := filepath.Join(outputDir, fn) + // Add an extra line to make it yaml compliant since helm doesn't seem to do it. + contents = fmt.Sprintln(contents) + return os.WriteFile(dst, []byte(contents), 0644) +} + +func loadChart() (*chart.Chart, error) { + l, err := loader.Loader(chartDir) + if err != nil { + return nil, fmt.Errorf("unable to load chart: %s", err) + } + return l.Load() +} + +func loadDiscoverManifest() (map[string]interface{}, error) { + d, err := os.ReadFile(input) + if err != nil { + return nil, fmt.Errorf("unable to load discover manifest: %s", err) + } + var m map[string]interface{} + err = yaml.Unmarshal(d, &m) + return m, err +} + +func generateK8sTemplates(chart chart.Chart) (map[string]string, error) { + return generateTemplates(chart) +} + +func generateNonK8sTemplates(chart chart.Chart) (map[string]string, error) { + chart.Templates = filterTemplatesByPath(konveyorDirectoryName, chart.Files) + return generateTemplates(chart) +} + +func generateTemplates(chart chart.Chart) (map[string]string, error) { + e := engine.Engine{} + options := chartutil.ReleaseOptions{ + Name: chart.Name(), + Namespace: "", + Revision: 1, + IsInstall: false, + IsUpgrade: false, + } + valuesToRender, err := chartutil.ToRenderValues(&chart, chart.Values, options, chartutil.DefaultCapabilities.Copy()) + if err != nil { + return nil, fmt.Errorf("failed to render the values for chart %s: %s", chart.Name(), err) + } + chart.Values = valuesToRender + rendered, err := e.Render(&chart, valuesToRender) + if err != nil { + return nil, fmt.Errorf("failed to render the templates for chart %s: %s", chart.Name(), err) + } + return rendered, nil + +} + +func filterTemplatesByPath(pathPrefix string, files []*chart.File) []*chart.File { + ret := []*chart.File{} + for _, f := range files { + if strings.HasPrefix(f.Name, pathPrefix) { + ret = append(ret, f) + } + } + return ret +} + +func parseValues() (map[string]interface{}, error) { + // User specified a value via --set + base := make(map[string]interface{}) + for _, value := range setValues { + if err := strvals.ParseInto(value, base); err != nil { + return nil, fmt.Errorf("failed parsing --set data:%s", err) + } + } + return base, nil +} diff --git a/cmd/asset_generation/generate/helm/helm_suite_test.go b/cmd/asset_generation/generate/helm/helm_suite_test.go new file mode 100644 index 00000000..dcafcbab --- /dev/null +++ b/cmd/asset_generation/generate/helm/helm_suite_test.go @@ -0,0 +1,13 @@ +package helm_test + +import ( + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestHelm(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "Helm Suite") +} diff --git a/cmd/asset_generation/generate/helm/helm_test.go b/cmd/asset_generation/generate/helm/helm_test.go new file mode 100644 index 00000000..fa76e0d4 --- /dev/null +++ b/cmd/asset_generation/generate/helm/helm_test.go @@ -0,0 +1,327 @@ +package helm_test + +import ( + "bytes" + "os" + "path" + "strings" + + "github.com/bombsimon/logrusr/v3" + "github.com/go-logr/logr" + "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/generate/helm" + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" +) + +var _ = Describe("Helm command", func() { + + type cmdFlags struct { + input string + chartDir string + output string + nonK8s bool + set []string + } + + type testCase struct { + args []string + expectedError string + expectedOut string + } + + var ( + logger logr.Logger + outBuffer bytes.Buffer + errBuffer bytes.Buffer + c *cobra.Command + ) + + const ( + testDiscoverPath = "../../../../test-data/asset_generation/helm/discover.yaml" + chartDir = "../../../../test-data/asset_generation/helm/" + ) + + var _ = BeforeEach(func() { + logrusLog := logrus.New() + logrusLog.SetOutput(&outBuffer) + logrusLog.SetFormatter(&logrus.TextFormatter{}) + logger = logrusr.New(logrusLog) + outBuffer = bytes.Buffer{} + errBuffer = bytes.Buffer{} + c = helm.NewGenerateHelmCommand(logger) + c.SetOut(&outBuffer) + c.SetErr(&errBuffer) + }) + DescribeTable("validating the execution when not generating templates", + func(tc testCase) { + c.SetArgs(tc.args) + err := c.Execute() + + if tc.expectedError != "" { + Expect(err).To(HaveOccurred()) + Expect(err).Should(MatchError(tc.expectedError)) + + } else { + Expect(err).NotTo(HaveOccurred()) + Expect(outBuffer.String()).To(ContainSubstring(tc.expectedOut)) + } + }, + + Entry("shows the help message when the -h flag is used", + testCase{args: []string{"-h"}, expectedError: "", expectedOut: "generate the helm template manifests"}), + + Entry("shows the error message when no flags are provided", + testCase{args: []string{}, expectedError: `required flag(s) "chart-dir", "input" not set`}), + + Entry("shows the error message when only the input flag is provided", + testCase{args: []string{"--input", "discover.yaml"}, expectedError: `required flag(s) "chart-dir" not set`}), + + Entry("shows the error message when only the chart-dir flag is provided", + testCase{args: []string{"--chart-dir", chartDir}, expectedError: `required flag(s) "input" not set`}), + + Entry("shows the error message when only the non-required flags are provided", + testCase{args: []string{"--non-k8s-only", "--output-dir", "./", "--set", "foo=bar"}, expectedError: `required flag(s) "chart-dir", "input" not set`}), + + Entry("shows an error message when the input flag points to an invalid file", + testCase{args: []string{"--input", "nonexistent.file", "--chart-dir", path.Join(chartDir, "k8s_only")}, + expectedError: `unable to load discover manifest: open nonexistent.file: no such file or directory`}), + + Entry("shows an error message when the chart-dir flag points to an invalid directory", + testCase{args: []string{"--input", testDiscoverPath, "--chart-dir", "nonexistent.dir"}, + expectedError: `unable to load chart: stat nonexistent.dir: no such file or directory`}), + + Entry("shows an error message when the set flag contains an invalid k/v pair", + testCase{args: []string{"--input", testDiscoverPath, "--chart-dir", path.Join(chartDir, "k8s_only"), "--set", "a,1"}, + expectedError: `failed parsing --set data:key "a" has no value (cannot end with ,)`}), + ) + + var _ = When("validating the execution when generating templates", func() { + + Context("when using the output flag", func() { + var ( + manifests = map[string]string{ + "configmap.yaml": `apiVersion: v1 +data: + chartName: hello world! +kind: ConfigMap +metadata: + name: sample + +`, "Dockerfile": `FROM python:3 + +RUN echo hello world! +`} + ) + It("generates the manifest files in the specified directory", func() { + + tmpDir, err := os.MkdirTemp("", "generate") + Expect(err).NotTo(HaveOccurred()) + defer os.RemoveAll(tmpDir) + c.SetArgs([]string{ + "--input", testDiscoverPath, + "--chart-dir", path.Join(chartDir, "mixed_templates"), + "--output-dir", tmpDir}) + err = c.Execute() + Expect(err).NotTo(HaveOccurred()) + Expect(outBuffer.String()).To(BeEmpty()) + Expect(errBuffer.String()).To(BeEmpty()) + f, err := os.ReadDir(tmpDir) + Expect(err).NotTo(HaveOccurred()) + Expect(len(f)).To(Equal(len(manifests))) + for k, v := range manifests { + m, err := os.ReadFile(path.Join(tmpDir, k)) + Expect(err).NotTo(HaveOccurred()) + Expect(string(m)).To(Equal(v)) + } + }) + }) + + DescribeTable("when sending the results to stdout", func(flags cmdFlags, expected string) { + args := []string{} + if flags.input != "" { + args = append(args, []string{"--input", flags.input}...) + } + if flags.chartDir != "" { + args = append(args, []string{"--chart-dir", flags.chartDir}...) + } + if len(flags.set) > 0 { + for _, s := range flags.set { + args = append(args, append([]string{"--set"}, s)...) + } + } + if flags.nonK8s { + args = append(args, "--non-k8s-only") + } + c.SetArgs(args) + err := c.Execute() + Expect(err).NotTo(HaveOccurred()) + results := strings.Split(outBuffer.String(), "---\n") + se := strings.Split(expected, "---\n") + Expect(len(results)).To(Equal(len(se))) + for _, v := range results { + Expect(v).To(BeElementOf(se)) + } + }, + Entry("generates the manifests for a K8s chart using the discover manifest as input", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "k8s_only"), + }, `--- +# Source: k8s_only/templates/configmap.yaml +apiVersion: v1 +data: + chartName: hello world! +kind: ConfigMap +metadata: + name: sample +`), + Entry("generates the manifests for a K8s chart while overriding the variable in the discover.yaml", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "k8s_only"), + set: []string{"foo.bar=bar.foo"}, + }, `--- +# Source: k8s_only/templates/configmap.yaml +apiVersion: v1 +data: + chartName: bar.foo +kind: ConfigMap +metadata: + name: sample +`), + Entry("generates the manifests for a K8s chart while adding a new variable that is interpreted in the template", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "k8s_only"), + set: []string{"extra.value=Lorem Ipsum"}, + }, `--- +# Source: k8s_only/templates/configmap.yaml +apiVersion: v1 +data: + chartName: hello world! + extraValue: Lorem Ipsum +kind: ConfigMap +metadata: + name: sample +`), + Entry("generates no manifest in a K8s chart when specifying the flag to generate only the non-K8s templates", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "k8s_only"), + nonK8s: true, + }, "", + ), + Entry("generates both non-K8s and K8s manifests in a chart that contains both type of templates with the discover manifest as input", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "mixed_templates"), + }, `--- +# Source: mixed_templates/templates/configmap.yaml +apiVersion: v1 +data: + chartName: hello world! +kind: ConfigMap +metadata: + name: sample +--- +# Source: mixed_templates/files/konveyor/Dockerfile +FROM python:3 + +RUN echo hello world!`), + Entry("with a chart with mixed templates and overriding the variable in the values.yaml", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "mixed_templates"), + set: []string{"foo.bar=bar.foo"}, + }, `--- +# Source: mixed_templates/templates/configmap.yaml +apiVersion: v1 +data: + chartName: bar.foo +kind: ConfigMap +metadata: + name: sample +--- +# Source: mixed_templates/files/konveyor/Dockerfile +FROM python:3 + +RUN echo bar.foo`), + Entry("with a chart with mixed templates and adding a new variable that is captured in the template", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "mixed_templates"), + set: []string{"extra.value=Lorem Ipsum"}, + }, `--- +# Source: mixed_templates/files/konveyor/Dockerfile +FROM python:3 + +RUN echo hello world! +RUN echo Lorem Ipsum +--- +# Source: mixed_templates/templates/configmap.yaml +apiVersion: v1 +data: + chartName: hello world! + extraValue: Lorem Ipsum +kind: ConfigMap +metadata: + name: sample +`), + Entry("with a chart with mixed templates with multiple variables as input", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "mixed_templates"), + set: []string{"extra.value=Lorem Ipsum", "foo.bar=bar foo"}, + }, `--- +# Source: mixed_templates/files/konveyor/Dockerfile +FROM python:3 + +RUN echo bar foo +RUN echo Lorem Ipsum +--- +# Source: mixed_templates/templates/configmap.yaml +apiVersion: v1 +data: + chartName: bar foo + extraValue: Lorem Ipsum +kind: ConfigMap +metadata: + name: sample +`), + Entry("with a chart with mixed templates with multiple variables as input in a single set flag", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "mixed_templates"), + set: []string{"extra.value=Lorem Ipsum,foo.bar=bar foo"}, + }, `--- +# Source: mixed_templates/files/konveyor/Dockerfile +FROM python:3 + +RUN echo bar foo +RUN echo Lorem Ipsum +--- +# Source: mixed_templates/templates/configmap.yaml +apiVersion: v1 +data: + chartName: bar foo + extraValue: Lorem Ipsum +kind: ConfigMap +metadata: + name: sample +`), + Entry("only generates the non-K8s manifests in a chart that contains both type of templates", + cmdFlags{ + input: testDiscoverPath, + chartDir: path.Join(chartDir, "mixed_templates"), + nonK8s: true, + }, `--- +# Source: mixed_templates/files/konveyor/Dockerfile +FROM python:3 + +RUN echo hello world!`, + ), + ) + }) +}) diff --git a/cmd/root.go b/cmd/root.go index 31e3d912..fde6f93e 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -10,6 +10,7 @@ import ( "github.com/bombsimon/logrusr/v3" "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/discover" + "github.com/konveyor-ecosystem/kantra/cmd/asset_generation/generate" "github.com/sirupsen/logrus" "github.com/spf13/cobra" ) @@ -56,6 +57,7 @@ func init() { rootCmd.AddCommand(NewTestCommand(logger)) rootCmd.AddCommand(NewVersionCommand()) rootCmd.AddCommand(discover.NewDiscoverCommand(logger)) + rootCmd.AddCommand(generate.NewGenerateCommand(logger)) } // Execute adds all child commands to the root command and sets flags appropriately. diff --git a/go.mod b/go.mod index 65eda57e..7f5f2be0 100644 --- a/go.mod +++ b/go.mod @@ -16,59 +16,99 @@ require ( go.opentelemetry.io/otel/trace v1.29.0 gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v3 v3.0.1 + helm.sh/helm/v3 v3.17.1 + k8s.io/helm v2.17.0+incompatible ) require ( cloud.google.com/go/compute/metadata v0.5.0 // indirect + dario.cat/mergo v1.0.1 // indirect + github.com/BurntSushi/toml v1.4.0 // indirect + github.com/Masterminds/goutils v1.1.1 // indirect + github.com/Masterminds/semver/v3 v3.3.0 // indirect + github.com/Masterminds/sprig/v3 v3.3.0 // indirect github.com/antchfx/xpath v1.3.1 // indirect github.com/bufbuild/protocompile v0.10.0 // indirect github.com/cbroglie/mustache v1.4.0 // indirect github.com/containerd/typeurl/v2 v2.1.1 // indirect + github.com/cyphar/filepath-securejoin v0.3.6 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect github.com/fsnotify/fsnotify v1.8.0 // indirect + github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/go-logr/zapr v1.3.0 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect github.com/go-openapi/swag v0.23.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang-jwt/jwt/v5 v5.2.1 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.4 // indirect + github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect github.com/google/pprof v0.0.0-20250208200701-d0013a598941 // indirect github.com/google/uuid v1.6.0 // indirect github.com/hashicorp/go-version v1.7.0 // indirect + github.com/huandu/xstrings v1.5.0 // indirect github.com/invopop/yaml v0.2.0 // indirect github.com/jhump/protoreflect v1.16.0 // indirect github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/mitchellh/copystructure v1.2.0 // indirect + github.com/mitchellh/reflectwalk v1.0.2 // indirect github.com/moby/buildkit v0.14.1 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/nxadm/tail v1.4.11 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect + github.com/spf13/cast v1.7.0 // indirect github.com/swaggest/jsonschema-go v0.3.72 // indirect github.com/swaggest/openapi-go v0.2.54 // indirect github.com/swaggest/refl v1.3.0 // indirect github.com/vifraa/gopom v1.0.0 // indirect + github.com/x448/float16 v0.8.4 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/sdk v1.29.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect + golang.org/x/crypto v0.33.0 // indirect golang.org/x/mod v0.23.0 // indirect golang.org/x/net v0.35.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sys v0.30.0 // indirect + golang.org/x/term v0.29.0 // indirect golang.org/x/text v0.22.0 // indirect + golang.org/x/time v0.7.0 // indirect golang.org/x/tools v0.30.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240826202546-f6391c0de4c7 // indirect google.golang.org/grpc v1.68.0-dev // indirect google.golang.org/protobuf v1.36.3 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + k8s.io/api v0.32.1 // indirect + k8s.io/apiextensions-apiserver v0.32.1 // indirect + k8s.io/apimachinery v0.32.1 // indirect + k8s.io/client-go v0.32.1 // indirect + k8s.io/klog/v2 v2.130.1 // indirect + k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect + k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect + sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect + sigs.k8s.io/yaml v1.4.0 // indirect ) require ( diff --git a/go.sum b/go.sum index 91c7b632..f20d3c55 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,17 @@ cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= cloud.google.com/go/compute/metadata v0.5.0/go.mod h1:aHnloV2TPI38yx4s9+wAZhHykWvVCfu7hQbF+9CWoiY= +dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= +dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 h1:bvDV9vkmnHYOMsOr4WLk+Vo07yKIzd94sVoIqshQ4bU= +github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24/go.mod h1:8o94RPi1/7XTJvwPpRSzSUedZrtlirdB3r9Z20bi2f8= +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/Masterminds/goutils v1.1.1 h1:5nUrii3FMTL5diU80unEVvNevw1nH4+ZV4DSLVJLSYI= +github.com/Masterminds/goutils v1.1.1/go.mod h1:8cTjp+g8YejhMuvIA5y2vz3BpJxksy863GQaJW2MFNU= +github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0= +github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM= +github.com/Masterminds/sprig/v3 v3.3.0 h1:mQh0Yrg1XPo6vjYXgtf5OtijNAKJRNcTdOOGZe3tPhs= +github.com/Masterminds/sprig/v3 v3.3.0/go.mod h1:Zy1iXRYNqNLUolqCpL4uhk6SHUMAOSCzdgBfDb35Lz0= github.com/PaesslerAG/gval v1.2.4 h1:rhX7MpjJlcxYwL2eTTYIOBUyEKZ+A96T9vQySWkVUiU= github.com/PaesslerAG/gval v1.2.4/go.mod h1:XRFLwvmkTEdYziLdaCeCa5ImcGVrfQbeNUbVR+C6xac= github.com/PaesslerAG/jsonpath v0.1.0 h1:gADYeifvlqK3R3i2cR5B4DGgxLXIPb3TRTH1mGi0jPI= @@ -25,21 +37,32 @@ github.com/codingconcepts/env v0.0.0-20200821220118-a8fbf8d84482/go.mod h1:TM9ug github.com/containerd/typeurl/v2 v2.1.1 h1:3Q4Pt7i8nYwy2KmQWIw2+1hTvwTE/6w9FqcttATPO/4= github.com/containerd/typeurl/v2 v2.1.1/go.mod h1:IDp2JFvbwZ31H8dQbEIY7sDl2L3o3HZj1hsSQlywkQ0= github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM= +github.com/cyphar/filepath-securejoin v0.3.6/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/devfile/alizer v1.6.1 h1:5G0SHFAcFNTwqsaZu5pir2pBJ04hg/F6d/lfQeAs7YY= github.com/devfile/alizer v1.6.1/go.mod h1:RHcz/nRPIlHNIfG3wTmVLrS8IyM+4CB841S/WKFXDiw= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/fabianvf/windup-rulesets-yaml v0.5.3 h1:CiOdTNIggt2NHwSpuCAJWKO5/X7t+Hq9+qXZ7lziGK8= github.com/fabianvf/windup-rulesets-yaml v0.5.3/go.mod h1:rv/Pzx5zMXKHbexpa8AeAI91Cb8Mw532jmx4HkgjGOc= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M= github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= +github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= +github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/gciavarrini/cf-application-discovery v0.0.0-20250212150920-7c54782f247e h1:oHUJXglRsqYck0nPwUFp/OElqPWspHQRr8OgEG+yiSo= github.com/gciavarrini/cf-application-discovery v0.0.0-20250212150920-7c54782f247e/go.mod h1:GOEaqmYOZJhDMUOv3iKClVPzTYK8Md4R9gUErX0CD/8= github.com/getkin/kin-openapi v0.108.0 h1:EYf0GtsKa4hQNIlplGS+Au7NEfGQ1F7MoHD2kcVevPQ= github.com/getkin/kin-openapi v0.108.0/go.mod h1:QtwUNt0PAAgIIBEvFWYfB7dfngxtAaqCX1zYHMZDeK8= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= @@ -48,13 +71,19 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/go-logr/zapr v1.3.0 h1:XGdV8XW8zdwFiwOA2Dryh1gj2KRQyOOoNmBy4EplIcQ= github.com/go-logr/zapr v1.3.0/go.mod h1:YKepepNBd1u/oyhd/yQmtjVXmm9uML4IXUgMOwR8/Gg= github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= github.com/go-openapi/jsonpointer v0.21.0 h1:YgdVicSA9vH5RiHs9TZW5oyafXZFc6+2Vc1rr/O9oNQ= github.com/go-openapi/jsonpointer v0.21.0/go.mod h1:IUyH9l/+uyhIYQ/PXVA41Rexl+kOkAPDdXEYns6fzUY= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/swag v0.23.0 h1:vsEVJDUo2hPJ2tu0/Xc+4noaxyEffXNIs3cOULZ+GrE= github.com/go-openapi/swag v0.23.0/go.mod h1:esZ8ITTYEsH1V2trKHjAN8Ai7xHb8RV+YSZ577vPjgQ= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= @@ -64,10 +93,16 @@ github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4er github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20250208200701-d0013a598941 h1:43XjGa6toxLpeksjcxs1jIoIyr+vUfOqY2c6HB4bpoc= github.com/google/pprof v0.0.0-20250208200701-d0013a598941/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -75,6 +110,8 @@ github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/huandu/xstrings v1.5.0 h1:2ag3IFq9ZDANvthTwTiqSSZLjDc+BedvHPAp5tJy2TI= +github.com/huandu/xstrings v1.5.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/iancoleman/orderedmap v0.3.0 h1:5cbR2grmZR/DiVt+VJopEhtVs9YGInGIxAoMJn+Ichc= github.com/iancoleman/orderedmap v0.3.0/go.mod h1:XuLcCUkdL5owUCQeF2Ue9uuw1EptkJDkXXS7VoV7XGE= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -86,6 +123,8 @@ github.com/jhump/protoreflect v1.16.0 h1:54fZg+49widqXYQ0b+usAFHbMkBGR4PpXrsHc8+ github.com/jhump/protoreflect v1.16.0/go.mod h1:oYPd7nPvcBw/5wlDfm/AVmU9zH9BgqGCI469pGxfj/8= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/konveyor/analyzer-lsp v0.6.0-alpha.2.0.20250115183201-2f9344a41b10 h1:0x1Mk5jPommKpN2NKpkQxn5FJLAfohSjLalsRijx19I= @@ -93,6 +132,7 @@ github.com/konveyor/analyzer-lsp v0.6.0-alpha.2.0.20250115183201-2f9344a41b10/go github.com/konveyor/analyzer-lsp/external-providers/java-external-provider v0.0.0-20250129143638-35bb8a364cdb h1:mWDDNdukmdowsS8/1XBpjfisqH/a+teyo2FpSxhZJM8= github.com/konveyor/analyzer-lsp/external-providers/java-external-provider v0.0.0-20250129143638-35bb8a364cdb/go.mod h1:9hR5THTSExZSAPz8uDEVgm2gm47F8gqFj8cU9K/d32M= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -103,10 +143,21 @@ github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= +github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= +github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= +github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/moby/buildkit v0.14.1 h1:2epLCZTkn4CikdImtsLtIa++7DzCimrrZCT1sway+oI= github.com/moby/buildkit v0.14.1/go.mod h1:1XssG7cAqv5Bz1xcGMxJL123iCv5TYN4Z/qf647gfuk= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nxadm/tail v1.4.11 h1:8feyoE3OzPrcshW5/MJ4sGESc5cqmGkGCWlco4l0bqY= github.com/nxadm/tail v1.4.11/go.mod h1:OTaG3NK980DZzxbRq6lEuzgU+mug70nY11sMd4JXXHc= github.com/onsi/ginkgo/v2 v2.22.2 h1:/3X8Panh8/WwhU/3Ssa6rCKqPLuAkVY2I0RoyDLySlU= @@ -132,6 +183,8 @@ github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w= +github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM= github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= @@ -159,6 +212,15 @@ github.com/swaggest/refl v1.3.0 h1:PEUWIku+ZznYfsoyheF97ypSduvMApYyGkYF3nabS0I= github.com/swaggest/refl v1.3.0/go.mod h1:3Ujvbmh1pfSbDYjC6JGG7nMgPvpG0ehQL4iNonnLNbg= github.com/vifraa/gopom v1.0.0 h1:L9XlKbyvid8PAIK8nr0lihMApJQg/12OBvMA28BcWh0= github.com/vifraa/gopom v1.0.0/go.mod h1:oPa1dcrGrtlO37WPDBm5SqHAT+wTgF8An1Q71Z6Vv4o= +github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= +github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= @@ -188,6 +250,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus= +golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -227,12 +291,16 @@ golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU= +golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM= golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY= +golang.org/x/time v0.7.0 h1:ntUhktv3OPE6TgYxXWv9vKvUSJyIFJlyohwbkEwPrKQ= +golang.org/x/time v0.7.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= @@ -256,6 +324,10 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSPG+6V4= +gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -265,3 +337,27 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +helm.sh/helm/v3 v3.17.1 h1:gzVoAD+qVuoJU6KDMSAeo0xRJ6N1znRxz3wyuXRmJDk= +helm.sh/helm/v3 v3.17.1/go.mod h1:nvreuhuR+j78NkQcLC3TYoprCKStLyw5P4T7E5itv2w= +k8s.io/api v0.32.1 h1:f562zw9cy+GvXzXf0CKlVQ7yHJVYzLfL6JAS4kOAaOc= +k8s.io/api v0.32.1/go.mod h1:/Yi/BqkuueW1BgpoePYBRdDYfjPF5sgTr5+YqDZra5k= +k8s.io/apiextensions-apiserver v0.32.1 h1:hjkALhRUeCariC8DiVmb5jj0VjIc1N0DREP32+6UXZw= +k8s.io/apiextensions-apiserver v0.32.1/go.mod h1:sxWIGuGiYov7Io1fAS2X06NjMIk5CbRHc2StSmbaQto= +k8s.io/apimachinery v0.32.1 h1:683ENpaCBjma4CYqsmZyhEzrGz6cjn1MY/X2jB2hkZs= +k8s.io/apimachinery v0.32.1/go.mod h1:GpHVgxoKlTxClKcteaeuF1Ul/lDVb74KpZcxcmLDElE= +k8s.io/client-go v0.32.1 h1:otM0AxdhdBIaQh7l1Q0jQpmo7WOFIk5FFa4bg6YMdUU= +k8s.io/client-go v0.32.1/go.mod h1:aTTKZY7MdxUaJ/KiUs8D+GssR9zJZi77ZqtzcGXIiDg= +k8s.io/helm v2.17.0+incompatible h1:Bpn6o1wKLYqKM3+Osh8e+1/K2g/GsQJ4F4yNF2+deao= +k8s.io/helm v2.17.0+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI= +k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= +k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= +k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f h1:GA7//TjRY9yWGy1poLzYYJJ4JRdzg3+O6e8I+e+8T5Y= +k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f/go.mod h1:R/HEjbvWI0qdfb8viZUeVZm0X6IZnxAydC7YU42CMw4= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 h1:M3sRQVHv7vB20Xc2ybTt7ODCeFj6JSWYFzOFnYeS6Ro= +k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 h1:/Rv+M11QRah1itp8VhT6HoVx1Ray9eB4DBr+K+/sCJ8= +sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3/go.mod h1:18nIHnGi6636UCz6m8i4DhaJ65T6EruyzmoQqI2BVDo= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2 h1:MdmvkGuXi/8io6ixD5wud3vOLwc1rj0aNqRlpuvjmwA= +sigs.k8s.io/structured-merge-diff/v4 v4.4.2/go.mod h1:N8f93tFZh9U6vpxwRArLiikrE5/2tiu1w1AGfACIGE4= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/test-data/asset_generation/helm/discover.yaml b/test-data/asset_generation/helm/discover.yaml new file mode 100644 index 00000000..e79b2bc9 --- /dev/null +++ b/test-data/asset_generation/helm/discover.yaml @@ -0,0 +1,2 @@ +foo: + bar: hello world! diff --git a/test-data/asset_generation/helm/k8s_only/.helmignore b/test-data/asset_generation/helm/k8s_only/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/test-data/asset_generation/helm/k8s_only/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/test-data/asset_generation/helm/k8s_only/Chart.yaml b/test-data/asset_generation/helm/k8s_only/Chart.yaml new file mode 100644 index 00000000..5f57f5d7 --- /dev/null +++ b/test-data/asset_generation/helm/k8s_only/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: k8s_only +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/test-data/asset_generation/helm/k8s_only/templates/configmap.yaml b/test-data/asset_generation/helm/k8s_only/templates/configmap.yaml new file mode 100644 index 00000000..b685e0bc --- /dev/null +++ b/test-data/asset_generation/helm/k8s_only/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +data: + chartName: {{ .Values.foo.bar }} + {{- if .Values.extra }} + extraValue: {{ .Values.extra.value }} + {{- end}} +kind: ConfigMap +metadata: + name: sample diff --git a/test-data/asset_generation/helm/mixed_templates/.helmignore b/test-data/asset_generation/helm/mixed_templates/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/test-data/asset_generation/helm/mixed_templates/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/test-data/asset_generation/helm/mixed_templates/Chart.yaml b/test-data/asset_generation/helm/mixed_templates/Chart.yaml new file mode 100644 index 00000000..890c9a6a --- /dev/null +++ b/test-data/asset_generation/helm/mixed_templates/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: mixed_templates +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/test-data/asset_generation/helm/mixed_templates/files/konveyor/Dockerfile b/test-data/asset_generation/helm/mixed_templates/files/konveyor/Dockerfile new file mode 100644 index 00000000..5052f2a7 --- /dev/null +++ b/test-data/asset_generation/helm/mixed_templates/files/konveyor/Dockerfile @@ -0,0 +1,6 @@ +FROM python:3 + +RUN echo {{ .Values.foo.bar }} +{{- if .Values.extra }} +RUN echo {{ .Values.extra.value }} +{{ end }} \ No newline at end of file diff --git a/test-data/asset_generation/helm/mixed_templates/templates/configmap.yaml b/test-data/asset_generation/helm/mixed_templates/templates/configmap.yaml new file mode 100644 index 00000000..b685e0bc --- /dev/null +++ b/test-data/asset_generation/helm/mixed_templates/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +data: + chartName: {{ .Values.foo.bar }} + {{- if .Values.extra }} + extraValue: {{ .Values.extra.value }} + {{- end}} +kind: ConfigMap +metadata: + name: sample From a72c99a739659eacf5543a70f4d9b2f697427971 Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Thu, 20 Feb 2025 17:43:00 +0100 Subject: [PATCH 4/7] Update README with discover and generate Signed-off-by: Gloria Ciavarrini --- README.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f830b18d..fab1bb0e 100644 --- a/README.md +++ b/README.md @@ -123,7 +123,7 @@ podman machine init ## Usage -Kantra has three subcommands: +Kantra has five subcommands: 1. _analyze_: This subcommand allows running source code analysis on input source code or a binary. @@ -131,6 +131,10 @@ Kantra has three subcommands: 3. _test_: This subcommand allows testing YAML rules. +4. _discover_: This subcommand allows to discover application and outputs a YAML representation of source platform resources. + +5. _generate_: This subcommand allora to analyze the source plaftform and/or application and output a discovery manifest. + ### Analyze _analyze_ subcommand allows running source code and binary analysis using [analyzer-lsp](https://github.com/konveyor/analyzer-lsp) @@ -255,6 +259,57 @@ The output of tests is printed on the console. See different ways to run the test command in the [test runner doc](./docs/testrunner.md#running-tests) +### Asset Generation + +Asset generation consist of two subcommands _discover_ and _generate_. + +#### Discover +Discover application outputs a YAML representation of source platform resources. + +To run a discover, run: + +`kantra discover --input=` + +_--input_ must point to a yaml manifest file. + + +All flags: + +```sh +Flags: + -h, --help help for discover + --list-platforms List available supported discovery platform. +``` + +#### Generate + +Analyze the source platform and/or application and output discovery manifest. + + +To generate a discovery manifest, run: + +`kantra generate helm --input= --chart-dir=` + +All flags + +```sh +Flags: + -h, --help help for generate +``` +_generate_ subcommand has a _helm_ subcommand that generates the helm template manifest. + +All flags: + +```sh +Flags: + --chart-dir string Directory to the Helm chart to use for chart generation. + -h, --help help for helm + --input string Specifies the discover manifest file + --non-k8s-only Render only the non-Kubernetes templates located in the files/konveyor directory of the chart + --output-dir string Directory to save the generated Helm chart. Defaults to stdout + --set stringArray Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2) +``` + ## References - [Example usage scenarios](./docs/examples.md) From b3a60a57bd26452bf916bd7a422d79beadf68d74 Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Tue, 25 Feb 2025 10:06:27 +0100 Subject: [PATCH 5/7] Update assertion to use ToNot(HaveOccurred()) for error checks Signed-off-by: Gloria Ciavarrini --- .../discover/cloud_foundry/discover_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/asset_generation/discover/cloud_foundry/discover_test.go b/cmd/asset_generation/discover/cloud_foundry/discover_test.go index 98dd73e1..d9f854e4 100644 --- a/cmd/asset_generation/discover/cloud_foundry/discover_test.go +++ b/cmd/asset_generation/discover/cloud_foundry/discover_test.go @@ -44,10 +44,10 @@ var _ = Describe("Discover Manifest", func() { err = discoverManifest(writer) writer.Flush() if expectedErrorMessage != "" { - Expect(err).ToNot(BeNil(), "Expected an error due to invalid manifest content, got none") + Expect(err).To(HaveOccurred(), "Expected an error due to invalid manifest content, got none") Expect(err.Error()).To(ContainSubstring(expectedErrorMessage)) } else { - Expect(err).To(BeNil(), "Expected no error for invalid manifest, but got one") + Expect(err).ToNot(HaveOccurred(), "Expected no error for invalid manifest, but got one") } }, Entry("with an empty manifest", "", "field validation for 'Name' failed on the 'required' tag"), @@ -62,10 +62,10 @@ var _ = Describe("Discover Manifest", func() { err = discoverManifest(writer) if expectedErrorMessage != "" { - Expect(err).ToNot(BeNil(), "Expected an error due to invalid manifest content, got none") + Expect(err).ToNot(HaveOccurred(), "Expected an error due to invalid manifest content, got none") Expect(err.Error()).To(ContainSubstring(expectedErrorMessage)) } else { - Expect(err).To(BeNil(), "Expected no error for valid manifest, but got one") + Expect(err).ToNot(HaveOccurred(), "Expected no error for valid manifest, but got one") } }, Entry("with readonly permission", `name: test-app`, os.FileMode(0444), ""), From 9184a66296de37a761e8394509713b45d0d0aa99 Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Tue, 25 Feb 2025 10:08:27 +0100 Subject: [PATCH 6/7] Move writer initialization into BeforeEach Signed-off-by: Gloria Ciavarrini --- .../discover/cloud_foundry/discover_test.go | 8 ++++---- cmd/asset_generation/discover/discover_test.go | 5 ++--- cmd/asset_generation/generate/generate_test.go | 5 ++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/cmd/asset_generation/discover/cloud_foundry/discover_test.go b/cmd/asset_generation/discover/cloud_foundry/discover_test.go index d9f854e4..3e268009 100644 --- a/cmd/asset_generation/discover/cloud_foundry/discover_test.go +++ b/cmd/asset_generation/discover/cloud_foundry/discover_test.go @@ -78,7 +78,7 @@ var _ = Describe("Discover command", func() { log logr.Logger out bytes.Buffer err bytes.Buffer - writer *bufio.Writer = bufio.NewWriter(&out) + writer *bufio.Writer tempDir string cmd *cobra.Command @@ -89,9 +89,9 @@ var _ = Describe("Discover command", func() { BeforeEach(func() { log = logr.Discard() - - // Reset buffers before each test - writer.Reset(&out) + out.Reset() + err.Reset() + writer = bufio.NewWriter(&out) // Create a temporary directory for test files tempDir, err := os.MkdirTemp("", "cloud_foundry_test") diff --git a/cmd/asset_generation/discover/discover_test.go b/cmd/asset_generation/discover/discover_test.go index ed811e4b..2688ce68 100644 --- a/cmd/asset_generation/discover/discover_test.go +++ b/cmd/asset_generation/discover/discover_test.go @@ -19,12 +19,11 @@ var _ = Describe("Discover Command", func() { logger logr.Logger out bytes.Buffer err bytes.Buffer - writer *bufio.Writer = bufio.NewWriter(&out) + writer *bufio.Writer c *cobra.Command ) BeforeEach(func() { - // Reset buffers before each test - writer.Reset(&out) + writer = bufio.NewWriter(&out) // Set up logger logrusLog := logrus.StandardLogger() diff --git a/cmd/asset_generation/generate/generate_test.go b/cmd/asset_generation/generate/generate_test.go index 6fb09951..e0d6fc1e 100644 --- a/cmd/asset_generation/generate/generate_test.go +++ b/cmd/asset_generation/generate/generate_test.go @@ -21,13 +21,12 @@ var _ = Describe("Generate Command", func() { logger logr.Logger out bytes.Buffer err bytes.Buffer - writer *bufio.Writer = bufio.NewWriter(&out) + writer *bufio.Writer c *cobra.Command ) var _ = BeforeEach(func() { - // Reset buffers before each test - writer.Reset(&out) + writer = bufio.NewWriter(&out) // Set up logger logrusLog := logrus.New() From 477831352561d3572c9b0d714157d72be9664ad8 Mon Sep 17 00:00:00 2001 From: Gloria Ciavarrini Date: Tue, 25 Feb 2025 11:21:32 +0100 Subject: [PATCH 7/7] Add tests to verify the generated output Signed-off-by: Gloria Ciavarrini --- .../discover/cloud_foundry/discover.go | 2 +- .../discover/cloud_foundry/discover_test.go | 122 ++++++++++++------ 2 files changed, 81 insertions(+), 43 deletions(-) diff --git a/cmd/asset_generation/discover/cloud_foundry/discover.go b/cmd/asset_generation/discover/cloud_foundry/discover.go index 13cfebf8..cb2b64e8 100644 --- a/cmd/asset_generation/discover/cloud_foundry/discover.go +++ b/cmd/asset_generation/discover/cloud_foundry/discover.go @@ -66,7 +66,7 @@ func discoverManifest(writer io.Writer) error { } if output == "" { - fmt.Fprintf(writer, "%s\n", b) + fmt.Fprintf(writer, "%s", b) return nil } return os.WriteFile(output, b, 0444) diff --git a/cmd/asset_generation/discover/cloud_foundry/discover_test.go b/cmd/asset_generation/discover/cloud_foundry/discover_test.go index 3e268009..2cdb663b 100644 --- a/cmd/asset_generation/discover/cloud_foundry/discover_test.go +++ b/cmd/asset_generation/discover/cloud_foundry/discover_test.go @@ -118,13 +118,13 @@ instances: 1 filePath string } type flagTest struct { - Input flagFile - Output flagFile - ExpectSuccess bool - ExpectedOut string - ExpectErr bool - ExpectedErrMessage string - OutputFileVerification bool + Input flagFile + Output flagFile + ExpectSuccess bool + ExpectedOut string + ExpectErr bool + ExpectedErrMessage string + OutputVerification bool } DescribeTable("flag behavior", @@ -170,11 +170,19 @@ instances: 1 Expect(err.String()).To(ContainSubstring(flags.ExpectedErrMessage)) // Check STDERR for errors } - if flags.OutputFileVerification { - outputContent, err := os.ReadFile(outputPath) - Expect(err).NotTo(HaveOccurred()) - Expect(string(outputContent)).To(ContainSubstring(flags.ExpectedOut)) - Expect(out.String()).To(BeEmpty()) // Standard output should be empty + if flags.OutputVerification { + var outputContent string + if flags.Output.setFlag { + outputContentByte, err := os.ReadFile(outputPath) + Expect(err).NotTo(HaveOccurred()) + outputContent = string(outputContentByte) + Expect(out.String()).To(BeEmpty()) // Standard output should be empty + } else { + Expect(out.String()).ToNot(BeEmpty()) // Standard output should not be empty + outputContent = out.String() + } + + Expect(string(outputContent)).To(Equal(flags.ExpectedOut)) } else { Expect(out.String()).To(ContainSubstring(flags.ExpectedOut)) // Check STDOUT for normal output } @@ -182,52 +190,82 @@ instances: 1 Entry("discovers manifest and prints output to standard output when flags are valid", flagTest{ - Input: flagFile{setFlag: true}, - Output: flagFile{setFlag: false}, - ExpectSuccess: true, - ExpectedOut: "test-app", - ExpectErr: false, - ExpectedErrMessage: "", - OutputFileVerification: false}, + Input: flagFile{setFlag: true}, + Output: flagFile{setFlag: false}, + ExpectSuccess: true, + ExpectedOut: "test-app", + ExpectErr: false, + ExpectedErrMessage: "", + OutputVerification: false}, + ), + Entry("discovers manifest and prints output to standard output when flags are valid and verify output", + flagTest{ + Input: flagFile{setFlag: true}, + Output: flagFile{setFlag: false}, + ExpectSuccess: true, + ExpectedOut: `name: test-app +space: default +version: "1" +timeout: 60 +instances: 1 +`, + ExpectErr: false, + ExpectedErrMessage: "", + OutputVerification: true}, ), Entry("writes to output file when --output flag is given", flagTest{ - Input: flagFile{setFlag: true}, - Output: flagFile{setFlag: true}, - ExpectSuccess: true, - ExpectedOut: "", - ExpectErr: false, - ExpectedErrMessage: "", - OutputFileVerification: false}, + Input: flagFile{setFlag: true}, + Output: flagFile{setFlag: true}, + ExpectSuccess: true, + ExpectedOut: "", + ExpectErr: false, + ExpectedErrMessage: "", + OutputVerification: false}, + ), + Entry("writes to output file when --output flag is given and verify output", + flagTest{ + Input: flagFile{setFlag: true}, + Output: flagFile{setFlag: true}, + ExpectSuccess: true, + ExpectedOut: `name: test-app +space: default +version: "1" +timeout: 60 +instances: 1 +`, + ExpectErr: false, + ExpectedErrMessage: "", + OutputVerification: true}, ), Entry("returns an error when input file is missing", flagTest{ - Input: flagFile{setFlag: false}, - Output: flagFile{setFlag: false}, - ExpectSuccess: false, - ExpectedOut: "", - ExpectErr: true, - ExpectedErrMessage: "required flag", - OutputFileVerification: false}, + Input: flagFile{setFlag: false}, + Output: flagFile{setFlag: false}, + ExpectSuccess: false, + ExpectedOut: "", + ExpectErr: true, + ExpectedErrMessage: "required flag", + OutputVerification: false}, ), Entry("returns an error when input file does not exist", flagTest{ - Input: flagFile{setFlag: true, filePath: "nonexistent.yaml"}, - Output: flagFile{setFlag: false}, - ExpectSuccess: false, - ExpectedOut: "", - ExpectErr: true, - ExpectedErrMessage: "no such file or directory", - OutputFileVerification: false}, + Input: flagFile{setFlag: true, filePath: "nonexistent.yaml"}, + Output: flagFile{setFlag: false}, + ExpectSuccess: false, + ExpectedOut: "", + ExpectErr: true, + ExpectedErrMessage: "no such file or directory", + OutputVerification: false}, ), ) }) -func helperCreateTestManifest(manifestPAth string, content string, perm os.FileMode) error { - err := os.WriteFile(manifestPAth, []byte(content), perm) //0644 +func helperCreateTestManifest(manifestPath string, content string, perm os.FileMode) error { + err := os.WriteFile(manifestPath, []byte(content), perm) //0644 if err != nil { return err }