Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hihilla committed Jan 21, 2021
1 parent 5ceac1b commit 304abe4
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ build-all: $(foreach os,$(OS),build/shipperctl.$(os)-amd64.tar.gz) build/sha256s
build:
mkdir -p build

build/shipper-state-metrics.%-amd64: $(PKG) cmd/shipper-state-metrics/*
build/shipper-state-metrics.%-amd64: $(PKG) cmd/shipper-state-metrics/*
GOOS=$* GOARCH=amd64 go build $(LDFLAGS) -o build/shipper-state-metrics.$*-amd64 cmd/shipper-state-metrics/*.go

build/shipper.%-amd64: $(PKG) cmd/shipper/*
Expand Down
24 changes: 12 additions & 12 deletions cmd/shipperctl/cmd/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var (
managementClusterContext string
verboseFlag bool

BackupCmd = &cobra.Command{
Cmd = &cobra.Command{
Use: "backup",
Short: "Backup and restore Shipper applications and releases",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -49,23 +49,23 @@ func init() {
kubeConfigFlagName := "kubeconfig"
fileFlagName := "file"

config.RegisterFlag(BackupCmd.PersistentFlags(), &kubeConfigFile)
if err := BackupCmd.MarkPersistentFlagFilename(kubeConfigFlagName, "yaml"); err != nil {
BackupCmd.Printf("warning: could not mark %q for filename autocompletion: %s\n", kubeConfigFlagName, err)
config.RegisterFlag(Cmd.PersistentFlags(), &kubeConfigFile)
if err := Cmd.MarkPersistentFlagFilename(kubeConfigFlagName, "yaml"); err != nil {
Cmd.Printf("warning: could not mark %q for filename autocompletion: %s\n", kubeConfigFlagName, err)
}

BackupCmd.PersistentFlags().StringVar(&managementClusterContext, "management-cluster-context", "", "The name of the context to use to communicate with the management cluster. defaults to the current one")
BackupCmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "Prints the list of backup items")
BackupCmd.PersistentFlags().StringVar(&outputFormat, "format", "yaml", "Output format. One of: json|yaml")
Cmd.PersistentFlags().StringVar(&managementClusterContext, "management-cluster-context", "", "The name of the context to use to communicate with the management cluster. defaults to the current one")
Cmd.PersistentFlags().BoolVarP(&verboseFlag, "verbose", "v", false, "Prints the list of backup items")
Cmd.PersistentFlags().StringVar(&outputFormat, "format", "yaml", "Output format. One of: json|yaml")

BackupCmd.PersistentFlags().StringVarP(&backupFile, fileFlagName, "f", "backup.yaml", "The path to a backup file")
err := BackupCmd.MarkPersistentFlagFilename(fileFlagName, "yaml")
Cmd.PersistentFlags().StringVarP(&backupFile, fileFlagName, "f", "backup.yaml", "The path to a backup file")
err := Cmd.MarkPersistentFlagFilename(fileFlagName, "yaml")
if err != nil {
BackupCmd.Printf("warning: could not mark %q for filename yaml autocompletion: %s\n", fileFlagName, err)
Cmd.Printf("warning: could not mark %q for filename yaml autocompletion: %s\n", fileFlagName, err)
}
err = BackupCmd.MarkPersistentFlagFilename(fileFlagName, "json")
err = Cmd.MarkPersistentFlagFilename(fileFlagName, "json")
if err != nil {
BackupCmd.Printf("warning: could not mark %q for filename json autocompletion: %s\n", fileFlagName, err)
Cmd.Printf("warning: could not mark %q for filename json autocompletion: %s\n", fileFlagName, err)
}
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/shipperctl/cmd/backup/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
)

func init() {
BackupCmd.AddCommand(prepareBackupCmd)
Cmd.AddCommand(prepareBackupCmd)
}

func runPrepareCommand(cmd *cobra.Command, args []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/shipperctl/cmd/backup/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var (
)

func init() {
BackupCmd.AddCommand(restoreBackupCmd)
Cmd.AddCommand(restoreBackupCmd)
}

func runRestoreCommand(cmd *cobra.Command, args []string) error {
Expand Down
4 changes: 2 additions & 2 deletions cmd/shipperctl/cmd/chart/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ func renderChartFromApp(cmd *cobra.Command, args []string) error {
}
var application shipper.Application
if appName != "" {
applicationP, err := shipperClient.ShipperV1alpha1().Applications(namespace).Get(appName, metav1.GetOptions{})
applicationPointer, err := shipperClient.ShipperV1alpha1().Applications(namespace).Get(appName, metav1.GetOptions{})
if err != nil {
return err
}
application = *applicationP
application = *applicationPointer
} else {
appYaml, err := ioutil.ReadFile(fileName)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions cmd/shipperctl/cmd/clean/decommission.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
kubeConfigFile string
managementClusterContext string

CleanCmd = &cobra.Command{
Cmd = &cobra.Command{
Use: "clean",
Short: "clean Shipper objects",
}
Expand All @@ -52,19 +52,19 @@ type releaseAndFilteredAnnotations struct {

func init() {
// Flags common to all commands under `shipperctl clean`
config.RegisterFlag(CleanCmd.PersistentFlags(), &kubeConfigFile)
if err := CleanCmd.MarkPersistentFlagFilename(kubeConfigFlagName, "yaml"); err != nil {
CleanCmd.Printf("warning: could not mark %q for filename autocompletion: %s\n", kubeConfigFlagName, err)
config.RegisterFlag(Cmd.PersistentFlags(), &kubeConfigFile)
if err := Cmd.MarkPersistentFlagFilename(kubeConfigFlagName, "yaml"); err != nil {
Cmd.Printf("warning: could not mark %q for filename autocompletion: %s\n", kubeConfigFlagName, err)
}

CleanCmd.PersistentFlags().BoolVar(&dryrun, "dryrun", false, "If true, only prints the objects that will be modified/deleted")
CleanCmd.PersistentFlags().StringVar(&managementClusterContext, "management-cluster-context", "", "The name of the context to use to communicate with the management cluster. defaults to the current one")
CleanCmd.PersistentFlags().StringSliceVar(&clusters, decommissionedClustersFlagName, clusters, "List of decommissioned clusters. (Required)")
if err := CleanCmd.MarkPersistentFlagRequired(decommissionedClustersFlagName); err != nil {
CleanCmd.Printf("warning: could not mark %q as required: %s\n", decommissionedClustersFlagName, err)
Cmd.PersistentFlags().BoolVar(&dryrun, "dryrun", false, "If true, only prints the objects that will be modified/deleted")
Cmd.PersistentFlags().StringVar(&managementClusterContext, "management-cluster-context", "", "The name of the context to use to communicate with the management cluster. defaults to the current one")
Cmd.PersistentFlags().StringSliceVar(&clusters, decommissionedClustersFlagName, clusters, "List of decommissioned clusters. (Required)")
if err := Cmd.MarkPersistentFlagRequired(decommissionedClustersFlagName); err != nil {
Cmd.Printf("warning: could not mark %q as required: %s\n", decommissionedClustersFlagName, err)
}

CleanCmd.AddCommand(cleanDeadClustersCmd)
Cmd.AddCommand(cleanDeadClustersCmd)
}

func runCleanCommand(cmd *cobra.Command, args []string) error {
Expand Down
6 changes: 3 additions & 3 deletions cmd/shipperctl/cmd/clusters/clusters.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ var (
RunE: runJoinClustersCommand,
}

ClustersCmd = &cobra.Command{
Cmd = &cobra.Command{
Use: "clusters",
Short: "manage Shipper clusters",
}
Expand Down Expand Up @@ -97,8 +97,8 @@ func init() {

setupCmd.AddCommand(setupMgmtCmd)

ClustersCmd.AddCommand(setupCmd)
ClustersCmd.AddCommand(joinCmd)
Cmd.AddCommand(setupCmd)
Cmd.AddCommand(joinCmd)
}

func runSetupMgmtClusterCommand(cmd *cobra.Command, args []string) error {
Expand Down
18 changes: 9 additions & 9 deletions cmd/shipperctl/cmd/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var (
kubeConfigFile string
managementClusterContext string

ListCmd = &cobra.Command{
Cmd = &cobra.Command{
Use: "list",
Short: "lists Shipper releases that are scheduled *only* on given clusters",
PersistentPreRun: func(cmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -64,17 +64,17 @@ type outputRelease struct {

func init() {
// Flags common to all commands under `shipperctl count`
config.RegisterFlag(ListCmd.PersistentFlags(), &kubeConfigFile)
if err := ListCmd.MarkPersistentFlagFilename(kubeConfigFlagName, "yaml"); err != nil {
ListCmd.Printf("warning: could not mark %q for filename autocompletion: %s\n", kubeConfigFlagName, err)
config.RegisterFlag(Cmd.PersistentFlags(), &kubeConfigFile)
if err := Cmd.MarkPersistentFlagFilename(kubeConfigFlagName, "yaml"); err != nil {
Cmd.Printf("warning: could not mark %q for filename autocompletion: %s\n", kubeConfigFlagName, err)
}

ListCmd.PersistentFlags().StringVar(&managementClusterContext, "management-cluster-context", "", "The name of the context to use to communicate with the management cluster. defaults to the current one")
ListCmd.PersistentFlags().StringSliceVar(&clusters, clustersFlagName, clusters, "List of comma separated clusters to list releases that are scheduled *only* on those clusters. If empty, will list without filtering")
ListCmd.PersistentFlags().StringVarP(&printOption, "output", "o", "", "Output format. One of: json|yaml. (Optional) defaults to verbose")
Cmd.PersistentFlags().StringVar(&managementClusterContext, "management-cluster-context", "", "The name of the context to use to communicate with the management cluster. defaults to the current one")
Cmd.PersistentFlags().StringSliceVar(&clusters, clustersFlagName, clusters, "List of comma separated clusters to list releases that are scheduled *only* on those clusters. If empty, will list without filtering")
Cmd.PersistentFlags().StringVarP(&printOption, "output", "o", "", "Output format. One of: json|yaml. (Optional) defaults to verbose")

ListCmd.AddCommand(countContendersCmd)
ListCmd.AddCommand(countReleasesCmd)
Cmd.AddCommand(countContendersCmd)
Cmd.AddCommand(countReleasesCmd)
for _, command := range []*cobra.Command{countContendersCmd, countReleasesCmd} {
command.SetOutput(os.Stdout)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/shipperctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ var rootCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(clusters.ClustersCmd)
rootCmd.AddCommand(list.ListCmd)
rootCmd.AddCommand(clean.CleanCmd)
rootCmd.AddCommand(backup.BackupCmd)
rootCmd.AddCommand(clusters.Cmd)
rootCmd.AddCommand(list.Cmd)
rootCmd.AddCommand(clean.Cmd)
rootCmd.AddCommand(backup.Cmd)
rootCmd.AddCommand(chart.Command)
}

Expand Down

0 comments on commit 304abe4

Please sign in to comment.