Skip to content

Commit

Permalink
doc updates; release listing
Browse files Browse the repository at this point in the history
  • Loading branch information
Jancis committed Oct 11, 2024
1 parent 21a5a79 commit 4bf0bfa
Show file tree
Hide file tree
Showing 15 changed files with 336 additions and 6 deletions.
8 changes: 5 additions & 3 deletions cmd/ciReleaseDeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var ciReleaseDeployCmd = &cobra.Command{
* Chart allows prepending extra configuration (to helm --values line) via
"SILTA_<chart_name>_CONFIG_VALUES" environment variable. It has to be a
base64 encoded string of a silta configuration yaml file.
* If IMAGE_PULL_SECRET is set (base64 encoded), it will be added to the
release values as imagePullSecret.
`,
Run: func(cmd *cobra.Command, args []string) {

Expand Down Expand Up @@ -184,9 +187,6 @@ var ciReleaseDeployCmd = &cobra.Command{
helmFlags = fmt.Sprintf("%s --set imagePullSecret='%s'", helmFlags, imagePullSecret)
}

// TODO: fix this
command := ""

if !debug {
// Add helm repositories
command := fmt.Sprintf("helm repo add '%s' '%s'", "wunderio", chartRepository)
Expand All @@ -201,6 +201,8 @@ var ciReleaseDeployCmd = &cobra.Command{
exec.Command("bash", "-c", command).Run()
}

command := ""

if chartName == "simple" || strings.HasSuffix(chartName, "/simple") {

if len(nginxImageUrl) == 0 {
Expand Down
3 changes: 3 additions & 0 deletions cmd/ciReleaseDiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var ciReleaseDiffCmd = &cobra.Command{
* Chart allows prepending extra configuration (to helm --values line) via
"SILTA_<chart_name>_CONFIG_VALUES" environment variable. It has to be a
base64 encoded string of a silta configuration yaml file.
* If IMAGE_PULL_SECRET is set (base64 encoded), it will be added to the
release values as imagePullSecret.
`,
Run: func(cmd *cobra.Command, args []string) {

Expand Down
79 changes: 79 additions & 0 deletions cmd/ciReleaseList.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package cmd

import (
"fmt"
"os"

helmclient "github.com/mittwald/go-helm-client"
"github.com/spf13/cobra"
"helm.sh/helm/v3/pkg/action"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // gcp auth provider

"text/tabwriter"
)

var ciReleaseListCmd = &cobra.Command{
Use: "list",
Short: "List releases",
Run: func(cmd *cobra.Command, args []string) {

namespace, _ := cmd.Flags().GetString("namespace")

homeDir, err := os.UserHomeDir()
if err != nil {
fmt.Println("cannot read user home dir")
os.Exit(1)
}
kubeConfigPath := homeDir + "/.kube/config"

kubeConfig, err := os.ReadFile(kubeConfigPath)
if err != nil {
fmt.Println("cannot read kubeConfig from path")
os.Exit(1)
}

helmOptions := helmclient.Options{
Namespace: namespace,
RepositoryCache: "/tmp/.helmcache",
RepositoryConfig: "/tmp/.helmrepo",
Debug: false,
Linting: false, // Change this to false if you don't want linting.
}

//Helm client init logic
opt := &helmclient.KubeConfClientOptions{
Options: &helmOptions,
KubeContext: "",
KubeConfig: kubeConfig,
}

helmClient, err := helmclient.NewClientFromKubeConf(opt)
if err != nil {
fmt.Println("Cannot create client from kubeConfig")
os.Exit(1)
}

// List Helm releases
releases, err := helmClient.ListReleasesByStateMask(action.ListAll)
if err != nil {
fmt.Printf("Cannot list releases: %s\n", err)
os.Exit(1)
}

writer := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', tabwriter.AlignRight)
fmt.Fprintln(writer, "NAME\tNAMESPACE\tREVISION\tUPDATED\tSTATUS\tCHART\tAPP VERSION")

for _, release := range releases {
fmt.Fprintf(writer, "%s\t%s\t%d\t%s\t%s\t%s\t%s\n", release.Name, release.Namespace, release.Version, release.Info.LastDeployed.String(), release.Info.Status.String(), release.Chart.Name(), release.Chart.Metadata.Version)
}

writer.Flush()

},
}

func init() {
ciReleaseCmd.AddCommand(ciReleaseListCmd)

ciReleaseListCmd.Flags().StringP("namespace", "n", "", "Project name (namespace, i.e. \"drupal-project\")")
}
2 changes: 2 additions & 0 deletions docs/silta.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ Silta CLI
* [silta ci](silta_ci.md) - Silta CI Commands
* [silta cloud](silta_cloud.md) - Kubernetes cloud related commands
* [silta completion](silta_completion.md) - Generate the autocompletion script for the specified shell
* [silta config](silta_config.md) - Silta configuration commands
* [silta doc](silta_doc.md) - Generate menu documentation markdown
* [silta scripts](silta_scripts.md) - Convenience scripts for silta
* [silta secrets](silta_secrets.md) - Manage encrypted secret files
* [silta tools](silta_tools.md) - CI tooling
* [silta version](silta_version.md) - Silta CLI version
Expand Down
2 changes: 2 additions & 0 deletions docs/silta_ci_release.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ silta ci release [flags]
* [silta ci release clean-failed](silta_ci_release_clean-failed.md) - Clean failed releases
* [silta ci release delete](silta_ci_release_delete.md) - Delete a release
* [silta ci release deploy](silta_ci_release_deploy.md) - Deploy release
* [silta ci release diff](silta_ci_release_diff.md) - Diff release resources
* [silta ci release environmentname](silta_ci_release_environmentname.md) - Return environment name
* [silta ci release info](silta_ci_release_info.md) - Print release information
* [silta ci release list](silta_ci_release_list.md) - List releases
* [silta ci release name](silta_ci_release_name.md) - Return release name
* [silta ci release validate](silta_ci_release_validate.md) - Validate release
* [silta ci release wakeup](silta_ci_release_wakeup.md) - Wake up a downscaled release
Expand Down
2 changes: 1 addition & 1 deletion docs/silta_ci_release_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ silta ci release delete [flags]
### Options

```
--delete-pvcs Delete PVCs (default: false)
--delete-pvcs Delete PVCs (default: true) (default true)
-h, --help help for delete
--namespace string Project name (namespace, i.e. "drupal-project")
--release-name string Release name
Expand Down
5 changes: 4 additions & 1 deletion docs/silta_ci_release_deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Release deployment
* Chart allows prepending extra configuration (to helm --values line) via
"SILTA_<chart_name>_CONFIG_VALUES" environment variable. It has to be a
base64 encoded string of a silta configuration yaml file.

* If IMAGE_PULL_SECRET is set (base64 encoded), it will be added to the
release values as imagePullSecret.


```
Expand All @@ -20,7 +23,7 @@ silta ci release deploy [flags]
```
--branchname string Repository branchname that will be used for release name and environment name creation
--chart-name string Chart name
--chart-repository string Chart repository
--chart-repository string Chart repository (default "https://storage.googleapis.com/charts.wdr.io")
--chart-version string Deploy a specific chart version
--cluster-domain string Base domain for cluster urls (i.e. dev.example.com)
--cluster-type string Cluster type (i.e. gke, aws, aks, other)
Expand Down
59 changes: 59 additions & 0 deletions docs/silta_ci_release_diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## silta ci release diff

Diff release resources

### Synopsis

Release diff command is used to compare the resources of a release with the current state of the cluster.

* Chart allows prepending extra configuration (to helm --values line) via
"SILTA_<chart_name>_CONFIG_VALUES" environment variable. It has to be a
base64 encoded string of a silta configuration yaml file.

* If IMAGE_PULL_SECRET is set (base64 encoded), it will be added to the
release values as imagePullSecret.


```
silta ci release diff [flags]
```

### Options

```
--branchname string Repository branchname that will be used for release name and environment name creation
--chart-name string Chart name
--chart-repository string Chart repository (default "https://storage.googleapis.com/charts.wdr.io")
--chart-version string Diff a specific chart version
--cluster-domain string Base domain for cluster urls (i.e. dev.example.com)
--cluster-type string Cluster type (i.e. gke, aws, aks, other)
--db-root-pass string Database password for root account
--db-user-pass string Database password for user account
--gitauth-password string Gitauth server password
--gitauth-username string Gitauth server username
--helm-flags string Extra flags for helm release
-h, --help help for diff
--namespace string Project name (namespace, i.e. "drupal-project")
--nginx-image-url string PHP image url
--php-image-url string PHP image url
--release-name string Release name
--release-suffix string Release name suffix for environment name creation
--repository-url string Repository url (i.e. git@github.com:wunderio/silta.git)
--shell-image-url string PHP image url
--silta-config string Silta release helm chart values
--silta-environment-name string Environment name override based on branchname and release-suffix. Used in some helm charts.
--vpc-native string VPC-native cluster (GKE specific)
--vpn-ip string VPN IP for basic auth allow list
```

### Options inherited from parent commands

```
--debug Print variables, do not execute external commands, rather print them
--use-env Use environment variables for value assignment (default true)
```

### SEE ALSO

* [silta ci release](silta_ci_release.md) - CI release related commands

26 changes: 26 additions & 0 deletions docs/silta_ci_release_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## silta ci release list

List releases

```
silta ci release list [flags]
```

### Options

```
-h, --help help for list
-n, --namespace string Project name (namespace, i.e. "drupal-project")
```

### Options inherited from parent commands

```
--debug Print variables, do not execute external commands, rather print them
--use-env Use environment variables for value assignment (default true)
```

### SEE ALSO

* [silta ci release](silta_ci_release.md) - CI release related commands

2 changes: 1 addition & 1 deletion docs/silta_ci_release_validate.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ silta ci release validate [flags]
```
--branchname string Repository branchname that will be used for release name and environment name creation
--chart-name string Chart name
--chart-repository string Chart repository
--chart-repository string Chart repository (default "https://storage.googleapis.com/charts.wdr.io")
--chart-version string Deploy a specific chart version
--cluster-type string Cluster type (i.e. gke, aws, aks, other)
-h, --help help for validate
Expand Down
32 changes: 32 additions & 0 deletions docs/silta_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## silta config

Silta configuration commands

### Synopsis

Silta configuration commands, allows setting and getting configuration values.
Configuration is persistent and is stored in file "/home/jancis/.config/silta/config.yaml".

```
silta config [flags]
```

### Options

```
-h, --help help for config
```

### Options inherited from parent commands

```
--debug Print variables, do not execute external commands, rather print them
--use-env Use environment variables for value assignment (default true)
```

### SEE ALSO

* [silta](silta.md) - Silta CLI
* [silta config get](silta_config_get.md) - Get configuration
* [silta config set](silta_config_set.md) - Set configuration

30 changes: 30 additions & 0 deletions docs/silta_config_get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
## silta config get

Get configuration

### Synopsis

This will print configuration information. If no arguments are provided, the entire configuration file will be printed.
If a single argument is provided, the value of the configuration key will be printed. Supports nested keys using dot notation.

```
silta config get [flags]
```

### Options

```
-h, --help help for get
```

### Options inherited from parent commands

```
--debug Print variables, do not execute external commands, rather print them
--use-env Use environment variables for value assignment (default true)
```

### SEE ALSO

* [silta config](silta_config.md) - Silta configuration commands

35 changes: 35 additions & 0 deletions docs/silta_config_set.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## silta config set

Set configuration

### Synopsis

This will set configuration information. The first argument is the key and the second argument is the value.
If the key already exists, the value will be overwritten. Supports nested keys using dot notation.
Usage: silta config set <key> <value>
Example: silta config set mykey
Example: silta config set mykey myvalue
Example: silta config set mykey.subkey myvalue


```
silta config set [flags]
```

### Options

```
-h, --help help for set
```

### Options inherited from parent commands

```
--debug Print variables, do not execute external commands, rather print them
--use-env Use environment variables for value assignment (default true)
```

### SEE ALSO

* [silta config](silta_config.md) - Silta configuration commands

26 changes: 26 additions & 0 deletions docs/silta_scripts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## silta scripts

Convenience scripts for silta

```
silta scripts [flags]
```

### Options

```
-h, --help help for scripts
```

### Options inherited from parent commands

```
--debug Print variables, do not execute external commands, rather print them
--use-env Use environment variables for value assignment (default true)
```

### SEE ALSO

* [silta](silta.md) - Silta CLI
* [silta scripts elasticsearch-initcontainer-remove](silta_scripts_elasticsearch-initcontainer-remove.md) - es-init-remove

Loading

0 comments on commit 4bf0bfa

Please sign in to comment.