mirror of
https://github.com/fluxcd/flux2.git
synced 2025-11-01 18:26:25 +08:00
Add export option to tk install
This commit is contained in:
@ -24,6 +24,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"sigs.k8s.io/kustomize/api/filesys"
|
"sigs.k8s.io/kustomize/api/filesys"
|
||||||
@ -43,11 +44,15 @@ If a previous version is installed, then an in-place upgrade will be performed.`
|
|||||||
|
|
||||||
# Dry-run install with manifests preview
|
# Dry-run install with manifests preview
|
||||||
tk install --dry-run --verbose
|
tk install --dry-run --verbose
|
||||||
|
|
||||||
|
# Write install manifests to file
|
||||||
|
tk install --export > gitops-system.yaml
|
||||||
`,
|
`,
|
||||||
RunE: installCmdRun,
|
RunE: installCmdRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
installExport bool
|
||||||
installDryRun bool
|
installDryRun bool
|
||||||
installManifestsPath string
|
installManifestsPath string
|
||||||
installVersion string
|
installVersion string
|
||||||
@ -55,6 +60,8 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
installCmd.Flags().BoolVar(&installExport, "export", false,
|
||||||
|
"write the install manifests to stdout and exit")
|
||||||
installCmd.Flags().BoolVarP(&installDryRun, "dry-run", "", false,
|
installCmd.Flags().BoolVarP(&installDryRun, "dry-run", "", false,
|
||||||
"only print the object that would be applied")
|
"only print the object that would be applied")
|
||||||
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaultVersion,
|
installCmd.Flags().StringVarP(&installVersion, "version", "v", defaultVersion,
|
||||||
@ -84,7 +91,9 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
defer os.RemoveAll(tmpDir)
|
defer os.RemoveAll(tmpDir)
|
||||||
|
|
||||||
logger.Generatef("generating manifests")
|
if !installExport {
|
||||||
|
logger.Generatef("generating manifests")
|
||||||
|
}
|
||||||
if kustomizePath == "" {
|
if kustomizePath == "" {
|
||||||
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
|
err = genInstallManifests(installVersion, namespace, installComponents, tmpDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -104,6 +113,12 @@ func installCmdRun(cmd *cobra.Command, args []string) error {
|
|||||||
} else {
|
} else {
|
||||||
if verbose {
|
if verbose {
|
||||||
fmt.Print(yaml)
|
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")
|
logger.Successf("manifests build completed")
|
||||||
|
|||||||
@ -23,6 +23,9 @@ tk install [flags]
|
|||||||
# Dry-run install with manifests preview
|
# Dry-run install with manifests preview
|
||||||
tk install --dry-run --verbose
|
tk install --dry-run --verbose
|
||||||
|
|
||||||
|
# Write install manifests to file
|
||||||
|
tk install --export > gitops-system.yaml
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
@ -30,6 +33,7 @@ tk install [flags]
|
|||||||
```
|
```
|
||||||
--components strings list of components, accepts comma-separated values (default [source-controller,kustomize-controller,helm-controller,notification-controller])
|
--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
|
--dry-run only print the object that would be applied
|
||||||
|
--export write the install manifests to stdout and exit
|
||||||
-h, --help help for install
|
-h, --help help for install
|
||||||
--manifests string path to the manifest directory, dev only
|
--manifests string path to the manifest directory, dev only
|
||||||
-v, --version string toolkit tag or branch (default "master")
|
-v, --version string toolkit tag or branch (default "master")
|
||||||
|
|||||||
Reference in New Issue
Block a user