diff --git a/Makefile b/Makefile index dccecd09f..6b460e082 100644 --- a/Makefile +++ b/Makefile @@ -89,7 +89,7 @@ gen-grpc-resources: # Generate plugins YAML index files for both all plugins and end-user ones. gen-plugins-index: build-plugins go run ./hack/gen-plugin-index.go -output-path ./plugins-dev-index.yaml - go run ./hack/gen-plugin-index.go -output-path ./plugins-index.yaml -plugin-name-filter 'kubectl|helm|kubernetes|prometheus|exec|doctor|keptn|github-events' + go run ./hack/gen-plugin-index.go -output-path ./plugins-index.yaml -plugin-name-filter 'kubectl|helm|kubernetes|prometheus|exec|doctor|keptn' gen-docs-cli: rm -f ./cmd/cli/docs/* diff --git a/internal/executor/flux/commands/template.go b/internal/executor/flux/commands/template.go index f07edca57..d11566e13 100644 --- a/internal/executor/flux/commands/template.go +++ b/internal/executor/flux/commands/template.go @@ -16,7 +16,7 @@ var f embed.FS func LoadTemplates() ([]template.Template, error) { dirs, err := f.ReadDir("store") if err != nil { - return nil, err + return nil, fmt.Errorf("while reading store directory: %w", err) } var templates []template.Template @@ -27,7 +27,7 @@ func LoadTemplates() ([]template.Template, error) { } file, err := f.ReadFile(filepath.Join("store", d.Name())) if err != nil { - return nil, err + return nil, fmt.Errorf("while reading %q file: %w", d.Name(), err) } var cfg struct { @@ -35,7 +35,7 @@ func LoadTemplates() ([]template.Template, error) { } err = yaml.Unmarshal(file, &cfg) if err != nil { - return nil, fmt.Errorf("while unmarshaling file %q: %v", d.Name(), err) + return nil, fmt.Errorf("while unmarshaling %q file: %v", d.Name(), err) } templates = append(templates, cfg.Templates...) diff --git a/internal/executor/flux/diff_cmd.go b/internal/executor/flux/diff_cmd.go index 582a7999b..5abe3555c 100644 --- a/internal/executor/flux/diff_cmd.go +++ b/internal/executor/flux/diff_cmd.go @@ -177,7 +177,7 @@ func (k *KustomizeDiffCmdService) runKustomizeDiff(ctx context.Context, diffCmd pluginx.ExecuteCommandWorkingDir(workdir), ) if err != nil { - k.log.WithError(err).WithField("command", kustomizeDiff.ToCmdString()).Error("failed to run command") + k.log.WithError(err).WithField("command", kustomizeDiff.ToCmdString()).Error("Failed to run command.") return executor.ExecuteOutput{}, fmt.Errorf("while running command: %v", err) } @@ -302,11 +302,11 @@ func (*KustomizeDiffCmdService) runDiffCmd(ctx context.Context, in string, opts func resolveGitHubRepoURL(ctx context.Context, logger logrus.FieldLogger, kubeConfigBytes []byte, ns string, name string) (string, error) { scheme := runtime.NewScheme() if err := kustomizev1.AddToScheme(scheme); err != nil { - return "", fmt.Errorf("failed to add Kustomize scheme: %w", err) + return "", fmt.Errorf("while adding Kustomize scheme: %w", err) } if err := sourcev1.AddToScheme(scheme); err != nil { - return "", fmt.Errorf("failed to add Source scheme: %w", err) + return "", fmt.Errorf("while adding Source scheme: %w", err) } kubeConfig, err := clientcmd.RESTConfigFromKubeConfig(kubeConfigBytes) @@ -320,7 +320,7 @@ func resolveGitHubRepoURL(ctx context.Context, logger logrus.FieldLogger, kubeCo Scheme: scheme, }) if err != nil { - return "", fmt.Errorf("failed to create client: %w", err) + return "", fmt.Errorf("while creating client: %w", err) } // Resolve Kustomize @@ -331,7 +331,7 @@ func resolveGitHubRepoURL(ctx context.Context, logger logrus.FieldLogger, kubeCo }, &ks) if err != nil { - return "", fmt.Errorf("failed to get Kustomization: %w", err) + return "", fmt.Errorf("while getting Kustomization: %w", err) } if ks.Spec.SourceRef.Kind != "GitRepository" { @@ -351,7 +351,7 @@ func resolveGitHubRepoURL(ctx context.Context, logger logrus.FieldLogger, kubeCo }, &git) if err != nil { - return "", fmt.Errorf("failed to get GitRepository: %w", err) + return "", fmt.Errorf("while getting GitRepository: %w", err) } return git.Spec.URL, nil @@ -392,7 +392,7 @@ func (k *KustomizeDiffCmdService) cloneResources(ctx context.Context, diff *Kust // because we clone with --depth 1 we have issues as described here: https://github.com/cli/cli/issues/4287 _, err = pluginx.ExecuteCommand(ctx, `git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"`, gitSetupOpts...) if err != nil { - return "", err + return "", fmt.Errorf("while setting up git repo: %w", err) } checkoutCmd := fmt.Sprintf("gh pr checkout %s", diff.GitHubRef) diff --git a/internal/executor/flux/executor.go b/internal/executor/flux/executor.go index d22a496e5..16ed99ed0 100644 --- a/internal/executor/flux/executor.go +++ b/internal/executor/flux/executor.go @@ -128,7 +128,7 @@ func (d *Executor) Execute(ctx context.Context, in executor.ExecuteInput) (execu templates, err := commands.LoadTemplates() if err != nil { - return executor.ExecuteOutput{}, err + return executor.ExecuteOutput{}, fmt.Errorf("while loading templates: %w", err) } return x.NewRunner(log, renderer).RunWithTemplates(templates, state.ExtractSlackState(in.Context.SlackState), command, func() (string, error) { diff --git a/pkg/pluginx/command.go b/pkg/pluginx/command.go index 6e1400f97..d77bd438c 100644 --- a/pkg/pluginx/command.go +++ b/pkg/pluginx/command.go @@ -66,7 +66,6 @@ func (out ExecuteCommandOutput) CombinedOutput() string { // ExecuteCommandWithEnvs is a simple wrapper around exec.CommandContext to simplify running a given // command. -// // Deprecated: Use ExecuteCommand(ctx, rawCmd, ExecuteCommandEnvs(envs)) instead. func ExecuteCommandWithEnvs(ctx context.Context, rawCmd string, envs map[string]string) (string, error) { out, err := ExecuteCommand(ctx, rawCmd, ExecuteCommandEnvs(envs)) diff --git a/pkg/pluginx/command_opts.go b/pkg/pluginx/command_opts.go index 03868d305..079898c39 100644 --- a/pkg/pluginx/command_opts.go +++ b/pkg/pluginx/command_opts.go @@ -27,14 +27,14 @@ func ExecuteCommandDependencyDir(dir string) ExecuteCommandMutation { } } -// ExecuteCommandWorkingDir is a functions that sets the working directory of the command. +// ExecuteCommandWorkingDir is a function that sets the working directory of the command. func ExecuteCommandWorkingDir(dir string) ExecuteCommandMutation { return func(options *ExecuteCommandOptions) { options.WorkDir = dir } } -// ExecuteCommandStdin is a functions that sets the stdin of the command. +// ExecuteCommandStdin is a function that sets the stdin of the command. func ExecuteCommandStdin(in io.Reader) ExecuteCommandMutation { return func(options *ExecuteCommandOptions) { options.Stdin = in