Exemplo n.º 1
0
func repositoryRemove(repositoryID string) {
	t := strings.Split(repositoryID, "/")
	if len(t) != 2 {
		fmt.Fprintln(os.Stderr, "Invalid usage. sail repository delete <applicationName>/<repositoryId>. Please see sail repository delete --help")
		return
	}

	path := fmt.Sprintf("/repositories/%s/%s", t[0], t[1])
	internal.FormatOutputDef(internal.DeleteWantJSON(path))
}
Exemplo n.º 2
0
func networkRemove(networkID string) {
	t := strings.Split(networkID, "/")
	if len(t) != 2 {
		fmt.Fprintln(os.Stderr, "Invalid usage. sail network delete <applicationName>/<networkId>. Please see sail network delete --help")
		return
	}

	path := fmt.Sprintf("/applications/%s/networks/%s", t[0], t[1])
	internal.FormatOutputDef(internal.DeleteWantJSON(path))
}
Exemplo n.º 3
0
func webhookDelete(namespace, webhookURL string) {
	urlEscape := url.QueryEscape(webhookURL)

	path := fmt.Sprintf("/applications/%s/hook", namespace)
	// pass urlEscape as query string argument
	BaseURL, err := url.Parse(path)
	internal.Check(err)

	params := url.Values{}
	params.Add("url", urlEscape)

	BaseURL.RawQuery = params.Encode()
	internal.FormatOutputDef(internal.DeleteWantJSON(BaseURL.String()))
}
Exemplo n.º 4
0
Arquivo: token.go Projeto: bewiwi/sail
func cmdRevoke(cmd *cobra.Command, args []string) {
	usage := "Invalid usage. sail metric token revoke <applicationName> <token>. Please see sail metric token revoke --help\n"
	if len(args) != 2 {
		fmt.Fprintf(os.Stderr, usage)
		return
	}

	// Get args
	application := args[0]
	token := args[1]

	path := fmt.Sprintf("/applications/%s/metrics/token/%s", application, token)
	internal.FormatOutputDef(internal.DeleteWantJSON(path))
}
Exemplo n.º 5
0
func sshKeyDelete(fingerprint string) {
	urlEscape := url.QueryEscape(fingerprint)

	path := "/user/keys"

	// pass urlEscape as query string argument
	BaseURL, err := url.Parse(path)
	internal.Check(err)

	params := url.Values{}
	params.Add("fingerprint", urlEscape)

	BaseURL.RawQuery = params.Encode()
	internal.FormatOutputDef(internal.DeleteWantJSON(BaseURL.String()))
}
Exemplo n.º 6
0
Arquivo: env.go Projeto: 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)))
}
Exemplo n.º 7
0
func repositoryRemove(repositoryID string) {
	// Split namespace and repository
	host, app, repo, tag, err := internal.ParseResourceName(repositoryID)
	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 delete --help\n")
		os.Exit(1)
	}

	path := fmt.Sprintf("/repositories/%s/%s", app, repo)
	data := internal.DeleteWantJSON(path)

	internal.FormatOutput(data, func(data []byte) {
		fmt.Fprintf(os.Stderr, "Deleted repository %s/%s\n", app, repo)
	})
}
Exemplo n.º 8
0
var cmdApplicationDomainDetach = &cobra.Command{
	Use:     "detach",
	Short:   "Detach a domain from the HTTP load balancer: sail application domain detach <applicationName> <domainName>",
	Aliases: []string{"add"},
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) != 2 {
			fmt.Fprintln(os.Stderr, "Invalid usage. Please see sail application domain attach --help")
		} else {
			// Sanity
			err := internal.CheckName(args[0])
			internal.Check(err)
			err = internal.CheckName(args[1])
			internal.Check(err)

			path := fmt.Sprintf("/applications/%s/attached-domains/%s", args[0], args[1])
			data := internal.DeleteWantJSON(path)

			internal.FormatOutput(data, func(data []byte) {
				fmt.Fprintf(os.Stderr, "Detached domain %s from application %s\n", args[1], args[0])
			})
		}
	},
}

func domainList(app string) {
	var apps []string

	// TODO: rewrite whithout the n+1... (needs API)
	if len(app) > 0 {
		apps = append(apps, app)
	} else {