Ejemplo n.º 1
0
Archivo: env.go Proyecto: runabove/sail
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)))
}
Ejemplo n.º 2
0
Archivo: env.go Proyecto: runabove/sail
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)))
}
Ejemplo n.º 3
0
Archivo: env.go Proyecto: runabove/sail
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))
}
Ejemplo n.º 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{