當前位置: 首頁>>代碼示例>>Golang>>正文


Golang internal.ParseResourceName函數代碼示例

本文整理匯總了Golang中github.com/runabove/sail/internal.ParseResourceName函數的典型用法代碼示例。如果您正苦於以下問題:Golang ParseResourceName函數的具體用法?Golang ParseResourceName怎麽用?Golang ParseResourceName使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ParseResourceName函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: serviceDomainDetach

func serviceDomainDetach(serviceID, domain string, args domainStruct) {
	// Split namespace and service
	host, app, service, tag, err := internal.ParseResourceName(serviceID)
	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 service name. Please see sail service domain detach --help\n")
		os.Exit(1)
	}

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

	// Sanity checks
	err = internal.CheckName(domain)
	internal.Check(err)

	path := fmt.Sprintf("/applications/%s/services/%s/attached-routes/%s", app, service, domain)
	data := internal.DeleteBodyWantJSON(path, body)

	internal.FormatOutput(data, func(data []byte) {
		fmt.Fprintf(os.Stderr, "Detached route %s %s%s from service %s/%s\n", args.Method, domain, args.Pattern, app, service)
	})
}
開發者ID:runabove,項目名稱:sail,代碼行數:27,代碼來源:detach.go

示例2: networkShow

func networkShow(networkID string) {
	// 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 show --help\n")
		os.Exit(1)
	}

	var network map[string]interface{}
	var ranges []string

	b := internal.ReqWant("GET", http.StatusOK, fmt.Sprintf("/applications/%s/networks/%s", app, net), nil)
	internal.Check(json.Unmarshal(b, &network))

	brange := internal.ReqWant("GET", http.StatusOK, fmt.Sprintf("/applications/%s/networks/%s/ranges", app, net), nil)
	internal.Check(json.Unmarshal(brange, &ranges))

	network["range"] = ranges
	n, err := json.Marshal(network)
	internal.Check(err)

	internal.FormatOutputDef(n)
}
開發者ID:runabove,項目名稱:sail,代碼行數:28,代碼來源:show.go

示例3: cmdLogs

func cmdLogs(cmd *cobra.Command, args []string) {
	usage := "usage: sail containers logs [<applicationName>/]<containerId>"

	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, usage)
		os.Exit(1)
	}

	// Split namespace and container
	host, app, container, tag, err := internal.ParseResourceName(args[0])
	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 container name. Please see sail container logs --help\n")
		os.Exit(1)
	}

	// Get args
	logsBody.Application = app
	logsBody.Container = container
	containerLogs(logsBody)
}
開發者ID:Alkorin,項目名稱:sail,代碼行數:25,代碼來源:logs.go

示例4: cmdAdd

func cmdAdd(cmd *cobra.Command, args []string) {
	cmdAddBody.ContainerNetwork = make(map[string]map[string][]string)
	cmdAddBody.Links = make(map[string]string)
	cmdAddBody.ContainerPorts = make(map[string][]PortConfig)
	cmdAddBody.ContainerCommand = make([]string, 0)

	if len(args) < 2 {
		fmt.Fprintln(os.Stderr, cmdAddUsage)
		os.Exit(1)
	}

	// Split namespace and repository
	host, app, repo, tag, err := internal.ParseResourceName(args[0])
	internal.Check(err)
	cmdAddBody.Application = app
	cmdAddBody.Repository = repo
	cmdAddBody.RepositoryTag = tag

	if !internal.CheckHostConsistent(host) {
		fmt.Fprintf(os.Stderr, "Error: Invalid Host %s for endpoint %s\n", host, internal.Host)
		os.Exit(1)
	}

	// Service name
	if len(args) >= 2 {
		cmdAddBody.Service = args[1]
	} else {
		cmdAddBody.Service = cmdAddBody.Repository
	}

	serviceAdd(cmdAddBody)
}
開發者ID:mathieupassenaud,項目名稱:sail,代碼行數:32,代碼來源:add.go

示例5: serviceAttach

