Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Apply = cobra.Command{ Use: "apply", Short: "Apply the configuration to the local machine", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { cfg := GetConfig(cmd, args) files, commands, err := cfg.ApplyPhases() if err != nil { panic(err) } for path, file := range files { log.Infof("Writing %s\n", utils.LightGreenf(path)) perms, _ := strconv.Atoi(file.Permissions) if perms == 0 { perms = 0644 } content := []byte(file.Content) if file.Content == "" && file.ContentFromURL != "" { log.Infof("Downloading %s to path %s", file.ContentFromURL, path) resp, err := http.Get(file.ContentFromURL) if err != nil { log.Errorf("Failed to download from url %s: %v", file.ContentFromURL, err) continue } defer resp.Body.Close() c, err := ioutil.ReadAll(resp.Body) if err != nil { log.Errorf("Failed to read response body from url %s: %v", file.ContentFromURL, err) continue } content = c } ioutil.WriteFile(path, []byte(content), os.FileMode(perms)) } for _, cmd := range commands { log.Infof("Executing %s\n", utils.LightGreenf(cmd.Cmd)) if err := utils.Exec(cmd.Cmd); err != nil { log.Fatalf("Failed to run: %s, %s", cmd.Cmd, err) } } }, } )
View Source
var ( CloudInit = cobra.Command{ Use: "cloud-init", Short: "Exports the configuration in cloud-init format", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { cfg := GetConfig(cmd, args) var userdata string if base64, _ := cmd.Flags().GetBool("base64"); base64 { cfg.Extra.FileEncoding = "base64" userdata = cfg.ToCloudInit().String() } else { userdata = cfg.ToCloudInit().String() } if iso, _ := cmd.Flags().GetBool("iso"); iso { hostname, _ := cmd.Flags().GetString("hostname") path, err := cloudinit.CreateISO(hostname, userdata) if err != nil { log.Fatal(err) } fmt.Println(path) } else { fmt.Println(userdata) } }, } )
View Source
var IMAGE_CACHE string
View Source
var ( //Images command Images = cobra.Command{ Use: "images", PersistentPreRun: func(cmd *cobra.Command, args []string) { driverName, _ = cmd.Flags().GetString("driver") outputDir, _ = cmd.Flags().GetString("output-dir") outputFilename, _ = cmd.Flags().GetString("output-filename") outputFormat, _ = cmd.Flags().GetString("output-format") resize, _ = cmd.Flags().GetString("resize") image, _ = cmd.Flags().GetString("image") inline, _ = cmd.Flags().GetBool("inline") captureLogs, _ = cmd.Flags().GetString("capture-logs") imageVersion := "" if strings.Contains(image, ":") { imageVersion = strings.Split(image, ":")[1] image = strings.Split(image, ":")[0] } if val, ok := images[image]; ok { alias = &val alias.Version = imageVersion log.Infof("%s is an alias for %s", image, alias) image = alias.GetURL() } cfg = GetConfig(cmd, args) if driverName != "" { var ok bool if driver, ok = drivers[driverName]; !ok { log.Fatalf("Invalid driver name: %s ", driverName) } } cfg.Context.CaptureLogs = captureLogs }, } )
View Source
var ( Minify = cobra.Command{ Use: "minify", Short: "Resolve all lookups and dependencies and export a single config file", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { cfg := GetConfig(cmd, args) fs, commands, err := cfg.ApplyPhases() if err != nil { log.Fatalf("Error applying phases %s\n", err) } primitive, _ := cmd.Flags().GetBool("primitive") if primitive { data, _ := yaml.Marshal(map[string]interface{}{ "filesystem": fs, "commands": commands, }) fmt.Println(string(data)) } else { data, _ := yaml.Marshal(cfg) fmt.Println(string(data)) } }, } )
View Source
var ( //Verify command Verify = cobra.Command{ Use: "verify", Short: "Verify that the configuration has been applied correctly and is in a healthy state", Args: cobra.MinimumNArgs(0), Run: func(cmd *cobra.Command, args []string) { cfg := GetConfig(cmd, args) _, _, err := cfg.ApplyPhases() if err != nil { log.Error(err) } verifier := types.VerifyResults{} if !cfg.Verify(&verifier) { verifier.Done() os.Exit(1) } verifier.Done() }, } )
Functions ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.