ListDeployments implements drivers.AdminService.
(ctx context.Context)
| 96 | |
| 97 | // ListDeployments implements drivers.AdminService. |
| 98 | func (l *localAdminService) ListDeployments(ctx context.Context) ([]*drivers.Deployment, error) { |
| 99 | if l.ch.AdminToken() == "" { |
| 100 | return nil, drivers.ErrNotAuthenticated |
| 101 | } |
| 102 | |
| 103 | client, err := l.ch.Client() |
| 104 | if err != nil { |
| 105 | return nil, err |
| 106 | } |
| 107 | |
| 108 | projects, err := l.ch.InferProjects(ctx, l.ch.Org, l.root) |
| 109 | if err != nil { |
| 110 | if errors.Is(err, cmdutil.ErrInferProjectFailed) { |
| 111 | // Succeed with an empty list |
| 112 | return nil, nil |
| 113 | } |
| 114 | return nil, err |
| 115 | } |
| 116 | project := projects[0] // InferProjects always returns at least one project in case of no error |
| 117 | |
| 118 | resp, err := client.ListDeployments(ctx, &adminv1.ListDeploymentsRequest{ |
| 119 | Org: project.OrgName, |
| 120 | Project: project.Name, |
| 121 | }) |
| 122 | if err != nil { |
| 123 | return nil, err |
| 124 | } |
| 125 | |
| 126 | res := make([]*drivers.Deployment, 0, len(resp.Deployments)) |
| 127 | for _, d := range resp.Deployments { |
| 128 | res = append(res, &drivers.Deployment{ |
| 129 | Branch: d.Branch, |
| 130 | }) |
| 131 | } |
| 132 | |
| 133 | return res, nil |
| 134 | } |
| 135 | |
| 136 | // UpdateProjectVariables implements drivers.AdminService. |
| 137 | func (l *localAdminService) UpdateProjectVariables(ctx context.Context, environment string, variables map[string]string) error { |
nothing calls this directly
no test coverage detected