Skip to content

Commit

Permalink
Add enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok committed Jul 10, 2023
1 parent 1c0c4c2 commit db6a62f
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 151 deletions.
20 changes: 13 additions & 7 deletions cmd/cli/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import (

"github.com/pkg/errors"
"github.com/spf13/cobra"
"sigs.k8s.io/controller-runtime/pkg/client/config"

"github.com/kubeshop/botkube/internal/cli"
"github.com/kubeshop/botkube/internal/cli/heredoc"
"github.com/kubeshop/botkube/internal/cli/install"
"github.com/kubeshop/botkube/internal/kubex"
)

// NewInstall returns a cobra.Command for installing Botkube.
Expand All @@ -32,30 +32,36 @@ func NewInstall() *cobra.Command {
# Install Botkube from local git repository. Needs to be run from the main directory.
<cli> install --repo @local`, cli.Name),
RunE: func(cmd *cobra.Command, args []string) error {
k8sCfg, err := config.GetConfig() // fixme kubex
config, err := kubex.LoadRestConfigWithMetaInformation()
if err != nil {
return err
}
if err != nil {
return errors.Wrap(err, "while creating k8s config")
}

return install.Install(cmd.Context(), os.Stdout, k8sCfg, opts)
return install.Install(cmd.Context(), os.Stdout, config, opts)
},
}

flags := installCmd.Flags()

kubex.RegisterKubeconfigFlag(flags)

// common params for install and upgrade operation
flags.StringVar(&opts.HelmParams.Version, "version", install.LatestVersionTag, "Botkube version. Possible values @latest, 0.3.0, ...")
flags.StringVar(&opts.HelmParams.Version, "version", install.LatestVersionTag, "Botkube version. Possible values @latest, 1.2.0, ...")
flags.StringVar(&opts.HelmParams.Namespace, "namespace", install.Namespace, "Botkube installation namespace.")
flags.StringVar(&opts.HelmParams.ReleaseName, "release-name", install.ReleaseName, "Botkube Helm chart release name.")
flags.StringVar(&opts.HelmParams.ChartName, "chart-name", "botkube", "Botkube Helm chart name.")
flags.StringVar(&opts.HelmParams.RepoLocation, "repo", install.HelmRepoStable, fmt.Sprintf("Botkube Helm chart repository location. It can be relative path to current working directory or URL. Use %s tag to select repository which holds the stable Helm chart versions.", install.StableVersionTag))
flags.BoolVar(&opts.HelmParams.DryRun, "dry-run", false, "Simulate an install")
flags.BoolVar(&opts.HelmParams.Force, "force", false, "Force resource updates through a replacement strategy")
flags.BoolVar(&opts.HelmParams.DisableHooks, "no-hooks", false, "Disable pre/post install/upgrade hooks")
flags.BoolVar(&opts.HelmParams.DisableOpenAPIValidation, "disable-openapi-validation", false, "If set, it will not validate rendered templates against the Kubernetes OpenAPI Schema")
flags.BoolVar(&opts.HelmParams.SkipCRDs, "skip-crds", false, "If set, no CRDs will be installed.")
flags.DurationVar(&opts.HelmParams.Timeout, "timeout", 300*time.Second, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
flags.BoolVar(&opts.HelmParams.Wait, "wait", false, "If set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout")
flags.BoolVar(&opts.HelmParams.WaitForJobs, "wait-for-jobs", false, "If set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout")
flags.DurationVar(&opts.HelmParams.Timeout, "timeout", 5*time.Minute, "time to wait for any individual Kubernetes operation (like Jobs for hooks)")
flags.BoolVar(&opts.HelmParams.Wait, "wait", true, "If set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout")
flags.BoolVar(&opts.HelmParams.WaitForJobs, "wait-for-jobs", true, "If set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout")
flags.BoolVar(&opts.HelmParams.Atomic, "atomic", false, "If set, process rolls back changes made in case of failed install/upgrade. The --wait flag will be set automatically if --atomic is used")
flags.BoolVar(&opts.HelmParams.SubNotes, "render-subchart-notes", false, "If set, render subchart notes along with the parent")
flags.StringVar(&opts.HelmParams.Description, "description", "", "add a custom description")
Expand Down
17 changes: 10 additions & 7 deletions cmd/cli/docs/botkube.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@ title: botkube

## botkube

Botkube Cloud CLI
Botkube CLI

### Synopsis

botkube - Botkube Cloud CLI
botkube - Botkube CLI

A utility that manages Botkube Cloud resources.
A utility that simplifies working with Botkube.

To begin working with Botkube Cloud using the botkube CLI, start with:
Quick Start:

$ botkube login
$ botkube install # Install Botkube

Quick Start:
Botkube Cloud:

$ botkube login # Login into Botkube Cloud
$ botkube migrate # Automatically migrates Open Source installation into Botkube Cloud


Expand All @@ -28,11 +29,13 @@ botkube [flags]
### Options

```
-h, --help help for botkube
-h, --help help for botkube
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

### SEE ALSO

* [botkube install](botkube_install.md) - install Botkube into cluster
* [botkube login](botkube_login.md) - Login to a Botkube Cloud
* [botkube migrate](botkube_migrate.md) - Automatically migrates Botkube installation into Botkube Cloud

71 changes: 71 additions & 0 deletions cmd/cli/docs/botkube_install.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: botkube install
---

## botkube install

install Botkube into cluster

### Synopsis

Use this command to install the Botkube agent.

```
botkube install [OPTIONS] [flags]
```

### Examples

```
# Install latest stable Botkube version
botkube install
# Install Botkube 0.1.0 version
botkube install --version 0.1.0
# Install Botkube from local git repository. Needs to be run from the main directory.
botkube install --repo @local
```

### Options

```
--atomic If set, process rolls back changes made in case of failed install/upgrade. The --wait flag will be set automatically if --atomic is used
--chart-name string Botkube Helm chart name. (default "botkube")
--dependency-update Update dependencies if they are missing before installing the chart
--description string add a custom description
--disable-openapi-validation If set, it will not validate rendered templates against the Kubernetes OpenAPI Schema
--dry-run Simulate an install
--force Force resource updates through a replacement strategy
-h, --help help for install
--kubeconfig string Paths to a kubeconfig. Only required if out-of-cluster.
--namespace string Botkube installation namespace. (default "botkube")
--no-hooks Disable pre/post install/upgrade hooks
--release-name string Botkube Helm chart release name. (default "botkube")
--render-subchart-notes If set, render subchart notes along with the parent
--repo string Botkube Helm chart repository location. It can be relative path to current working directory or URL. Use @stable tag to select repository which holds the stable Helm chart versions. (default "https://charts.botkube.io/")
--reset-values When upgrading, reset the values to the ones built into the chart
--reuse-values When upgrading, reuse the last release's values and merge in any overrides from the command line via --set and -f. If '--reset-values' is specified, this is ignored
--set stringArray Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--set-file stringArray Set values from respective files specified via the command line (can specify multiple or separate values with commas: key1=path1,key2=path2)
--set-json stringArray Set JSON values on the command line (can specify multiple or separate values with commas: key1=jsonval1,key2=jsonval2)
--set-literal stringArray Set a literal STRING value on the command line
--set-string stringArray Set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)
--skip-crds If set, no CRDs will be installed.
--timeout duration time to wait for any individual Kubernetes operation (like Jobs for hooks) (default 5m0s)
-f, --values strings Specify values in a YAML file or a URL (can specify multiple)
--version string Botkube version. Possible values @latest, 1.2.0, ... (default "@latest")
--wait If set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout (default true)
--wait-for-jobs If set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout (default true)
```

### Options inherited from parent commands

```
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

### SEE ALSO

* [botkube](botkube.md) - Botkube CLI

8 changes: 7 additions & 1 deletion cmd/cli/docs/botkube_login.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ botkube login
-h, --help help for login
```

### Options inherited from parent commands

```
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

### SEE ALSO

* [botkube](botkube.md) - Botkube Cloud CLI
* [botkube](botkube.md) - Botkube CLI

8 changes: 7 additions & 1 deletion cmd/cli/docs/botkube_migrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ botkube migrate [OPTIONS] [flags]
--token string Botkube Cloud authentication token
```

### Options inherited from parent commands

```
-v, --verbose int/string[=simple] Prints more verbose output. Allowed values: 0 - disable, 1 - simple, 2 - trace (default 0 - disable)
```

### SEE ALSO

* [botkube](botkube.md) - Botkube Cloud CLI
* [botkube](botkube.md) - Botkube CLI

12 changes: 8 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/aws/aws-sdk-go v1.44.122
github.com/briandowns/spinner v1.23.0
github.com/bwmarrin/discordgo v0.25.0
github.com/dustin/go-humanize v1.0.0
github.com/dustin/go-humanize v1.0.1
github.com/fatih/color v1.13.0
github.com/go-playground/locales v0.14.0
github.com/go-playground/universal-translator v0.18.0
Expand Down Expand Up @@ -46,12 +46,13 @@ require (
github.com/sha1sum/aws_signing_client v0.0.0-20200229211254-f7815c59d5c1
github.com/sirupsen/logrus v1.9.0
github.com/slack-go/slack v0.12.2
github.com/spf13/cobra v1.6.1
github.com/spf13/cobra v1.7.0
github.com/spf13/pflag v1.0.5
github.com/spiffe/spire v1.5.3
github.com/stretchr/testify v1.8.4
github.com/vrischmann/envconfig v1.3.0
github.com/xeipuuv/gojsonschema v1.2.0
go.szostok.io/version v1.2.0
golang.org/x/exp v0.0.0-20230307190834-24139beb5833
golang.org/x/oauth2 v0.5.0
golang.org/x/sync v0.2.0
Expand Down Expand Up @@ -87,6 +88,7 @@ require (
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/alexflint/go-scalar v1.1.0 // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
Expand Down Expand Up @@ -143,7 +145,7 @@ require (
github.com/hashicorp/go-safetemp v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20211028200310-0bc27b27de87 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -162,13 +164,14 @@ require (
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattermost/go-i18n v1.11.1-0.20211013152124-5c415071e404 // indirect
github.com/mattermost/ldap v0.0.0-20201202150706-ee0e6284187d // indirect
github.com/mattermost/logr v1.0.13 // indirect
github.com/mattermost/logr/v2 v2.0.15 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/minio/md5-simd v1.1.2 // indirect
Expand All @@ -187,6 +190,7 @@ require (
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/muesli/termenv v0.15.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oklog/run v1.1.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand Down
Loading

0 comments on commit db6a62f

Please sign in to comment.