-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
336 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\")") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.