Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var APIDocs = &cobra.Command{ Use: "api", Short: "Generate docs ", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { printAPIDocs(args) }, }
View Source
var Operator = &cobra.Command{
Use: "operator",
Short: "Start the kubernetes operator",
Run: run,
}
View Source
var Root = &cobra.Command{ Use: "canary-checker", PersistentPreRun: func(cmd *cobra.Command, args []string) { logger.UseZap(cmd.Flags()) }, }
View Source
var Run = &cobra.Command{ Use: "run <canary.yaml>", Short: "Execute checks and return", Run: func(cmd *cobra.Command, configFiles []string) { namespace, _ := cmd.Flags().GetString("namespace") junitFile, _ := cmd.Flags().GetString("junit-file") if len(configFiles) == 0 { log.Fatalln("Must specify at least one canary") } kommonsClient, err := pkg.NewKommonsClient() if err != nil { logger.Warnf("Failed to get kommons client, features that read kubernetes configs will fail: %v", err) } var results = []*pkg.CheckResult{} wg := sync.WaitGroup{} queue := make(chan []*pkg.CheckResult, 1) for _, configfile := range configFiles { logger.Infof("Checking %s", configfile) config, err := pkg.ParseConfig(configfile) if err != nil { logger.Errorf("Could not parse %s: %v", configfile, err) continue } if namespace != "" { config.Namespace = namespace } if config.Name == "" { config.Name = CleanupFilename(configfile) } wg.Add(1) go func() { queue <- checks.RunChecks(context.New(kommonsClient, *config)) wg.Done() }() } failed := 0 passed := 0 go func() { wg.Wait() close(queue) }() for item := range queue { for _, result := range item { if !result.Pass { failed++ } else { passed++ } results = append(results, result) } } if junitFile != "" { report := getJunitReport(results) err := ioutil.WriteFile(junitFile, []byte(report), 0755) if err != nil { logger.Fatalf("%d checks failed", failed) } } logger.Infof("%d passed, %d failed", passed, failed) if failed > 0 { os.Exit(1) } }, }
View Source
var Serve = &cobra.Command{ Use: "serve", Short: "Start a server to execute checks ", Run: func(cmd *cobra.Command, args []string) { canary, err := pkg.ParseConfig(configFile) if err != nil { logger.Fatalf("could not parse %s: %v", configFile, err) } if canary.Spec.Interval == 0 && canary.Spec.Schedule == "" { canary.Spec.Schedule = schedule } kommonsClient, err := pkg.NewKommonsClient() if err != nil { logger.Warnf("Failed to get kommons client, features that read kubernetes config will fail: %v", err) } cron := cron.New() cron.Start() for _, _c := range checks.All { c := _c if !checks.Checks(canary.Spec.GetAllChecks()).Includes(c) { continue } schedule := canary.Spec.Schedule cron.AddFunc(schedule, func() { go func() { for _, result := range checks.RunChecks(context.New(kommonsClient, *canary)) { if logPass && result.Pass || logFail && !result.Pass { logger.Infof(result.String()) } cache.AddCheck(*canary, result) metrics.Record(*canary, result) } }() }) } serve() }, }
Functions ¶
func CleanupFilename ¶ added in v0.33.0
func ParseDocumentationFrom ¶
ParseDocumentationFrom gets all types' documentation and returns them as an array. Each type is again represented as an array (we have to use arrays as we need to be sure for the order of the fields). This function returns fields and struct definitions that have no documentation as {name, ""}.
func ServerFlags ¶ added in v0.38.4
Types ¶
type Struct ¶
type Struct struct {
Name, Doc string
StructType *ast.StructType
DocType *doc.Type
Fields []StructField
}
type StructField ¶
func NewStructField ¶
func NewStructField(field *ast.Field) StructField
Click to show internal directories.
Click to hide internal directories.