diff --git a/cmd/modulectl/create/cmd_test.go b/cmd/modulectl/create/cmd_test.go index 6c3e50fa..b00385c4 100644 --- a/cmd/modulectl/create/cmd_test.go +++ b/cmd/modulectl/create/cmd_test.go @@ -48,7 +48,6 @@ func Test_Execute_ReturnsError_WhenModuleServiceReturnsError(t *testing.T) { func Test_Execute_ParsesAllModuleOptions(t *testing.T) { moduleConfigFile := testutils.RandomName(10) credentials := testutils.RandomName(10) - gitRemote := testutils.RandomName(10) insecure := "true" templateOutput := testutils.RandomName(10) registryURL := testutils.RandomName(10) @@ -57,7 +56,6 @@ func Test_Execute_ParsesAllModuleOptions(t *testing.T) { os.Args = []string{ "create", "--config-file", moduleConfigFile, - "--git-remote", gitRemote, "--insecure", insecure, "--output", templateOutput, "--registry", registryURL, @@ -76,7 +74,6 @@ func Test_Execute_ParsesAllModuleOptions(t *testing.T) { assert.Equal(t, moduleConfigFile, svc.opts.ConfigFile) assert.Equal(t, credentials, svc.opts.Credentials) - assert.Equal(t, gitRemote, svc.opts.GitRemote) assert.Equal(t, insecureFlagSet, svc.opts.Insecure) assert.Equal(t, templateOutput, svc.opts.TemplateOutput) assert.Equal(t, registryURL, svc.opts.RegistryURL) @@ -119,7 +116,6 @@ func Test_Execute_ModuleParsesDefaults(t *testing.T) { assert.Equal(t, createcmd.ConfigFileFlagDefault, svc.opts.ConfigFile) assert.Equal(t, createcmd.CredentialsFlagDefault, svc.opts.Credentials) - assert.Equal(t, createcmd.GitRemoteFlagDefault, svc.opts.GitRemote) assert.Equal(t, createcmd.InsecureFlagDefault, svc.opts.Insecure) assert.Equal(t, createcmd.TemplateOutputFlagDefault, svc.opts.TemplateOutput) assert.Equal(t, createcmd.RegistryURLFlagDefault, svc.opts.RegistryURL) diff --git a/cmd/modulectl/create/flags.go b/cmd/modulectl/create/flags.go index 64162d85..a89a08c4 100644 --- a/cmd/modulectl/create/flags.go +++ b/cmd/modulectl/create/flags.go @@ -16,10 +16,6 @@ const ( CredentialsFlagDefault = "" credentialsFlagUsage = "Basic authentication credentials for the given repository in the format." - GitRemoteFlagName = "git-remote" - GitRemoteFlagDefault = "" - gitRemoteFlagUsage = "Specifies the URL of the module's GitHub repository. " - InsecureFlagName = "insecure" InsecureFlagDefault = false insecureFlagUsage = "Uses an insecure connection to access the registry." @@ -46,7 +42,6 @@ func parseFlags(flags *pflag.FlagSet, opts *create.Options) { configFileFlagUsage) flags.StringVar(&opts.Credentials, CredentialsFlagName, CredentialsFlagDefault, credentialsFlagUsage) - flags.StringVar(&opts.GitRemote, GitRemoteFlagName, GitRemoteFlagDefault, gitRemoteFlagUsage) flags.BoolVar(&opts.Insecure, InsecureFlagName, InsecureFlagDefault, insecureFlagUsage) flags.StringVarP(&opts.TemplateOutput, TemplateOutputFlagName, templateOutputFlagShort, TemplateOutputFlagDefault, templateOutputFlagUsage) diff --git a/cmd/modulectl/create/flags_test.go b/cmd/modulectl/create/flags_test.go index b0c50d65..ade4f1c0 100644 --- a/cmd/modulectl/create/flags_test.go +++ b/cmd/modulectl/create/flags_test.go @@ -19,7 +19,6 @@ func Test_ScaffoldFlagsDefaults(t *testing.T) { expected: "module-config.yaml", }, {name: createcmd.CredentialsFlagName, value: createcmd.CredentialsFlagDefault, expected: ""}, - {name: createcmd.GitRemoteFlagName, value: createcmd.GitRemoteFlagDefault, expected: ""}, {name: createcmd.InsecureFlagName, value: strconv.FormatBool(createcmd.InsecureFlagDefault), expected: "false"}, {name: createcmd.TemplateOutputFlagName, value: createcmd.TemplateOutputFlagDefault, expected: "template.yaml"}, {name: createcmd.RegistryURLFlagName, value: createcmd.RegistryURLFlagDefault, expected: ""}, diff --git a/docs/gen-docs/modulectl_create.md b/docs/gen-docs/modulectl_create.md index e7d5029a..dd86c5af 100644 --- a/docs/gen-docs/modulectl_create.md +++ b/docs/gen-docs/modulectl_create.md @@ -74,7 +74,6 @@ Build a simple module and push it to a remote registry ```bash -c, --config-file string Specifies the path to the module configuration file. - --git-remote string Specifies the URL of the module's GitHub repository. -h, --help Provides help for the create command. --insecure Uses an insecure connection to access the registry. -o, --output string Path to write the ModuleTemplate file to, if the module is uploaded to a registry (default "template.yaml"). diff --git a/internal/service/create/create.go b/internal/service/create/create.go index 7a50ce38..cbe57fd3 100644 --- a/internal/service/create/create.go +++ b/internal/service/create/create.go @@ -183,16 +183,14 @@ func (s *Service) Run(opts Options) error { return fmt.Errorf("failed to generate module resources: %w", err) } - if opts.GitRemote != "" { - if err = s.gitSourcesService.AddGitSources(descriptor, opts.GitRemote, - moduleConfig.Version); err != nil { - return fmt.Errorf("failed to add git sources: %w", err) - } - if moduleConfig.Security != "" { - err = s.configureSecScannerConf(descriptor, moduleConfig, opts) - if err != nil { - return fmt.Errorf("failed to configure security scanners: %w", err) - } + if err = s.gitSourcesService.AddGitSources(descriptor, moduleConfig.Repository, + moduleConfig.Version); err != nil { + return fmt.Errorf("failed to add git sources: %w", err) + } + if moduleConfig.Security != "" { + err = s.configureSecScannerConf(descriptor, moduleConfig, opts) + if err != nil { + return fmt.Errorf("failed to configure security scanners: %w", err) } } @@ -248,7 +246,7 @@ func (s *Service) pushImgAndCreateTemplate(archive *comparch.ComponentArchive, m func (s *Service) configureSecScannerConf(descriptor *compdesc.ComponentDescriptor, moduleConfig *contentprovider.ModuleConfig, opts Options) error { opts.Out.Write("- Configuring security scanners config\n") - securityConfig, err := s.securityConfigService.ParseSecurityConfigData(opts.GitRemote, moduleConfig.Security) + securityConfig, err := s.securityConfigService.ParseSecurityConfigData(moduleConfig.Repository, moduleConfig.Security) if err != nil { return fmt.Errorf("%w: failed to parse security config data", err) } diff --git a/internal/service/create/create_test.go b/internal/service/create/create_test.go index 8d01f849..5d1d5674 100644 --- a/internal/service/create/create_test.go +++ b/internal/service/create/create_test.go @@ -138,7 +138,6 @@ func newCreateOptionsBuilder() *createOptionsBuilder { withOut(iotools.NewDefaultOut(io.Discard)). withModuleConfigFile("create-module-config.yaml"). withRegistryURL("https://registry.kyma.cx"). - withGitRemote("http://github.com/kyma-project"). withTemplateOutput("test"). withCredentials("user:password") } @@ -162,11 +161,6 @@ func (b *createOptionsBuilder) withRegistryURL(registryURL string) *createOption return b } -func (b *createOptionsBuilder) withGitRemote(gitRemote string) *createOptionsBuilder { - b.options.GitRemote = gitRemote - return b -} - func (b *createOptionsBuilder) withTemplateOutput(templateOutput string) *createOptionsBuilder { b.options.TemplateOutput = templateOutput return b diff --git a/internal/service/create/options.go b/internal/service/create/options.go index 71e952b8..f54815c7 100644 --- a/internal/service/create/options.go +++ b/internal/service/create/options.go @@ -13,7 +13,6 @@ type Options struct { Out iotools.Out ConfigFile string Credentials string - GitRemote string Insecure bool TemplateOutput string RegistryURL string diff --git a/internal/service/create/options_test.go b/internal/service/create/options_test.go index af6987b1..7637442f 100644 --- a/internal/service/create/options_test.go +++ b/internal/service/create/options_test.go @@ -50,7 +50,6 @@ func Test_Validate_Options(t *testing.T) { Out: iotools.NewDefaultOut(io.Discard), ConfigFile: "config.yaml", Credentials: "username:password", - GitRemote: "github.com/kyma-project/modulectl", TemplateOutput: "", }, wantErr: true, @@ -62,7 +61,6 @@ func Test_Validate_Options(t *testing.T) { Out: iotools.NewDefaultOut(io.Discard), ConfigFile: "config.yaml", Credentials: "username:password", - GitRemote: "github.com/kyma-project/modulectl", TemplateOutput: "output", RegistryURL: "http://registry.example.com", }, @@ -74,7 +72,6 @@ func Test_Validate_Options(t *testing.T) { Out: iotools.NewDefaultOut(io.Discard), ConfigFile: "config.yaml", Credentials: "username:password", - GitRemote: "origin", TemplateOutput: "output", RegistryURL: "ftp://registry.example.com", }, diff --git a/tests/e2e/create/create_suite_test.go b/tests/e2e/create/create_suite_test.go index b716f796..96072eac 100644 --- a/tests/e2e/create/create_suite_test.go +++ b/tests/e2e/create/create_suite_test.go @@ -53,7 +53,6 @@ const ( ociRegistry = "http://k3d-oci.localhost:5001" templateOutputPath = "/tmp/template.yaml" - gitRemote = "https://github.com/kyma-project/template-operator" ) // Command wrapper for `modulectl create` @@ -62,7 +61,6 @@ type createCmd struct { registry string output string moduleConfigFile string - gitRemote string insecure bool } @@ -83,10 +81,6 @@ func (cmd *createCmd) execute() error { args = append(args, "--output="+cmd.output) } - if cmd.gitRemote != "" { - args = append(args, "--git-remote="+cmd.gitRemote) - } - if cmd.insecure { args = append(args, "--insecure") } diff --git a/tests/e2e/create/create_test.go b/tests/e2e/create/create_test.go index 2fbfd3c4..af0b58db 100644 --- a/tests/e2e/create/create_test.go +++ b/tests/e2e/create/create_test.go @@ -339,8 +339,15 @@ var _ = Describe("Test 'create' command", Ordered, func() { Expect(localBlobAccessSpec.LocalReference).To(ContainSubstring("sha256:")) Expect(localBlobAccessSpec.MediaType).To(Equal("application/x-tar")) - By("And descriptor.component.sources should be empty") - Expect(len(descriptor.Sources)).To(Equal(0)) + By("And descriptor.component.sources should contain repository entry") + Expect(len(descriptor.Sources)).To(Equal(1)) + source := descriptor.Sources[0] + sourceAccessSpec, err := ocm.DefaultContext().AccessSpecForSpec(source.Access) + Expect(err).ToNot(HaveOccurred()) + githubAccessSpec, ok := sourceAccessSpec.(*github.AccessSpec) + Expect(ok).To(BeTrue()) + Expect(github.Type).To(Equal(githubAccessSpec.Type)) + Expect(githubAccessSpec.RepoURL).To(Equal("https://github.com/kyma-project/template-operator")) By("And spec.mandatory should be false") Expect(template.Spec.Mandatory).To(BeFalse()) @@ -456,14 +463,13 @@ var _ = Describe("Test 'create' command", Ordered, func() { Context("Given 'modulectl create' command", func() { var cmd createCmd - It("When invoked with valid module-config containing security-scanner-config and different version, and the git-remote flag", + It("When invoked with valid module-config containing security-scanner-config and different version", func() { cmd = createCmd{ moduleConfigFile: withSecurityConfig, registry: ociRegistry, insecure: true, output: templateOutputPath, - gitRemote: gitRemote, } }) It("Then the command should succeed", func() {