Initial commit

This commit is contained in:
Alexis Vanier
2020-01-09 17:06:03 -05:00
committed by Alexis Vanier
commit ebbf79ce68
23 changed files with 1443 additions and 0 deletions

47
cmd/root.go Normal file
View File

@@ -0,0 +1,47 @@
package cmd
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
action string
cfgFile string
verbose bool
inputFile string
showVersion bool
)
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "gitea-resource",
Short: "Do things with Gitea from Concourse",
}
// Execute adds all child commands to the root command and sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().StringVarP(&action, "action", "a", "check", "Concourse resource action to perform. May be check, in, or out.")
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Prints out debug messages.")
rootCmd.PersistentFlags().BoolVarP(&showVersion, "version", "V", false, "Prints the version and exit.")
rootCmd.PersistentFlags().StringVarP(&inputFile, "file", "F", "", "Consume input from file instead of stdin")
}
// initConfig reads in config file and ENV variables if set.
func initConfig() {
viper.AutomaticEnv() // read in environment variables that match
}