func serviceAttach(serviceID string) {
	// Split namespace and service
	host, app, service, _, err := internal.ParseResourceName(serviceID)
	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)
	}

	internal.StreamPrint("GET", fmt.Sprintf("/applications/%s/services/%s/attach", app, service), nil)
	internal.ExitAfterCtrlC()
}
開發者ID:runabove,項目名稱:sail,代碼行數:13,代碼來源:attach.go

示例6: containerAttach

func containerAttach(containerID string) {
	// Split namespace and container
	host, _, container, tag, err := internal.ParseResourceName(containerID)
	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 container name. Please see sail container attach --help\n")
		os.Exit(1)
	}

	internal.StreamPrint("GET", fmt.Sprintf("/containers/%s/attach", container), nil)
	internal.ExitAfterCtrlC()
}
開發者ID:runabove,項目名稱:sail,代碼行數:16,代碼來源:attach.go

示例7: cmdScale

func cmdScale(cmd *cobra.Command, args []string) {
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, scaleUsage)
		os.Exit(1)
	}

	// Split namespace and service
	host, app, service, _, err := internal.ParseResourceName(args[0])
	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)
	}

	serviceScale(app, service, scaleNumber, scaleDestroy, scaleBatch)
}
開發者ID:runabove,項目名稱:sail,代碼行數:17,代碼來源:scale.go

示例8: networkRangeAdd

func networkRangeAdd(networkID, ipFrom, ipTo string) {
	// 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 show --help\n")
		os.Exit(1)
	}

	path := fmt.Sprintf("/applications/%s/networks/%s/ranges/%s-%s", app, net, ipFrom, ipTo)
	internal.FormatOutputDef(internal.PostWantJSON(path))

}
開發者ID:runabove,項目名稱:sail,代碼行數:17,代碼來源:rangeAdd.go

示例9: cmdServiceDelete

func cmdServiceDelete(cmd *cobra.Command, args []string) {
	usage := "Invalid usage. sail service delete [<applicationName>/]<serviceId>"
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, usage)
		return
	}

	// Split namespace and service
	host, app, service, _, err := internal.ParseResourceName(args[0])
	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)
	}

	serviceDelete(app, service)
}
開發者ID:Alkorin,項目名稱:sail,代碼行數:18,代碼來源:delete.go

示例10: networkAdd

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))

}
開發者ID:runabove,項目名稱:sail,代碼行數:20,代碼來源:add.go

示例11: repositoryAdd

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))

}
開發者ID:runabove,項目名稱:sail,代碼行數:20,代碼來源:add.go

示例12: repositoryRemove

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)
	})
}
開發者ID:runabove,項目名稱:sail,代碼行數:20,代碼來源:delete.go

示例13: cmdLogs

func cmdLogs(cmd *cobra.Command, args []string) {
	usage := "Invalid usage. sail service logs [<applicationName>/]<serviceId>. Please see sail service logs --help\n"
	if len(args) != 1 {
		fmt.Fprintf(os.Stderr, usage)
		return
	}

	// Split namespace and service
	host, app, service, _, err := internal.ParseResourceName(args[0])
	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)
	}

	// Get args
	logsBody.Application = app
	logsBody.Service = service
	serviceLogs(logsBody)
}
開發者ID:runabove,項目名稱:sail,代碼行數:21,代碼來源:logs.go

示例14: cmdRedeploy

func cmdRedeploy(cmd *cobra.Command, args []string) {
	usage := "Invalid usage. sail service redeploy <applicationName>/<serviceId>. Please see sail service redeploy --help\n"
	if len(args) != 1 {
		fmt.Fprintf(os.Stderr, usage)
		return
	}

	// Split namespace and repository
	host, app, service, _, err := internal.ParseResourceName(args[0])
	internal.Check(err)
	redeployBody.Application = app
	redeployBody.Service = service

	if !internal.CheckHostConsistent(host) {
		fmt.Fprintf(os.Stderr, "Error: Invalid Host %s for endpoint %s\n", host, internal.Host)
		os.Exit(1)
	}

	// Redeploy
	serviceRedeploy(redeployBody)
}
開發者ID:bewiwi,項目名稱:sail,代碼行數:21,代碼來源:redeploy.go


注:本文中的github.com/runabove/sail/internal.ParseResourceName函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。