1
0
mirror of synced 2026-02-06 19:05:55 +00:00

Rename tk binary to gotk

To avoid conflicts with the `tk` binary from the Tanka project.
This commit is contained in:
Hidde Beydals
2020-08-25 21:09:34 +02:00
parent cb23d3ff3c
commit 22624ae4d5
108 changed files with 500 additions and 500 deletions

View File

@@ -71,14 +71,14 @@ func init() {
}
func generateInstallManifests(targetPath, namespace, tmpDir string) (string, error) {
tkDir := path.Join(tmpDir, ".tk")
defer os.RemoveAll(tkDir)
gotkDir := path.Join(tmpDir, ".gotk")
defer os.RemoveAll(gotkDir)
if err := os.MkdirAll(tkDir, os.ModePerm); err != nil {
if err := os.MkdirAll(gotkDir, os.ModePerm); err != nil {
return "", fmt.Errorf("generating manifests failed: %w", err)
}
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents, bootstrapRegistry, bootstrapImagePullSecret, tkDir); err != nil {
if err := genInstallManifests(bootstrapVersion, namespace, bootstrapComponents, bootstrapRegistry, bootstrapImagePullSecret, gotkDir); err != nil {
return "", fmt.Errorf("generating manifests failed: %w", err)
}
@@ -88,7 +88,7 @@ func generateInstallManifests(targetPath, namespace, tmpDir string) (string, err
}
manifest := path.Join(manifestsDir, bootstrapInstallManifest)
if err := buildKustomization(tkDir, manifest); err != nil {
if err := buildKustomization(gotkDir, manifest); err != nil {
return "", fmt.Errorf("build kustomization failed: %w", err)
}

View File

@@ -42,19 +42,19 @@ the bootstrap command will perform an upgrade if needed.`,
export GITHUB_TOKEN=<my-token>
# Run bootstrap for a private repo owned by a GitHub organization
tk bootstrap github --owner=<organization> --repository=<repo name>
gotk bootstrap github --owner=<organization> --repository=<repo name>
# Run bootstrap for a private repo and assign organization teams to it
tk bootstrap github --owner=<organization> --repository=<repo name> --team=<team1 slug> --team=<team2 slug>
gotk bootstrap github --owner=<organization> --repository=<repo name> --team=<team1 slug> --team=<team2 slug>
# Run bootstrap for a repository path
tk bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster
gotk bootstrap github --owner=<organization> --repository=<repo name> --path=dev-cluster
# Run bootstrap for a public repository on a personal account
tk bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true
gotk bootstrap github --owner=<user> --repository=<repo name> --private=false --personal=true
# Run bootstrap for a private repo hosted on GitHub Enterprise
tk bootstrap github --owner=<organization> --repository=<repo name> --hostname=<domain>
gotk bootstrap github --owner=<organization> --repository=<repo name> --hostname=<domain>
`,
RunE: bootstrapGitHubCmdRun,
}
@@ -93,7 +93,7 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("%s environment variable not found", git.GitHubTokenName)
}
repository, err := git.NewRepository(ghRepository, ghOwner, ghHostname, ghToken, "tk", ghOwner+"@users.noreply.github.com")
repository, err := git.NewRepository(ghRepository, ghOwner, ghHostname, ghToken, "gotk", ghOwner+"@users.noreply.github.com")
if err != nil {
return err
}
@@ -194,9 +194,9 @@ func bootstrapGitHubCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("generating deploy key failed: %w", err)
}
keyName := "tk"
keyName := "gotk"
if ghPath != "" {
keyName = fmt.Sprintf("tk-%s", ghPath)
keyName = fmt.Sprintf("gotk-%s", ghPath)
}
if changed, err := provider.AddDeployKey(ctx, repository, key, keyName); err != nil {

View File

@@ -42,16 +42,16 @@ the bootstrap command will perform an upgrade if needed.`,
export GITLAB_TOKEN=<my-token>
# Run bootstrap for a private repo owned by a GitLab group
tk bootstrap gitlab --owner=<group> --repository=<repo name>
gotk bootstrap gitlab --owner=<group> --repository=<repo name>
# Run bootstrap for a repository path
tk bootstrap gitlab --owner=<group> --repository=<repo name> --path=dev-cluster
gotk bootstrap gitlab --owner=<group> --repository=<repo name> --path=dev-cluster
# Run bootstrap for a public repository on a personal account
tk bootstrap gitlab --owner=<user> --repository=<repo name> --private=false --personal=true
gotk bootstrap gitlab --owner=<user> --repository=<repo name> --private=false --personal=true
# Run bootstrap for a private repo hosted on a GitLab server
tk bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain>
gotk bootstrap gitlab --owner=<group> --repository=<repo name> --hostname=<domain>
`,
RunE: bootstrapGitLabCmdRun,
}
@@ -86,7 +86,7 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("%s environment variable not found", git.GitLabTokenName)
}
repository, err := git.NewRepository(glRepository, glOwner, glHostname, glToken, "tk", glOwner+"@users.noreply.gitlab.com")
repository, err := git.NewRepository(glRepository, glOwner, glHostname, glToken, "gotk", glOwner+"@users.noreply.gitlab.com")
if err != nil {
return err
}
@@ -178,9 +178,9 @@ func bootstrapGitLabCmdRun(cmd *cobra.Command, args []string) error {
return fmt.Errorf("generating deploy key failed: %w", err)
}
keyName := "tk"
keyName := "gotk"
if glPath != "" {
keyName = fmt.Sprintf("tk-%s", glPath)
keyName = fmt.Sprintf("gotk-%s", glPath)
}
if changed, err := provider.AddDeployKey(ctx, repository, key, keyName); err != nil {

View File

@@ -35,10 +35,10 @@ var checkCmd = &cobra.Command{
Long: `The check command will perform a series of checks to validate that
the local environment is configured correctly and if the installed components are healthy.`,
Example: ` # Run pre-installation checks
tk check --pre
gotk check --pre
# Run installation checks
tk check
gotk check
`,
RunE: runCheckCmd,
}

View File

@@ -27,12 +27,12 @@ var completionCmd = &cobra.Command{
Short: "Generates bash completion scripts",
Example: `To load completion run
. <(tk completion)
. <(gotk completion)
To configure your bash shell to load completions for each session add to your bashrc
# ~/.bashrc or ~/.profile
. <(tk completion)
. <(gotk completion)
`,
Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenBashCompletion(os.Stdout)

View File

@@ -42,7 +42,7 @@ var createHelmReleaseCmd = &cobra.Command{
Short: "Create or update a HelmRelease resource",
Long: "The helmrelease create command generates a HelmRelease resource for a given HelmRepository source.",
Example: ` # Create a HelmRelease from a source
tk create hr podinfo \
gotk create hr podinfo \
--interval=10m \
--release-name=podinfo \
--target-namespace=default \
@@ -51,7 +51,7 @@ var createHelmReleaseCmd = &cobra.Command{
--chart-version=">4.0.0"
# Create a HelmRelease with values for a local YAML file
tk create hr podinfo \
gotk create hr podinfo \
--target-namespace=default \
--source=podinfo \
--chart-name=podinfo \
@@ -59,7 +59,7 @@ var createHelmReleaseCmd = &cobra.Command{
--values=./my-values.yaml
# Create a HelmRelease definition on disk without applying it on the cluster
tk create hr podinfo \
gotk create hr podinfo \
--target-namespace=default \
--source=podinfo \
--chart-name=podinfo \

View File

@@ -40,7 +40,7 @@ var createKsCmd = &cobra.Command{
Short: "Create or update a Kustomization resource",
Long: "The kustomization source create command generates a Kustomize resource for a given GitRepository source.",
Example: ` # Create a Kustomization resource from a source at a given path
tk create kustomization contour \
gotk create kustomization contour \
--source=contour \
--path="./examples/contour/" \
--prune=true \
@@ -51,7 +51,7 @@ var createKsCmd = &cobra.Command{
--health-check-timeout=3m
# Create a Kustomization resource that depends on the previous one
tk create kustomization webapp \
gotk create kustomization webapp \
--depends-on=contour \
--source=webapp \
--path="./deploy/overlays/dev" \
@@ -60,7 +60,7 @@ var createKsCmd = &cobra.Command{
--validation=client
# Create a Kustomization resource that runs under a service account
tk create kustomization webapp \
gotk create kustomization webapp \
--source=webapp \
--path="./deploy/overlays/staging" \
--prune=true \

View File

@@ -46,35 +46,35 @@ The create source git command generates a GitRepository resource and waits for i
For Git over SSH, host and SSH keys are automatically generated and stored in a Kubernetes secret.
For private Git repositories, the basic authentication credentials are stored in a Kubernetes secret.`,
Example: ` # Create a source from a public Git repository master branch
tk create source git podinfo \
gotk create source git podinfo \
--url=https://github.com/stefanprodan/podinfo \
--branch=master
# Create a source from a Git repository pinned to specific git tag
tk create source git podinfo \
gotk create source git podinfo \
--url=https://github.com/stefanprodan/podinfo \
--tag="3.2.3"
# Create a source from a public Git repository tag that matches a semver range
tk create source git podinfo \
gotk create source git podinfo \
--url=https://github.com/stefanprodan/podinfo \
--tag-semver=">=3.2.0 <3.3.0"
# Create a source from a Git repository using SSH authentication
tk create source git podinfo \
gotk create source git podinfo \
--url=ssh://git@github.com/stefanprodan/podinfo \
--branch=master
# Create a source from a Git repository using SSH authentication and an
# ECDSA P-521 curve public key
tk create source git podinfo \
gotk create source git podinfo \
--url=ssh://git@github.com/stefanprodan/podinfo \
--branch=master \
--ssh-key-algorithm=ecdsa \
--ssh-ecdsa-curve=p521
# Create a source from a Git repository using basic authentication
tk create source git podinfo \
gotk create source git podinfo \
--url=https://github.com/stefanprodan/podinfo \
--username=username \
--password=password

View File

@@ -40,18 +40,18 @@ var createSourceHelmCmd = &cobra.Command{
The create source helm command generates a HelmRepository resource and waits for it to fetch the index.
For private Helm repositories, the basic authentication credentials are stored in a Kubernetes secret.`,
Example: ` # Create a source from a public Helm repository
tk create source helm podinfo \
gotk create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--interval=10m
# Create a source from a Helm repository using basic authentication
tk create source helm podinfo \
gotk create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--username=username \
--password=password
# Create a source from a Helm repository using TLS authentication
tk create source helm podinfo \
gotk create source helm podinfo \
--url=https://stefanprodan.github.io/podinfo \
--cert-file=./cert.crt \
--key-file=./key.crt \

View File

@@ -33,7 +33,7 @@ var deleteHelmReleaseCmd = &cobra.Command{
Short: "Delete a HelmRelease resource",
Long: "The delete helmrelease command removes the given HelmRelease from the cluster.",
Example: ` # Delete a Helm release and the Kubernetes resources created by it
tk delete hr podinfo
gotk delete hr podinfo
`,
RunE: deleteHelmReleaseCmdRun,
}

View File

@@ -32,7 +32,7 @@ var deleteKsCmd = &cobra.Command{
Short: "Delete a Kustomization resource",
Long: "The delete kustomization command deletes the given Kustomization from the cluster.",
Example: ` # Delete a kustomization and the Kubernetes resources created by it
tk delete kustomization podinfo
gotk delete kustomization podinfo
`,
RunE: deleteKsCmdRun,
}

View File

@@ -31,7 +31,7 @@ var deleteSourceGitCmd = &cobra.Command{
Short: "Delete a GitRepository source",
Long: "The delete source git command deletes the given GitRepository from the cluster.",
Example: ` # Delete a Git repository
tk delete source git podinfo
gotk delete source git podinfo
`,
RunE: deleteSourceGitCmdRun,
}

View File

@@ -31,7 +31,7 @@ var deleteSourceHelmCmd = &cobra.Command{
Short: "Delete a HelmRepository source",
Long: "The delete source helm command deletes the given HelmRepository from the cluster.",
Example: ` # Delete a Helm repository
tk delete source helm podinfo
gotk delete source helm podinfo
`,
RunE: deleteSourceHelmCmdRun,
}

View File

@@ -35,10 +35,10 @@ var exportHelmReleaseCmd = &cobra.Command{
Short: "Export HelmRelease resources in YAML format",
Long: "The export helmrelease command exports one or all HelmRelease resources in YAML format.",
Example: ` # Export all HelmRelease resources
tk export helmrelease --all > kustomizations.yaml
gotk export helmrelease --all > kustomizations.yaml
# Export a HelmRelease
tk export hr my-app > app-release.yaml
gotk export hr my-app > app-release.yaml
`,
RunE: exportHelmReleaseCmdRun,
}

View File

@@ -34,10 +34,10 @@ var exportKsCmd = &cobra.Command{
Short: "Export Kustomization resources in YAML format",
Long: "The export kustomization command exports one or all Kustomization resources in YAML format.",
Example: ` # Export all Kustomization resources
tk export kustomization --all > kustomizations.yaml
gotk export kustomization --all > kustomizations.yaml
# Export a Kustomization
tk export kustomization my-app > kustomization.yaml
gotk export kustomization my-app > kustomization.yaml
`,
RunE: exportKsCmdRun,
}

View File

@@ -34,10 +34,10 @@ var exportSourceGitCmd = &cobra.Command{
Short: "Export GitRepository sources in YAML format",
Long: "The export source git command exports on or all GitRepository sources in YAML format.",
Example: ` # Export all GitRepository sources
tk export source git --all > sources.yaml
gotk export source git --all > sources.yaml
# Export a GitRepository source including the SSH key pair or basic auth credentials
tk export source git my-private-repo --with-credentials > source.yaml
gotk export source git my-private-repo --with-credentials > source.yaml
`,
RunE: exportSourceGitCmdRun,
}

View File

@@ -34,10 +34,10 @@ var exportSourceHelmCmd = &cobra.Command{
Short: "Export HelmRepository sources in YAML format",
Long: "The export source git command exports on or all HelmRepository sources in YAML format.",
Example: ` # Export all HelmRepository sources
tk export source helm --all > sources.yaml
gotk export source helm --all > sources.yaml
# Export a HelmRepository source including the basic auth credentials
tk export source helm my-private-repo --with-credentials > source.yaml
gotk export source helm my-private-repo --with-credentials > source.yaml
`,
RunE: exportSourceHelmCmdRun,
}

View File

@@ -32,7 +32,7 @@ var getHelmReleaseCmd = &cobra.Command{
Short: "Get HelmRelease statuses",
Long: "The get helmreleases command prints the statuses of the resources.",
Example: ` # List all Helm releases and their status
tk get helmreleases
gotk get helmreleases
`,
RunE: getHelmReleaseCmdRun,
}

View File

@@ -31,7 +31,7 @@ var getKsCmd = &cobra.Command{
Short: "Get Kustomization statuses",
Long: "The get kustomizations command prints the statuses of the resources.",
Example: ` # List all kustomizations and their status
tk get kustomizations
gotk get kustomizations
`,
RunE: getKsCmdRun,
}

View File

@@ -30,7 +30,7 @@ var getSourceGitCmd = &cobra.Command{
Short: "Get GitRepository source statuses",
Long: "The get sources git command prints the status of the GitRepository sources.",
Example: ` # List all Git repositories and their status
tk get sources git
gotk get sources git
`,
RunE: getSourceGitCmdRun,
}

View File

@@ -30,7 +30,7 @@ var getSourceHelmCmd = &cobra.Command{
Short: "Get HelmRepository source statuses",
Long: "The get sources helm command prints the status of the HelmRepository sources.",
Example: ` # List all Helm repositories and their status
tk get sources helm
gotk get sources helm
`,
RunE: getSourceHelmCmdRun,
}

View File

@@ -39,16 +39,16 @@ var installCmd = &cobra.Command{
Long: `The install command deploys the toolkit components in the specified namespace.
If a previous version is installed, then an in-place upgrade will be performed.`,
Example: ` # Install the latest version in the gitops-systems namespace
tk install --version=latest --namespace=gitops-systems
gotk install --version=latest --namespace=gitops-systems
# Dry-run install for a specific version and a series of components
tk install --dry-run --version=v0.0.7 --components="source-controller,kustomize-controller"
gotk install --dry-run --version=v0.0.7 --components="source-controller,kustomize-controller"
# Dry-run install with manifests preview
tk install --dry-run --verbose
gotk install --dry-run --verbose
# Write install manifests to file
tk install --export > gitops-system.yaml
gotk install --export > gitops-system.yaml
`,
RunE: installCmdRun,
}

View File

@@ -26,41 +26,41 @@ import (
"github.com/spf13/cobra/doc"
_ "k8s.io/client-go/plugin/pkg/client/auth"
tklog "github.com/fluxcd/toolkit/pkg/log"
gotklog "github.com/fluxcd/toolkit/pkg/log"
)
var VERSION = "0.0.0-dev.0"
var rootCmd = &cobra.Command{
Use: "tk",
Use: "gotk",
Version: VERSION,
SilenceUsage: true,
SilenceErrors: true,
Short: "Command line utility for assembling Kubernetes CD pipelines",
Long: `Command line utility for assembling Kubernetes CD pipelines the GitOps way.`,
Example: ` # Check prerequisites
tk check --pre
gotk check --pre
# Install the latest version of the toolkit
tk install --version=master
gotk install --version=master
# Create a source from a public Git repository
tk create source git webapp-latest \
gotk create source git webapp-latest \
--url=https://github.com/stefanprodan/podinfo \
--branch=master \
--interval=3m
# List GitRepository sources and their status
tk get sources git
gotk get sources git
# Trigger a GitRepository source reconciliation
tk reconcile source git gitops-system
gotk reconcile source git gitops-system
# Export GitRepository sources in YAML format
tk export source git --all > sources.yaml
gotk export source git --all > sources.yaml
# Create a Kustomization for deploying a series of microservices
tk create kustomization webapp-dev \
gotk create kustomization webapp-dev \
--source=webapp-latest \
--path="./deploy/webapp/" \
--prune=true \
@@ -71,25 +71,25 @@ var rootCmd = &cobra.Command{
--health-check-timeout=2m
# Trigger a git sync of the Kustomization's source and apply changes
tk reconcile kustomization webapp-dev --with-source
gotk reconcile kustomization webapp-dev --with-source
# Suspend a Kustomization reconciliation
tk suspend kustomization webapp-dev
gotk suspend kustomization webapp-dev
# Export Kustomizations in YAML format
tk export kustomization --all > kustomizations.yaml
gotk export kustomization --all > kustomizations.yaml
# Resume a Kustomization reconciliation
tk resume kustomization webapp-dev
gotk resume kustomization webapp-dev
# Delete a Kustomization
tk delete kustomization webapp-dev
gotk delete kustomization webapp-dev
# Delete a GitRepository source
tk delete source git webapp-latest
gotk delete source git webapp-latest
# Uninstall the toolkit and delete CRDs
tk uninstall --crds
gotk uninstall --crds
`,
}
@@ -99,8 +99,8 @@ var (
timeout time.Duration
verbose bool
utils Utils
pollInterval = 2 * time.Second
logger tklog.Logger = printLogger{}
pollInterval = 2 * time.Second
logger gotklog.Logger = printLogger{}
)
var (

View File

@@ -37,10 +37,10 @@ var reconcileHrCmd = &cobra.Command{
Long: `
The reconcile kustomization command triggers a reconciliation of a HelmRelease resource and waits for it to finish.`,
Example: ` # Trigger a HelmRelease apply outside of the reconciliation interval
tk reconcile hr podinfo
gotk reconcile hr podinfo
# Trigger a reconciliation of the HelmRelease's source and apply changes
tk reconcile hr podinfo --with-source
gotk reconcile hr podinfo --with-source
`,
RunE: reconcileHrCmdRun,
}

View File

@@ -34,10 +34,10 @@ var reconcileKsCmd = &cobra.Command{
Long: `
The reconcile kustomization command triggers a reconciliation of a Kustomization resource and waits for it to finish.`,
Example: ` # Trigger a Kustomization apply outside of the reconciliation interval
tk reconcile kustomization podinfo
gotk reconcile kustomization podinfo
# Trigger a sync of the Kustomization's source and apply changes
tk reconcile kustomization podinfo --with-source
gotk reconcile kustomization podinfo --with-source
`,
RunE: reconcileKsCmdRun,
}

View File

@@ -31,7 +31,7 @@ var reconcileSourceGitCmd = &cobra.Command{
Short: "Reconcile a GitRepository source",
Long: `The reconcile source command triggers a reconciliation of a GitRepository resource and waits for it to finish.`,
Example: ` # Trigger a git pull for an existing source
tk reconcile source git podinfo
gotk reconcile source git podinfo
`,
RunE: syncSourceGitCmdRun,
}

View File

@@ -35,7 +35,7 @@ var reconcileSourceHelmCmd = &cobra.Command{
Short: "Reconcile a HelmRepository source",
Long: `The reconcile source command triggers a reconciliation of a HelmRepository resource and waits for it to finish.`,
Example: ` # Trigger a reconciliation for an existing source
tk reconcile source helm podinfo
gotk reconcile source helm podinfo
`,
RunE: syncSourceHelmCmdRun,
}

View File

@@ -36,7 +36,7 @@ var resumeHrCmd = &cobra.Command{
Long: `The resume command marks a previously suspended HelmRelease resource for reconciliation and waits for it to
finish the apply.`,
Example: ` # Resume reconciliation for an existing Helm release
tk resume hr podinfo
gotk resume hr podinfo
`,
RunE: resumeHrCmdRun,
}

View File

@@ -36,7 +36,7 @@ var resumeKsCmd = &cobra.Command{
Long: `The resume command marks a previously suspended Kustomization resource for reconciliation and waits for it to
finish the apply.`,
Example: ` # Resume reconciliation for an existing Kustomization
tk resume ks podinfo
gotk resume ks podinfo
`,
RunE: resumeKsCmdRun,
}

View File

@@ -32,7 +32,7 @@ var suspendHrCmd = &cobra.Command{
Short: "Suspend reconciliation of HelmRelease",
Long: "The suspend command disables the reconciliation of a HelmRelease resource.",
Example: ` # Suspend reconciliation for an existing Helm release
tk suspend hr podinfo
gotk suspend hr podinfo
`,
RunE: suspendHrCmdRun,
}

View File

@@ -30,7 +30,7 @@ var suspendKsCmd = &cobra.Command{
Short: "Suspend reconciliation of Kustomization",
Long: "The suspend command disables the reconciliation of a Kustomization resource.",
Example: ` # Suspend reconciliation for an existing Kustomization
tk suspend ks podinfo
gotk suspend ks podinfo
`,
RunE: suspendKsCmdRun,
}

View File

@@ -32,10 +32,10 @@ var uninstallCmd = &cobra.Command{
Short: "Uninstall the toolkit components",
Long: "The uninstall command removes the namespace, cluster roles, cluster role bindings and CRDs from the cluster.",
Example: ` # Dry-run uninstall of all components
tk uninstall --dry-run --namespace=gitops-system
gotk uninstall --dry-run --namespace=gitops-system
# Uninstall all components and delete custom resource definitions
tk uninstall --resources --crds --namespace=gitops-system
gotk uninstall --resources --crds --namespace=gitops-system
`,
RunE: uninstallCmdRun,
}