github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/cmd/gen-crds/main.go (about) 1 package main 2 3 import ( 4 "flag" 5 "path/filepath" 6 7 "github.com/caos/orbos/mntr" 8 "github.com/caos/orbos/pkg/kubernetes" 9 ) 10 11 const ( 12 crdFolder = "crds" 13 ) 14 15 func main() { 16 var basePath string 17 var boilerplatePath string 18 var kubeconfig string 19 flag.StringVar(&kubeconfig, "kubeconfig", "", "If kubeconfig is provided, crds will get applied") 20 flag.StringVar(&basePath, "basepath", "./artifacts", "The local path where the base folder should be") 21 flag.StringVar(&boilerplatePath, "boilerplatepath", "./hack/boilerplate.go.txt", "The local path where the boilerplate text file lies") 22 flag.Parse() 23 24 if kubeconfig != "" { 25 k8sClient, err := kubernetes.NewK8sClientPathBeforeInCluster(mntr.Monitor{}, kubeconfig) 26 if err != nil { 27 panic(err) 28 } 29 30 if k8sClient != nil { 31 if err := kubernetes.ApplyCRDs(boilerplatePath, "./...", k8sClient); err != nil { 32 panic(err) 33 } 34 } 35 } else { 36 if err := kubernetes.WriteCRDs(boilerplatePath, "./...", filepath.Join(basePath, crdFolder)); err != nil { 37 panic(err) 38 } 39 } 40 }