1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
package api
import (
"context"
"net/url"
"gitlab.com/gitlab-org/cluster-integration/gitlab-agent/v16/internal/api"
"gitlab.com/gitlab-org/cluster-integration/gitlab-agent/v16/internal/gitlab"
)
const (
ProjectInfoApiPath = "/api/v4/internal/kubernetes/project_info"
ProjectIdQueryParam = "id"
)
func GetProjectInfo(ctx context.Context, client gitlab.ClientInterface, agentToken api.AgentToken, projectId string, opts ...gitlab.DoOption) (*api.ProjectInfo, error) {
response := &GetProjectInfoResponse{}
err := client.Do(ctx,
joinOpts(opts,
gitlab.WithPath(ProjectInfoApiPath),
gitlab.WithQuery(url.Values{
ProjectIdQueryParam: []string{projectId},
}),
gitlab.WithAgentToken(agentToken),
gitlab.WithResponseHandler(gitlab.ProtoJsonResponseHandler(response)),
gitlab.WithJWT(true),
)...,
)
if err != nil {
return nil, err
}
return response.ToApiProjectInfo(), nil
}
|