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 basic config command #253

Draft
wants to merge 6 commits 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
3 changes: 3 additions & 0 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.21.0"
cache: false
- name: Go vet
run: |
make vet
Expand All @@ -29,6 +30,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: "1.21.0"
cache: false
- name: Go vet
run: |
make vet
Expand Down Expand Up @@ -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
Expand Down
55 changes: 55 additions & 0 deletions cmd/embedded-cluster/config.go
Original file line number Diff line number Diff line change
@@ -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 {
danj-replicated marked this conversation as resolved.
Show resolved Hide resolved
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
},
}
1 change: 1 addition & 0 deletions cmd/embedded-cluster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {
shellCommand,
nodeCommands,
versionCommand,
configCommand,
},
}
if err := app.Run(os.Args); err != nil {
Expand Down
Loading