Skip to content

Commit

Permalink
testing moving to using packages per sommand set
Browse files Browse the repository at this point in the history
  • Loading branch information
dilerous committed Jun 21, 2024
1 parent 8099f33 commit c501099
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 6 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified cmd/.DS_Store
Binary file not shown.
40 changes: 40 additions & 0 deletions cmd/backup/bucket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright © 2024 NAME HERE [email protected]
*/
package backup

import (
"log"

"github.com/dilerous/cnvrgctl/cmd"
"github.com/spf13/cobra"
)

// bucketCmd represents the bucket command
var bucketCmd = &cobra.Command{
Use: "bucket",
Short: "Backup the S3 bucket",
Long: `The command will backup the bucket used to host the files and
datasets in the cnvrg environment. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
log.Println("bucket called")
},
}

func init() {
cmd.RootCmd.AddCommand(bucketCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// bucketCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// bucketCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
42 changes: 42 additions & 0 deletions cmd/backup/database.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package backup

import (
"fmt"

"github.com/dilerous/cnvrgctl/cmd"
"github.com/spf13/cobra"
)

// databaseCmd represents the database command
var databaseCmd = &cobra.Command{
Use: "database",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("database called")

// cmd.ConnectToK8s
},
}

func init() {
cmd.RootCmd.AddCommand(databaseCmd)

// Here you will define your flags and configuration settings.

// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// databaseCmd.PersistentFlags().String("foo", "", "A help for foo")

// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// databaseCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}
14 changes: 8 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ var (
// rootCmd represents the base command when called without any subcommands
var RootCmd = &cobra.Command{
Use: "cnvrgctl",
Short: "A brief description of your application",
Long: `A longer description that spans multiple lines and likely contains
examples and usage of using your application. For example:
Short: "cnvrg.io delivery tool for cnvrg deployment maintenance",
Long: `cnvrg.io cli tool used to backup, migrate and install cnvrg.io. The tool
can be used to migrate exisiting deployments or install new cnvrg classic.
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
Examples:
# Backups the default postgres database and files in the cnvrg namespace.
cnvrgctl migrate restore postgres -n cnvrg`,
// Uncomment the following line if your bare application
// has an action associated with it:
// Run: func(cmd *cobra.Command, args []string) { },
Expand Down Expand Up @@ -76,6 +77,7 @@ func init() {
err := setLogger()
if err != nil {
fmt.Fprintln(os.Stderr, "error configuring the logger.")
log.Printf("error configuring the logger. %v ", err)
}
}

Expand Down
1 change: 1 addition & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright © 2024 Brad Soper [email protected]
package main

import (
_ "github.com/dilerous/cnvrgctl/backup"

Check failure on line 7 in main.go

View workflow job for this annotation

GitHub Actions / build

no required module provides package github.com/dilerous/cnvrgctl/backup; to add it:
"github.com/dilerous/cnvrgctl/cmd"
)

Expand Down

0 comments on commit c501099

Please sign in to comment.