Example #1
0
func webhookAdd(namespace, webhookURL string) {

	path := fmt.Sprintf("/applications/%s/hook", namespace)

	rawBody := webhookStruct{URL: webhookURL}
	body, err := json.MarshalIndent(rawBody, " ", " ")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Fatal: %s\n", err)
		return
	}
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))
}
Example #2
0
File: add.go Project: bewiwi/sail
func networkAdd(networkID string, args networkAddStruct) {
	t := strings.Split(networkID, "/")
	if len(t) != 2 {
		fmt.Fprintln(os.Stderr, "Invalid usage. sail network add <applicationName>/<networkId>. Please see sail network add --help")
		return
	}

	body, err := json.Marshal(args)
	internal.Check(err)

	path := fmt.Sprintf("/applications/%s/networks/%s", t[0], t[1])
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))

}
Example #3
0
func sshKeyAdd(keyLine, keyName string) {
	path := "/user/keys"

	rawBody := sshkeyStruct{
		KeyLine: string(keyLine),
		KeyName: string(keyName),
	}
	body, err := json.MarshalIndent(rawBody, " ", " ")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Fatal: %s\n", err)
		return
	}

	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))
}
Example #4
0
func serviceDomainAttach(serviceID, domain, pattern, method string) {
	t := strings.Split(serviceID, "/")
	if len(t) != 2 {
		fmt.Fprintln(os.Stderr, usageDomainAttach)
		return
	}

	args := domainStruct{Pattern: pattern, Method: method}
	body, err := json.Marshal(args)
	internal.Check(err)

	path := fmt.Sprintf("/applications/%s/services/%s/attached-routes/%s", t[0], t[1], domain)
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))

}
Example #5
0
File: add.go Project: runabove/sail
func networkAdd(networkID string, args networkAddStruct) {
	// Split namespace and repository
	host, app, net, tag, err := internal.ParseResourceName(networkID)
	internal.Check(err)

	if !internal.CheckHostConsistent(host) {
		fmt.Fprintf(os.Stderr, "Error: Invalid Host %s for endpoint %s\n", host, internal.Host)
		os.Exit(1)
	} else if len(tag) > 0 {
		fmt.Fprintf(os.Stderr, "Error: Invalid network name. Please see sail network add --help\n")
		os.Exit(1)
	}

	body, err := json.Marshal(args)
	internal.Check(err)

	path := fmt.Sprintf("/applications/%s/networks/%s", app, net)
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))

}
Example #6
0
File: add.go Project: runabove/sail
func repositoryAdd(repositoryName string, args repositoryAddStruct) {
	// Split namespace and repository
	host, app, repo, tag, err := internal.ParseResourceName(repositoryName)
	internal.Check(err)

	if !internal.CheckHostConsistent(host) {
		fmt.Fprintf(os.Stderr, "Error: Invalid Host %s for endpoint %s\n", host, internal.Host)
		os.Exit(1)
	} else if len(tag) > 0 {
		fmt.Fprintf(os.Stderr, "Error: Invalid repository name. Please see sail repository add --help\n")
		os.Exit(1)
	}

	body, err := json.Marshal(args)
	internal.Check(err)

	path := fmt.Sprintf("/repositories/%s/%s", app, repo)
	internal.FormatOutputDef(internal.PostBodyWantJSON(path, body))

}
Example #7
0
File: env.go Project: 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))
}