Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add lint-registry command #1028

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions pkg/cli/lint_registry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package cli

import (
"fmt"

"github.com/aquaproj/aqua/pkg/config"
"github.com/aquaproj/aqua/pkg/controller"
"github.com/urfave/cli/v2"
)

func (runner *Runner) newLintRegistryCommand() *cli.Command {
return &cli.Command{
Name: "lint-registry",
Aliases: []string{
"lr",
},
Usage: "Lint a registry file",
ArgsUsage: `<registry file path>`,
Description: `Lint a registry file
e.g.
$ aqua lr registry.yaml`,
Action: runner.lintRegistryAction,
}
}

func (runner *Runner) lintRegistryAction(c *cli.Context) error {
tracer, err := startTrace(c.String("trace"))
if err != nil {
return err
}
defer tracer.Stop()

cpuProfiler, err := startCPUProfile(c.String("cpu-profile"))
if err != nil {
return err
}
defer cpuProfiler.Stop()

param := &config.Param{}
if err := runner.setParam(c, "lint-registry", param); err != nil {
return fmt.Errorf("parse the command line arguments: %w", err)
}
ctrl := controller.InitializeInitCommandController(c.Context, param)
return ctrl.Init(c.Context, c.Args().First(), runner.LogE) //nolint:wrapcheck
}
1 change: 1 addition & 0 deletions pkg/cli/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (runner *Runner) Run(ctx context.Context, args ...string) error {
runner.newWhichCommand(),
runner.newExecCommand(),
runner.newListCommand(),
runner.newLintRegistryCommand(),
runner.newGenerateRegistryCommand(),
runner.newCompletionCommand(),
runner.newVersionCommand(),
Expand Down
Loading