예제 #1
0
파일: main.go 프로젝트: tmaiaroto/discfg
func main() {
	// If not set for some reason, use us-east-1 by default.
	if discfgDBRegion == "" {
		discfgDBRegion = "us-east-1"
	}

	apex.HandleFunc(func(event json.RawMessage, ctx *apex.Context) (interface{}, error) {
		var m message

		if err := json.Unmarshal(event, &m); err != nil {
			return nil, err
		}

		options.Storage.AWS.Region = discfgDBRegion

		if m.Name != "" {
			options.CfgName = m.Name
		}

		resp := commands.DeleteCfg(options)

		return commands.FormatJSONValue(resp), nil
	})
}
예제 #2
0
파일: main.go 프로젝트: tmaiaroto/discfg
	Use:   "delete",
	Short: "delete config",
	Long:  `Deletes a discfg distributed configuration`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) > 0 {
			Options.CfgName = args[0]
			// Confirmation
			inputReader := bufio.NewReader(os.Stdin)
			cfgCmd.Print("Are you sure? [Y/n] ")
			input, _ := inputReader.ReadString('\n')
			if input != "Y\n" {
				DiscfgCmd.Println("Aborted")
				return
			}
		}
		resp := commands.DeleteCfg(Options)
		commands.Out(Options, resp)
	},
}
var updateCfgCmd = &cobra.Command{
	Use:   "update",
	Short: "update config storage settings",
	Long:  `Adjusts options for a config's storage engine`,
	Run: func(cmd *cobra.Command, args []string) {
		name := commands.GetDiscfgNameFromFile()
		Options.CfgName = name
		var settings map[string]interface{}

		switch len(args) {
		case 1:
			if err := json.Unmarshal([]byte(args[0]), &settings); err != nil {