-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f83c2a
commit 0fb3b78
Showing
3 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/voxpupuli/webhook-go/config" | ||
) | ||
|
||
var cfgFile string | ||
|
||
var version = "0.0.0" | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "webhook-go", | ||
Version: version, | ||
Short: "API Server for providing r10k/g10k as a web service", | ||
Long: `Provides an API service that parses git-based webhook | ||
requests, executing r10k deployments based on the payload and | ||
API endpoint.`, | ||
} | ||
|
||
func Execute() { | ||
if err := rootCmd.Execute(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
} | ||
|
||
func init() { | ||
cobra.OnInitialize(initConfig) | ||
|
||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is ./webhook.yml)") | ||
} | ||
|
||
func initConfig() { | ||
if cfgFile != "" { | ||
config.Init(&cfgFile) | ||
} else { | ||
config.Init(nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
Copyright © 2022 NAME HERE <EMAIL ADDRESS> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/voxpupuli/webhook-go/server" | ||
) | ||
|
||
// serverCmd represents the server command | ||
var serverCmd = &cobra.Command{ | ||
Use: "server", | ||
Short: "Start the Webhook-go server", | ||
Long: ``, | ||
Run: startServer, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(serverCmd) | ||
|
||
// Here you will define your flags and configuration settings. | ||
|
||
// Cobra supports Persistent Flags which will work for this command | ||
// and all subcommands, e.g.: | ||
// serverCmd.PersistentFlags().String("foo", "", "A help for foo") | ||
|
||
// Cobra supports local flags which will only run when this command | ||
// is called directly, e.g.: | ||
// serverCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") | ||
} | ||
|
||
func startServer(cmd *cobra.Command, args []string) { | ||
server.Init() | ||
} |