Example #1
0
func update(cmd *cobra.Command, args []string) error {
	// Get config from disk
	dmconf, err := ReadDeploymentConfig()
	if err != nil {
		return err
	}
	c := dmconf.Deployments[Name]

	depBuilder := &DeploymentBuilder{
		DeploymentName:  Name,
		DeploymentDesc:  "",
		ConfigFilePath:  c.Config,
		VarsDotYamlPath: c.Vars,
		CLIVars:         vars.vars,
	}

	d, err := depBuilder.GetDeployment()
	if err != nil {
		log.Warning(err)
		return err
	}

	//d.Intent = "UPDATE"
	existing, err := googlecloud.GetDeployment(c.Project, c.Id)
	if err != nil {
		return err
	}
	d.Fingerprint = existing.Fingerprint

	service, err := googlecloud.GetService()
	if err != nil {
		return err
	}
	log.Infof("Updating deployment %s", Name)
	_, err = service.Deployments.Update(Project, Name, d).Do()
	if err != nil {
		return err
	}
	fmt.Printf("Updated deployment %s.\n", Name)
	return nil
}
Example #2
0
File: ls.go Project: evandbrown/dm
func ls(cmd *cobra.Command, args []string) error {
	// Get config from disk
	config, _ := ReadDeploymentConfig()

	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 0, 8, 2, '\t', 0)
	fmt.Fprintln(w, "Deployment Name\tProject\tState\t")
	for _, c := range config.Deployments {
		d, err := googlecloud.GetDeployment(c.Project, c.Id)
		if err != nil {
			return err
		}
		status, err := getDeploymentStatus(d)
		if err != nil {
			return err
		}
		fmt.Fprintf(w, "%s\t%s\t%s\t\n", c.Id, c.Project, status)
	}
	w.Flush()
	return nil
}