示例#1
0
文件: apply.go 项目: vektorlab/otter
		stateMap, err := state.StateMapFromYamlPath(GetStatePath(cmd.Flag("state")))
		if err != nil {
			return err
		}
		if cmd.Flag("local").Changed {
			DumpResults(stateMap.Apply())
			return nil
		} else {
			client, err := clients.NewOtterClient(GetEtcdUrls(cmd.Flag("etcd")))
			if err != nil {
				return err
			}
			data, err := stateMap.ToJson()
			if err != nil {
				return err
			}
			client.SubmitState(string(data))
			resultMap, err := client.SubmitCommands("*", "apply")
			if err != nil {
				return err
			}
			DumpResults(resultMap)
		}
		return nil
	},
}

func init() {
	RootCmd.AddCommand(applyCmd)
}
示例#2
0
文件: state.go 项目: vektorlab/otter
		stateMap, err := state.StateMapFromYamlPath(GetStatePath(cmd.Flag("state")))
		if err != nil {
			return err
		}
		if cmd.Flag("local").Changed {
			DumpResults(stateMap.State())
			return nil
		} else {
			client, err := clients.NewOtterClient(GetEtcdUrls(cmd.Flag("etcd")))
			data, err := stateMap.ToJson()
			if err != nil {
				return err
			}
			client.SubmitState(string(data))
			if err != nil {
				return err
			}
			resultMap, err := client.SubmitCommands("*", "state")
			if err != nil {
				return err
			}
			DumpResults(resultMap)
		}
		return nil
	},
}

func init() {
	RootCmd.AddCommand(stateCmd)
}