diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index fcd013e09..a5e5ab531 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -12,6 +12,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21.0" + cache: false - name: Go vet run: | make vet @@ -29,6 +30,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21.0" + cache: false - name: Go vet run: | make vet @@ -56,6 +58,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21.0" + cache: false - name: Build Linux AMD64 run: | make embedded-cluster-linux-amd64 VERSION=dev-$SHORT_SHA diff --git a/cmd/embedded-cluster/config.go b/cmd/embedded-cluster/config.go new file mode 100644 index 000000000..33eb2d3ac --- /dev/null +++ b/cmd/embedded-cluster/config.go @@ -0,0 +1,55 @@ +package main + +import ( + "fmt" + "os" + + "github.com/urfave/cli/v2" + "gopkg.in/yaml.v2" + + "github.com/replicatedhq/embedded-cluster/pkg/addons" + "github.com/replicatedhq/embedded-cluster/pkg/config" +) + +var configCommand = &cli.Command{ + Name: "config", + Usage: "Dumps generated config to stdout", + Flags: []cli.Flag{ + &cli.StringFlag{ + Name: "overrides", + Usage: "File with an EmbeddedClusterConfig object to override the default configuration", + Hidden: true, + }, + &cli.BoolFlag{ + Name: "no-prompt", + Usage: "Do not prompt user when it is not necessary", + Value: false, + }, + }, + Action: func(c *cli.Context) error { + multi := false + + cfg, err := config.RenderClusterConfig(c.Context, multi) + if err != nil { + return fmt.Errorf("unable to render config: %w", err) + } + opts := []addons.Option{} + if c.Bool("no-prompt") { + opts = append(opts, addons.WithoutPrompt()) + } + for _, addon := range c.StringSlice("disable-addon") { + opts = append(opts, addons.WithoutAddon(addon)) + } + if err := config.UpdateHelmConfigs(cfg, opts...); err != nil { + return fmt.Errorf("unable to update helm configs: %w", err) + } + if err := applyUnsupportedOverrides(c, cfg); err != nil { + return fmt.Errorf("unable to apply unsupported overrides: %w", err) + } + if err := yaml.NewEncoder(os.Stdout).Encode(cfg); err != nil { + return fmt.Errorf("unable to write config file: %w", err) + } + + return nil + }, +} diff --git a/cmd/embedded-cluster/main.go b/cmd/embedded-cluster/main.go index 2d42293ac..723c2d763 100644 --- a/cmd/embedded-cluster/main.go +++ b/cmd/embedded-cluster/main.go @@ -37,6 +37,7 @@ func main() { shellCommand, nodeCommands, versionCommand, + configCommand, }, } if err := app.Run(os.Args); err != nil {