本文整理汇总了Golang中github.com/catalyzeio/cli/commands/services.IServices.ListByEnvID方法的典型用法代码示例。如果您正苦于以下问题:Golang IServices.ListByEnvID方法的具体用法?Golang IServices.ListByEnvID怎么用?Golang IServices.ListByEnvID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/catalyzeio/cli/commands/services.IServices
的用法示例。
在下文中一共展示了IServices.ListByEnvID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: CmdStatus
func CmdStatus(envID string, is IStatus, ie environments.IEnvironments, iservices services.IServices) error {
env, err := ie.Retrieve(envID)
if err != nil {
return err
}
svcs, err := iservices.ListByEnvID(env.ID, env.Pod)
if err != nil {
return err
}
return is.Status(env, svcs)
}
示例2: CmdAssociate
func CmdAssociate(envLabel, svcLabel, alias, remote string, defaultEnv bool, ia IAssociate, ig git.IGit, ie environments.IEnvironments, is services.IServices) error {
if defaultEnv {
logrus.Warnln("The \"--default\" flag has been deprecated! It will be removed in a future version.")
}
if !ig.Exists() {
return errors.New("No git repo found in the current directory")
}
logrus.Printf("Existing git remotes named \"%s\" will be overwritten", remote)
envs, errs := ie.List()
if errs != nil && len(errs) > 0 {
for pod, err := range errs {
logrus.Debugf("Failed to list environments for pod \"%s\": %s", pod, err)
}
}
var e *models.Environment
var svcs *[]models.Service
var err error
for _, env := range *envs {
if env.Name == envLabel {
e = &env
svcs, err = is.ListByEnvID(env.ID, env.Pod)
if err != nil {
return err
}
break
}
}
if e == nil {
return fmt.Errorf("No environment with name \"%s\" found", envLabel)
}
if svcs == nil {
return fmt.Errorf("No services found for environment with name \"%s\"", envLabel)
}
var chosenService *models.Service
availableCodeServices := []string{}
for _, service := range *svcs {
if service.Type == "code" {
if service.Label == svcLabel {
chosenService = &service
break
}
availableCodeServices = append(availableCodeServices, service.Label)
}
}
if chosenService == nil {
return fmt.Errorf("No code service found with label \"%s\". Code services found: %s", svcLabel, strings.Join(availableCodeServices, ", "))
}
remotes, err := ig.List()
if err != nil {
return err
}
for _, r := range remotes {
if r == remote {
ig.Rm(remote)
break
}
}
err = ig.Add(remote, chosenService.Source)
if err != nil {
return err
}
logrus.Printf("\"%s\" remote added.", remote)
name := alias
if name == "" {
name = envLabel
}
err = ia.Associate(name, remote, defaultEnv, e, chosenService)
if err != nil {
return err
}
logrus.Printf("Your git repository \"%s\" has been associated with code service \"%s\" and environment \"%s\"", remote, svcLabel, name)
logrus.Println("After associating to an environment, you need to add a cert with the \"catalyze certs create\" command, if you have not done so already")
return nil
}