diff --git a/examples/third_party_integration/flux/flux_test.go b/examples/third_party_integration/flux/flux_test.go index 09713043..725e1ebb 100644 --- a/examples/third_party_integration/flux/flux_test.go +++ b/examples/third_party_integration/flux/flux_test.go @@ -18,6 +18,9 @@ package flux import ( "context" + "testing" + "time" + appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -25,8 +28,6 @@ import ( "sigs.k8s.io/e2e-framework/klient/wait/conditions" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/features" - "testing" - "time" ) func TestFluxRepoWorkflow(t *testing.T) { diff --git a/examples/third_party_integration/flux/main_test.go b/examples/third_party_integration/flux/main_test.go index e0d80cf8..e34dad51 100644 --- a/examples/third_party_integration/flux/main_test.go +++ b/examples/third_party_integration/flux/main_test.go @@ -18,12 +18,12 @@ package flux import ( "os" - "sigs.k8s.io/e2e-framework/third_party/flux" "testing" "sigs.k8s.io/e2e-framework/pkg/env" "sigs.k8s.io/e2e-framework/pkg/envconf" "sigs.k8s.io/e2e-framework/pkg/envfuncs" + "sigs.k8s.io/e2e-framework/third_party/flux" ) var ( diff --git a/third_party/flux/cmd_manager.go b/third_party/flux/cmd_manager.go index efb8d768..1127f5c3 100644 --- a/third_party/flux/cmd_manager.go +++ b/third_party/flux/cmd_manager.go @@ -18,9 +18,10 @@ package flux import ( "fmt" + "strings" + "github.com/vladimirvivien/gexe" log "k8s.io/klog/v2" - "strings" ) type Opts struct { @@ -115,10 +116,8 @@ func (m *Manager) run(opts *Opts) (err error) { err = fmt.Errorf("'flux' command is missing. Please ensure the tool exists before using the flux manager") return } - command, err := m.getCommand(opts) - if err != nil { - return - } + command := m.getCommand(opts) + log.V(4).InfoS("Running Flux Operation", "command", command) proc := m.e.RunProc(command) result := proc.Result() @@ -134,7 +133,7 @@ func New(kubeConfig string) *Manager { return &Manager{e: gexe.New(), kubeConfig: kubeConfig} } -func (m *Manager) getCommand(opt *Opts) (string, error) { +func (m *Manager) getCommand(opt *Opts) string { commandParts := []string{"flux", opt.mode} if opt.name != "" { @@ -167,7 +166,7 @@ func (m *Manager) getCommand(opt *Opts) (string, error) { commandParts = append(commandParts, opt.args...) commandParts = append(commandParts, "--kubeconfig", m.kubeConfig) - return strings.Join(commandParts, " "), nil + return strings.Join(commandParts, " ") } func (m *Manager) installFlux(opts ...Option) error { @@ -181,7 +180,8 @@ func (m *Manager) uninstallFlux(opts ...Option) error { o.mode = "uninstall -s" return m.run(o) } -func (m *Manager) createSource(sourceType Source, name string, url string, opts ...Option) error { + +func (m *Manager) createSource(sourceType Source, name, url string, opts ...Option) error { o := m.processOpts(opts...) o.mode = string("create source " + sourceType) o.name = name @@ -196,7 +196,7 @@ func (m *Manager) deleteSource(sourceType Source, name string, opts ...Option) e return m.run(o) } -func (m *Manager) createKustomization(name string, source string, opts ...Option) error { +func (m *Manager) createKustomization(name, source string, opts ...Option) error { o := m.processOpts(opts...) o.mode = "create ks" o.name = name diff --git a/third_party/flux/flux_setup.go b/third_party/flux/flux_setup.go index 11561161..20c48963 100644 --- a/third_party/flux/flux_setup.go +++ b/third_party/flux/flux_setup.go @@ -19,6 +19,7 @@ package flux import ( "context" "fmt" + "sigs.k8s.io/e2e-framework/pkg/env" "sigs.k8s.io/e2e-framework/pkg/envconf" ) @@ -40,12 +41,12 @@ func InstallFlux(opts ...Option) env.Func { } // CreateGitRepo creates a reference to a specific repository, it is a source for Kustomization or HelmRelease -func CreateGitRepo(gitRepoName string, gitRepoUrl string, opts ...Option) env.Func { +func CreateGitRepo(gitRepoName, gitRepoURL string, opts ...Option) env.Func { return func(ctx context.Context, c *envconf.Config) (context.Context, error) { if manager == nil { return ctx, fmt.Errorf(NoFluxInstallationFoundMsg) } - err := manager.createSource(Git, gitRepoName, gitRepoUrl, opts...) + err := manager.createSource(Git, gitRepoName, gitRepoURL, opts...) if err != nil { return ctx, fmt.Errorf("git reporistory creation failed: %w", err) } @@ -54,7 +55,7 @@ func CreateGitRepo(gitRepoName string, gitRepoUrl string, opts ...Option) env.Fu } // CreateKustomization is used to point to a specific source and path for reconciliation -func CreateKustomization(kustomizationName string, sourceRef string, opts ...Option) env.Func { +func CreateKustomization(kustomizationName, sourceRef string, opts ...Option) env.Func { return func(ctx context.Context, c *envconf.Config) (context.Context, error) { if manager == nil { return ctx, fmt.Errorf(NoFluxInstallationFoundMsg)