Example #1
0
	Long:    `Update a template with new parameters for people to use to build images from`,
	Run: func(cmd *cobra.Command, args []string) {
		if templateUpdateID == "" {
			fmt.Println("You need to specify a name with --id in order to update a template")
			os.Exit(-3)
		}

		params := api.TemplateParams{}
		res, err := api.TemplateFind(templateUpdateID)
		if err != nil {
			errorColor := color.New(color.FgRed, color.Bold).SprintFunc()
			fmt.Println(errorColor("An error occured:"), err.Error())
			return
		}
		params.ID = res.Path("id").Data().(string)
		params.Name = res.Path("name").Data().(string)
		params.ImageID = res.Path("image_id").Data().(string)
		params.ShortDescription = res.Path("short_description").Data().(string)
		params.Description = res.Path("description").Data().(string)
		params.CloudConfig = res.Path("cloud_config").Data().(string)

		if templateUpdateName != "" {
			params.Name = templateUpdateName
		}
		if templateUpdateImageId != "" {
			params.ImageID = templateUpdateImageId
		}
		if templateUpdateShortDescription != "" {
			params.ShortDescription = templateUpdateShortDescription
		}
		if templateUpdateDescription != "" {