Add export flag to create commands

pull/31/head
stefanprodan 5 years ago
parent f5b738198f
commit 1bc637a43f

@ -13,9 +13,11 @@ var createCmd = &cobra.Command{
var (
interval time.Duration
export bool
)
func init() {
createCmd.PersistentFlags().DurationVarP(&interval, "interval", "", time.Minute, "source sync interval")
createCmd.PersistentFlags().BoolVar(&export, "export", false, "export in yaml format to stdout")
rootCmd.AddCommand(createCmd)
}

@ -3,11 +3,9 @@ package main
import (
"context"
"fmt"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1"
"strings"
"time"
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
@ -15,6 +13,9 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"sigs.k8s.io/controller-runtime/pkg/client"
kustomizev1 "github.com/fluxcd/kustomize-controller/api/v1alpha1"
sourcev1 "github.com/fluxcd/source-controller/api/v1alpha1"
)
var createKsCmd = &cobra.Command{
@ -106,7 +107,9 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
return err
}
logGenerate("generating kustomization")
if !export {
logGenerate("generating kustomization")
}
emptyAPIGroup := ""
kustomization := kustomizev1.Kustomization{
@ -171,6 +174,10 @@ func createKsCmdRun(cmd *cobra.Command, args []string) error {
}
}
if export {
return exportKs(kustomization)
}
logAction("applying kustomization")
if err := upsertKustomization(ctx, kubeClient, kustomization); err != nil {
return err

Loading…
Cancel
Save