Skip to content

Commit

Permalink
Merge pull request #99 from fluxcd/export-install-manifests
Browse files Browse the repository at this point in the history
Add export option to tk install
  • Loading branch information
stefanprodan authored Jul 16, 2020
2 parents b04abe9 + 499ba15 commit 6cb7897
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cmd/tk/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"path"
"path/filepath"
"strings"
"time"

"github.com/spf13/cobra"
"sigs.k8s.io/kustomize/api/filesys"
Expand All @@ -43,18 +44,24 @@ If a previous version is installed, then an in-place upgrade will be performed.`
# Dry-run install with manifests preview
tk install --dry-run --verbose
# Write install manifests to file
tk install --export > gitops-system.yaml
`,
RunE: installCmdRun,
}

var (
installExport bool
installDryRun bool
installManifestsPath string
installVersion string
installComponents []string
)

func init() {
installCmd.Flags().BoolVar(&installExport, "export", false,
"write the install manifests to stdout and exit")
installCmd.Flags().BoolVarP(&installDryRun, "dry-run", "", false,
"only print the object that would be applied")
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaultVersion,
Expand Down Expand Up @@ -84,7 +91,9 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
}
defer os.RemoveAll(tmpDir)

logger.Generatef("generating manifests")
if !installExport {
logger.Generatef("generating manifests")
}
if kustomizePath == "" {
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
if err != nil {
Expand All @@ -104,6 +113,12 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
} else {
if verbose {
fmt.Print(yaml)
} else if installExport {
fmt.Println("---")
fmt.Println("# GitOps Toolkit revision", installVersion, time.Now().Format(time.RFC3339))
fmt.Print(yaml)
fmt.Println("---")
return nil
}
}
logger.Successf("manifests build completed")
Expand Down
4 changes: 4 additions & 0 deletions docs/cmd/tk_install.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,17 @@ tk install [flags]
# Dry-run install with manifests preview
tk install --dry-run --verbose
# Write install manifests to file
tk install --export > gitops-system.yaml
```

### Options

```
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
--dry-run only print the object that would be applied
--export write the install manifests to stdout and exit
-h, --help help for install
--manifests string path to the manifest directory, dev only
-v, --version string toolkit tag or branch (default "master")
Expand Down

0 comments on commit 6cb7897

Please sign in to comment.