-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
40 lines (34 loc) · 901 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"fmt"
"os"
"path/filepath"
"github.com/spf13/cobra"
"k8s.io/client-go/util/homedir"
)
var rootCmd = &cobra.Command{
Use: "nsg-updater",
Short: "Azure NSG utility",
Long: `Automates Azure NSG updates based on Kubernetes resources`,
Run: func(cmd *cobra.Command, args []string) {
controller := NewNsgController(
getK8sConfig(kubeconfig),
getAzureConfig(azureconfig),
getAzureCredential(),
)
controller.Run()
select {}
},
}
var kubeconfig string
var azureconfig string
func init() {
rootCmd.PersistentFlags().StringVar(&kubeconfig, "kubeconfig", filepath.Join(homedir.HomeDir(), ".kube", "config"), "Path to kubeconfig file")
rootCmd.PersistentFlags().StringVar(&azureconfig, "azureconfig", "/etc/kubernetes/azure.json", "Path to azure.json file")
}
func main() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}