Пример #1
0
func cmdListEnv(cmd *cobra.Command, args []string) {
	var applicationName string

	switch len(args) {
	case 0:
		applicationName = internal.GetUserName()
	case 1:
		applicationName = args[0]
	default:
		fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application env list --help")
		return
	}

	internal.FormatOutputDef(internal.GetWantJSON(fmt.Sprintf("/applications/%s/env", applicationName)))
}
Пример #2
0
func cmdDelEnv(cmd *cobra.Command, args []string) {
	var applicationName string
	var key string

	switch len(args) {
	case 1:
		applicationName = internal.GetUserName()
		key = args[0]
	case 2:
		applicationName = args[0]
		key = args[1]
	default:
		fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application env set --help")
		return
	}

	internal.FormatOutputDef(internal.DeleteWantJSON(fmt.Sprintf("/applications/%s/env/%s", applicationName, key)))
}
Пример #3
0
func cmdSetEnv(cmd *cobra.Command, args []string) {
	var cmdEnvBody env
	var applicationName string
	var parsedData []string

	switch len(args) {
	case 1:
		applicationName = internal.GetUserName()
		parsedData = strings.SplitN(args[0], "=", 2)
	case 2:
		applicationName = args[0]
		parsedData = strings.SplitN(args[1], "=", 2)
	default:
		fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application env set --help")
		return
	}

	cmdEnvBody.Data = parsedData[1]
	jsonStr, err := json.Marshal(cmdEnvBody)
	internal.Check(err)
	internal.FormatOutputDef(internal.PostBodyWantJSON(fmt.Sprintf("/applications/%s/env/%s", applicationName, parsedData[0]), jsonStr))
}
Пример #4
0
}

var cmdApplicationWebhookList = &cobra.Command{
	Use:     "list",
	Aliases: []string{"ls"},
	Short:   "List the webhooks of an app: sail application webhook list [<applicationName>]",
	Long: `List the webhooks of an app: sail application webhook list [<applicationName>]
example:
	sail application webhook list
	sail application webhook list my-app
	`,
	Run: func(cmd *cobra.Command, args []string) {
		var applicationName string
		switch len(args) {
		case 0:
			applicationName = internal.GetUserName()
		case 1:
			applicationName = args[0]
		default:
			fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application webhook list --help")
			return
		}
		// Sanity
		err := internal.CheckName(applicationName)
		internal.Check(err)

		internal.FormatOutputDef(internal.GetWantJSON(fmt.Sprintf("/applications/%s/hook", applicationName)))
	},
}

var cmdApplicationWebhookAdd = &cobra.Command{