mirror of https://github.com/agola-io/agola
Compare commits
8 Commits
ba6c38cfe5
...
cf4197e886
| Author | SHA1 | Date |
|---|---|---|
|
|
cf4197e886 | |
|
|
80aa1f52d9 | |
|
|
0887406f1b | |
|
|
0c9f6169b5 | |
|
|
cccac861b8 | |
|
|
497839a0f9 | |
|
|
7612495ed1 | |
|
|
d071845770 |
|
|
@ -39,8 +39,8 @@ local task_build_go(version, arch) = {
|
|||
{ type: 'run', command: 'make' },
|
||||
{ type: 'save_cache', key: 'cache-sum-{{ md5sum "go.sum" }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] },
|
||||
{ type: 'save_cache', key: 'cache-date-{{ year }}-{{ month }}-{{ day }}', contents: [{ source_dir: '/go/pkg/mod/cache' }] },
|
||||
{ type: 'run', name: 'install golangci-lint', command: 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2' },
|
||||
{ type: 'run', command: 'golangci-lint run --deadline 5m' },
|
||||
{ type: 'run', name: 'install golangci-lint', command: 'curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.61.0' },
|
||||
{ type: 'run', command: 'golangci-lint run --timeout 10m' },
|
||||
{ type: 'run', name: 'build docker/k8s drivers tests binary', command: 'CGO_ENABLED=0 go test -c ./internal/services/executor/driver -o ./bin/docker-tests' },
|
||||
{ type: 'run', name: 'build integration tests binary', command: 'go test -tags "sqlite_unlock_notify" -c ./tests -o ./bin/integration-tests' },
|
||||
{ type: 'run', name: 'run tests (sqlite3)',
|
||||
|
|
@ -128,7 +128,7 @@ local task_build_push_images(name, target, push) =
|
|||
[
|
||||
task_build_go(version, arch),
|
||||
]
|
||||
for version in ['1.21', '1.22']
|
||||
for version in ['1.22', '1.23']
|
||||
for arch in ['amd64' /*, 'arm64' */]
|
||||
]) + [
|
||||
{
|
||||
|
|
@ -139,7 +139,7 @@ local task_build_push_images(name, target, push) =
|
|||
{ type: 'run', command: 'SKIP_K8S_TESTS=1 AGOLA_TOOLBOX_PATH="./bin" ./bin/docker-tests -test.parallel 5 -test.v' },
|
||||
],
|
||||
depends: [
|
||||
'build go 1.22 amd64',
|
||||
'build go 1.23 amd64',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
@ -162,7 +162,7 @@ local task_build_push_images(name, target, push) =
|
|||
{ type: 'run', name: 'integration tests', command: 'AGOLA_BIN_DIR="./bin" GITEA_PATH=${PWD}/bin/gitea DOCKER_BRIDGE_ADDRESS="172.18.0.1" ./bin/integration-tests -test.parallel 3 -test.v' },
|
||||
],
|
||||
depends: [
|
||||
'build go 1.22 amd64',
|
||||
'build go 1.23 amd64',
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ FROM $AGOLAWEB_IMAGE as agola-web
|
|||
#######
|
||||
|
||||
# base build image
|
||||
FROM golang:1.22-bookworm AS build_base
|
||||
FROM golang:1.23-bookworm AS build_base
|
||||
|
||||
WORKDIR /agola
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ func directRunStart(cmd *cobra.Command, args []string) error {
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
log.Info().Msgf("pushing branch")
|
||||
log.Info().Msg("pushing branch")
|
||||
repoPath := fmt.Sprintf("%s/%s", user.ID, repoUUID)
|
||||
repoURL := fmt.Sprintf("%s/repos/%s/%s.git", gatewayURL, user.ID, repoUUID)
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ func directRunStart(cmd *cobra.Command, args []string) error {
|
|||
}
|
||||
}
|
||||
|
||||
log.Info().Msgf("starting direct run")
|
||||
log.Info().Msg("starting direct run")
|
||||
req := &gwapitypes.UserCreateRunRequest{
|
||||
RepoUUID: repoUUID,
|
||||
RepoPath: repoPath,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ func logDelete(cmd *cobra.Command, args []string) error {
|
|||
taskid = task.ID
|
||||
}
|
||||
|
||||
log.Info().Msgf("deleting log")
|
||||
log.Info().Msg("deleting log")
|
||||
|
||||
var err error
|
||||
if isProject {
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ func logGet(cmd *cobra.Command, args []string) error {
|
|||
taskid = task.ID
|
||||
}
|
||||
|
||||
log.Info().Msgf("getting log")
|
||||
log.Info().Msg("getting log")
|
||||
|
||||
var resp *gwclient.Response
|
||||
var err error
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ func orgCreate(cmd *cobra.Command, args []string) error {
|
|||
Visibility: gwapitypes.Visibility(orgCreateOpts.visibility),
|
||||
}
|
||||
|
||||
log.Info().Msgf("creating org")
|
||||
log.Info().Msg("creating org")
|
||||
org, _, err := gwClient.CreateOrg(context.TODO(), req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create org")
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ func projectCreate(cmd *cobra.Command, args []string) error {
|
|||
PassVarsToForkedPR: projectCreateOpts.passVarsToForkedPR,
|
||||
}
|
||||
|
||||
log.Info().Msgf("creating project")
|
||||
log.Info().Msg("creating project")
|
||||
|
||||
project, _, err := gwClient.CreateProject(context.TODO(), req)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func init() {
|
|||
func projectDelete(cmd *cobra.Command, args []string) error {
|
||||
gwClient := gwclient.NewClient(gatewayURL, token)
|
||||
|
||||
log.Info().Msgf("deleting project")
|
||||
log.Info().Msg("deleting project")
|
||||
|
||||
if _, err := gwClient.DeleteProject(context.TODO(), projectDeleteOpts.ref); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete project")
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ func projectGroupCreate(cmd *cobra.Command, args []string) error {
|
|||
Visibility: gwapitypes.Visibility(projectGroupCreateOpts.visibility),
|
||||
}
|
||||
|
||||
log.Info().Msgf("creating project group")
|
||||
log.Info().Msg("creating project group")
|
||||
|
||||
projectGroup, _, err := gwClient.CreateProjectGroup(context.TODO(), req)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ func init() {
|
|||
func projectGroupDelete(cmd *cobra.Command, args []string) error {
|
||||
gwClient := gwclient.NewClient(gatewayURL, token)
|
||||
|
||||
log.Info().Msgf("deleting project group")
|
||||
log.Info().Msg("deleting project group")
|
||||
|
||||
if _, err := gwClient.DeleteProjectGroup(context.TODO(), projectGroupDeleteOpts.ref); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete project group")
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ func projectGroupUpdate(cmd *cobra.Command, args []string) error {
|
|||
req.Name = &projectGroupUpdateOpts.visibility
|
||||
}
|
||||
|
||||
log.Info().Msgf("updating project group")
|
||||
log.Info().Msg("updating project group")
|
||||
projectGroup, _, err := gwClient.UpdateProjectGroup(context.TODO(), projectGroupUpdateOpts.ref, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update project group")
|
||||
|
|
|
|||
|
|
@ -55,11 +55,11 @@ func init() {
|
|||
func projectReconfig(cmd *cobra.Command, args []string) error {
|
||||
gwClient := gwclient.NewClient(gatewayURL, token)
|
||||
|
||||
log.Info().Msgf("reconfiguring remote project")
|
||||
log.Info().Msg("reconfiguring remote project")
|
||||
if _, err := gwClient.ReconfigProject(context.TODO(), projectReconfigOpts.name); err != nil {
|
||||
return errors.Wrapf(err, "failed to reconfigure remote project")
|
||||
}
|
||||
log.Info().Msgf("project reconfigured")
|
||||
log.Info().Msg("project reconfigured")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,14 +103,14 @@ func secretCreate(cmd *cobra.Command, ownertype string, args []string) error {
|
|||
|
||||
switch ownertype {
|
||||
case "project":
|
||||
log.Info().Msgf("creating project secret")
|
||||
log.Info().Msg("creating project secret")
|
||||
secret, _, err := gwClient.CreateProjectSecret(context.TODO(), secretCreateOpts.parentRef, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create project secret")
|
||||
}
|
||||
log.Info().Msgf("project secret %q created, ID: %q", secret.Name, secret.ID)
|
||||
case "projectgroup":
|
||||
log.Info().Msgf("creating project group secret")
|
||||
log.Info().Msg("creating project group secret")
|
||||
secret, _, err := gwClient.CreateProjectGroupSecret(context.TODO(), secretCreateOpts.parentRef, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create project group secret")
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ func secretDelete(cmd *cobra.Command, ownertype string, args []string) error {
|
|||
|
||||
switch ownertype {
|
||||
case "project":
|
||||
log.Info().Msgf("deleting project secret")
|
||||
log.Info().Msg("deleting project secret")
|
||||
_, err := gwClient.DeleteProjectSecret(context.TODO(), secretDeleteOpts.parentRef, secretDeleteOpts.name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to delete project secret")
|
||||
}
|
||||
log.Info().Msgf("project secret deleted")
|
||||
log.Info().Msg("project secret deleted")
|
||||
case "projectgroup":
|
||||
log.Info().Msgf("deleting project group secret")
|
||||
log.Info().Msg("deleting project group secret")
|
||||
_, err := gwClient.DeleteProjectGroupSecret(context.TODO(), secretDeleteOpts.parentRef, secretDeleteOpts.name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to delete project group secret")
|
||||
}
|
||||
log.Info().Msgf("project group secret deleted")
|
||||
log.Info().Msg("project group secret deleted")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -110,14 +110,14 @@ func secretUpdate(cmd *cobra.Command, ownertype string, args []string) error {
|
|||
|
||||
switch ownertype {
|
||||
case "project":
|
||||
log.Info().Msgf("creating project secret")
|
||||
log.Info().Msg("creating project secret")
|
||||
secret, _, err := gwClient.UpdateProjectSecret(context.TODO(), secretUpdateOpts.parentRef, secretUpdateOpts.name, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update project secret")
|
||||
}
|
||||
log.Info().Msgf("project secret %q updated, ID: %q", secret.Name, secret.ID)
|
||||
case "projectgroup":
|
||||
log.Info().Msgf("creating project group secret")
|
||||
log.Info().Msg("creating project group secret")
|
||||
secret, _, err := gwClient.UpdateProjectGroupSecret(context.TODO(), secretUpdateOpts.parentRef, secretUpdateOpts.name, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update project group secret")
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ func projectUpdate(cmd *cobra.Command, args []string) error {
|
|||
req.PassVarsToForkedPR = &projectUpdateOpts.passVarsToForkedPR
|
||||
}
|
||||
|
||||
log.Info().Msgf("updating project")
|
||||
log.Info().Msg("updating project")
|
||||
project, _, err := gwClient.UpdateProject(context.TODO(), projectUpdateOpts.ref, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update project")
|
||||
|
|
|
|||
|
|
@ -133,14 +133,14 @@ func variableCreate(cmd *cobra.Command, ownertype string, args []string) error {
|
|||
|
||||
switch ownertype {
|
||||
case "project":
|
||||
log.Info().Msgf("creating project variable")
|
||||
log.Info().Msg("creating project variable")
|
||||
variable, _, err := gwClient.CreateProjectVariable(context.TODO(), variableCreateOpts.parentRef, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create project variable")
|
||||
}
|
||||
log.Info().Msgf("project variable %q created, ID: %q", variable.Name, variable.ID)
|
||||
case "projectgroup":
|
||||
log.Info().Msgf("creating project group variable")
|
||||
log.Info().Msg("creating project group variable")
|
||||
variable, _, err := gwClient.CreateProjectGroupVariable(context.TODO(), variableCreateOpts.parentRef, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create project group variable")
|
||||
|
|
|
|||
|
|
@ -62,19 +62,19 @@ func variableDelete(cmd *cobra.Command, ownertype string, args []string) error {
|
|||
|
||||
switch ownertype {
|
||||
case "project":
|
||||
log.Info().Msgf("deleting project variable")
|
||||
log.Info().Msg("deleting project variable")
|
||||
_, err := gwClient.DeleteProjectVariable(context.TODO(), variableDeleteOpts.parentRef, variableDeleteOpts.name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to delete project variable")
|
||||
}
|
||||
log.Info().Msgf("project variable deleted")
|
||||
log.Info().Msg("project variable deleted")
|
||||
case "projectgroup":
|
||||
log.Info().Msgf("deleting project group variable")
|
||||
log.Info().Msg("deleting project group variable")
|
||||
_, err := gwClient.DeleteProjectGroupVariable(context.TODO(), variableDeleteOpts.parentRef, variableDeleteOpts.name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to delete project group variable")
|
||||
}
|
||||
log.Info().Msgf("project group variable deleted")
|
||||
log.Info().Msg("project group variable deleted")
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -110,14 +110,14 @@ func variableUpdate(cmd *cobra.Command, ownertype string, args []string) error {
|
|||
|
||||
switch ownertype {
|
||||
case "project":
|
||||
log.Info().Msgf("updating project variable")
|
||||
log.Info().Msg("updating project variable")
|
||||
variable, _, err := gwClient.UpdateProjectVariable(context.TODO(), variableUpdateOpts.parentRef, variableUpdateOpts.name, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update project variable")
|
||||
}
|
||||
log.Info().Msgf("project variable %q updated, ID: %q", variable.Name, variable.ID)
|
||||
case "projectgroup":
|
||||
log.Info().Msgf("updating project group variable")
|
||||
log.Info().Msg("updating project group variable")
|
||||
variable, _, err := gwClient.UpdateProjectGroupVariable(context.TODO(), variableUpdateOpts.parentRef, variableUpdateOpts.name, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update project group variable")
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func remoteSourceCreate(cmd *cobra.Command, args []string) error {
|
|||
LoginEnabled: util.Ptr(remoteSourceCreateOpts.loginEnabled),
|
||||
}
|
||||
|
||||
log.Info().Msgf("creating remotesource")
|
||||
log.Info().Msg("creating remotesource")
|
||||
remoteSource, _, err := gwClient.CreateRemoteSource(context.TODO(), req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create remotesource")
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ func remoteSourceUpdate(cmd *cobra.Command, args []string) error {
|
|||
req.LoginEnabled = &remoteSourceUpdateOpts.loginEnabled
|
||||
}
|
||||
|
||||
log.Info().Msgf("updating remotesource")
|
||||
log.Info().Msg("updating remotesource")
|
||||
remoteSource, _, err := gwClient.UpdateRemoteSource(context.TODO(), remoteSourceUpdateOpts.ref, req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to update remotesource")
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ func userCreate(cmd *cobra.Command, args []string) error {
|
|||
UserName: userCreateOpts.username,
|
||||
}
|
||||
|
||||
log.Info().Msgf("creating user")
|
||||
log.Info().Msg("creating user")
|
||||
user, _, err := gwClient.CreateUser(context.TODO(), req)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to create user")
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -1,6 +1,6 @@
|
|||
module agola.io/agola
|
||||
|
||||
go 1.21
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
ariga.io/atlas v0.12.0
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ func (h *GitSmartHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
res, err := InfoRefsResponse(ctx, repoAbsPath, serviceName)
|
||||
if err != nil {
|
||||
// we cannot return any http error since the http header has already been written
|
||||
h.log.Err(err).Msgf("git command error")
|
||||
h.log.Err(err).Msg("git command error")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -220,14 +220,14 @@ func (h *GitSmartHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
if err := gitService(ctx, w, body, repoAbsPath, "upload-pack"); err != nil {
|
||||
// we cannot return any http error since the http header has already been written
|
||||
h.log.Err(err).Msgf("git command error")
|
||||
h.log.Err(err).Msg("git command error")
|
||||
}
|
||||
case RequestTypeReceivePack:
|
||||
w.Header().Set("Content-Type", "application/x-git-receive-pack-result")
|
||||
|
||||
if err := gitService(ctx, w, body, repoAbsPath, "receive-pack"); err != nil {
|
||||
// we cannot return any http error since the http header has already been written
|
||||
h.log.Err(err).Msgf("git command error")
|
||||
h.log.Err(err).Msg("git command error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -266,7 +266,7 @@ func (h *FetchFileHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if err := gitFetchFile(ctx, w, r.Body, repoAbsPath, fetchData.Ref, fetchData.Path); err != nil {
|
||||
h.log.Err(err).Msgf("git command error")
|
||||
h.log.Err(err).Msg("git command error")
|
||||
|
||||
// since we already answered with a 200 we cannot return another error code
|
||||
// So abort the connection and the client will detect the missing ending chunk
|
||||
|
|
|
|||
|
|
@ -212,40 +212,40 @@ func (s *GitSave) Save(message, branchName string) (string, error) {
|
|||
s.log.Info().Msgf("index %s does not exist", indexPath)
|
||||
}
|
||||
|
||||
s.log.Info().Msgf("updating files already in the index")
|
||||
s.log.Info().Msg("updating files already in the index")
|
||||
if err := gitUpdateFiles(tmpIndexPath); err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
|
||||
if s.conf.AddUntracked {
|
||||
s.log.Info().Msgf("adding untracked files")
|
||||
s.log.Info().Msg("adding untracked files")
|
||||
if err := gitAddUntrackedFiles(tmpIndexPath); err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
||||
if s.conf.AddIgnored {
|
||||
s.log.Info().Msgf("adding ignored files")
|
||||
s.log.Info().Msg("adding ignored files")
|
||||
if err := gitAddIgnoredFiles(tmpIndexPath); err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
||||
s.log.Info().Msgf("writing tree file")
|
||||
s.log.Info().Msg("writing tree file")
|
||||
treeSHA, err := gitWriteTree(tmpIndexPath)
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
s.log.Info().Msgf("tree: %s", treeSHA)
|
||||
|
||||
s.log.Info().Msgf("committing tree")
|
||||
s.log.Info().Msg("committing tree")
|
||||
commitSHA, err := gitCommitTree(message, treeSHA)
|
||||
if err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
s.log.Info().Msgf("commit: %s", commitSHA)
|
||||
|
||||
s.log.Info().Msgf("updating ref")
|
||||
s.log.Info().Msg("updating ref")
|
||||
if err = gitUpdateRef("git-save", filepath.Join(s.refsPrefix, branchName), commitSHA); err != nil {
|
||||
return "", errors.WithStack(err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ type ErrNotExist struct {
|
|||
|
||||
func NewErrNotExist(err error, format string, args ...interface{}) error {
|
||||
return &ErrNotExist{
|
||||
util.NewWrapperError(err, util.WithWrapperErrorMsg(format, args...)),
|
||||
util.NewWrapperError(err, util.WithWrapperErrorMsgf(format, args...)),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ func NewActionHandler(log zerolog.Logger, d *db.DB, lf lock.LockFactory) *Action
|
|||
func (h *ActionHandler) GetProjectGroupByPath(tx *sql.Tx, projectGroupPath string) (*types.ProjectGroup, error) {
|
||||
parts := strings.Split(projectGroupPath, "/")
|
||||
if len(parts) < 2 {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong project group path: %q", projectGroupPath), serrors.InvalidPath())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong project group path: %q", projectGroupPath), serrors.InvalidPath())
|
||||
}
|
||||
var parentID string
|
||||
switch parts[0] {
|
||||
|
|
@ -61,7 +61,7 @@ func (h *ActionHandler) GetProjectGroupByPath(tx *sql.Tx, projectGroupPath strin
|
|||
return nil, errors.Wrapf(err, "failed to get organization %q", parts[1])
|
||||
}
|
||||
if org == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("organization with name %q doesn't exist", parts[1]), serrors.OrganizationDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("organization with name %q doesn't exist", parts[1]), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
parentID = org.ID
|
||||
case "user":
|
||||
|
|
@ -70,11 +70,11 @@ func (h *ActionHandler) GetProjectGroupByPath(tx *sql.Tx, projectGroupPath strin
|
|||
return nil, errors.Wrapf(err, "failed to get user %q", parts[1])
|
||||
}
|
||||
if user == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user with name %q doesn't exist", parts[1]), serrors.UserDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user with name %q doesn't exist", parts[1]), serrors.UserDoesNotExist())
|
||||
}
|
||||
parentID = user.ID
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong project group path: %q", projectGroupPath), serrors.InvalidPath())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong project group path: %q", projectGroupPath), serrors.InvalidPath())
|
||||
}
|
||||
|
||||
var projectGroup *types.ProjectGroup
|
||||
|
|
@ -96,7 +96,7 @@ func (h *ActionHandler) GetProjectGroupByPath(tx *sql.Tx, projectGroupPath strin
|
|||
|
||||
func (h *ActionHandler) GetProjectByPath(tx *sql.Tx, projectPath string) (*types.Project, error) {
|
||||
if len(strings.Split(projectPath, "/")) < 3 {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong project path: %q", projectPath), serrors.InvalidPath())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong project path: %q", projectPath), serrors.InvalidPath())
|
||||
}
|
||||
|
||||
projectGroupPath := path.Dir(projectPath)
|
||||
|
|
@ -153,7 +153,7 @@ func (h *ActionHandler) GetProjectPath(tx *sql.Tx, project *types.Project) (stri
|
|||
return "", errors.WithStack(err)
|
||||
}
|
||||
if pgroup == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("parent project group %q for project %q doesn't exist", project.Parent.ID, project.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("parent project group %q for project %q doesn't exist", project.Parent.ID, project.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
p, err := h.GetProjectGroupPath(tx, pgroup)
|
||||
if err != nil {
|
||||
|
|
@ -168,7 +168,7 @@ func (h *ActionHandler) GetProjectPath(tx *sql.Tx, project *types.Project) (stri
|
|||
func (h *ActionHandler) GetProjectGroupByRef(tx *sql.Tx, projectGroupRef string) (*types.ProjectGroup, error) {
|
||||
groupRef, err := common.ParsePathRef(projectGroupRef)
|
||||
if err != nil {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong project group ref: %q", projectGroupRef), serrors.InvalidRef())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong project group ref: %q", projectGroupRef), serrors.InvalidRef())
|
||||
}
|
||||
|
||||
var group *types.ProjectGroup
|
||||
|
|
@ -184,7 +184,7 @@ func (h *ActionHandler) GetProjectGroupByRef(tx *sql.Tx, projectGroupRef string)
|
|||
func (h *ActionHandler) GetProjectByRef(tx *sql.Tx, projectRef string) (*types.Project, error) {
|
||||
projectRefType, err := common.ParsePathRef(projectRef)
|
||||
if err != nil {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong project ref: %q", projectRef), serrors.InvalidRef())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong project ref: %q", projectRef), serrors.InvalidRef())
|
||||
}
|
||||
|
||||
var project *types.Project
|
||||
|
|
@ -200,7 +200,7 @@ func (h *ActionHandler) GetProjectByRef(tx *sql.Tx, projectRef string) (*types.P
|
|||
func (h *ActionHandler) GetOrgByRef(tx *sql.Tx, orgRef string) (*types.Organization, error) {
|
||||
refType, err := common.ParseNameRef(orgRef)
|
||||
if err != nil {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong organization ref: %q", orgRef), serrors.InvalidRef())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong organization ref: %q", orgRef), serrors.InvalidRef())
|
||||
}
|
||||
|
||||
var org *types.Organization
|
||||
|
|
@ -216,7 +216,7 @@ func (h *ActionHandler) GetOrgByRef(tx *sql.Tx, orgRef string) (*types.Organizat
|
|||
func (h *ActionHandler) GetUserByRef(tx *sql.Tx, userRef string) (*types.User, error) {
|
||||
refType, err := common.ParseNameRef(userRef)
|
||||
if err != nil {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong user ref: %q", userRef), serrors.InvalidRef())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong user ref: %q", userRef), serrors.InvalidRef())
|
||||
}
|
||||
|
||||
var user *types.User
|
||||
|
|
@ -238,7 +238,7 @@ func (h *ActionHandler) GetPath(tx *sql.Tx, objectKind types.ObjectKind, id stri
|
|||
return "", errors.WithStack(err)
|
||||
}
|
||||
if projectGroup == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("projectgroup with id %q doesn't exist", id), serrors.ProjectGroupDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("projectgroup with id %q doesn't exist", id), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
p, err = h.GetProjectGroupPath(tx, projectGroup)
|
||||
if err != nil {
|
||||
|
|
@ -250,7 +250,7 @@ func (h *ActionHandler) GetPath(tx *sql.Tx, objectKind types.ObjectKind, id stri
|
|||
return "", errors.WithStack(err)
|
||||
}
|
||||
if project == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project with id %q doesn't exist", id), serrors.ProjectDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project with id %q doesn't exist", id), serrors.ProjectDoesNotExist())
|
||||
}
|
||||
p, err = h.GetProjectPath(tx, project)
|
||||
if err != nil {
|
||||
|
|
@ -262,7 +262,7 @@ func (h *ActionHandler) GetPath(tx *sql.Tx, objectKind types.ObjectKind, id stri
|
|||
return "", errors.Wrapf(err, "failed to get organization %q", id)
|
||||
}
|
||||
if org == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("organization with id %q doesn't exist", id), serrors.OrganizationDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("organization with id %q doesn't exist", id), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
p = path.Join("org", org.Name)
|
||||
case types.ObjectKindUser:
|
||||
|
|
@ -271,7 +271,7 @@ func (h *ActionHandler) GetPath(tx *sql.Tx, objectKind types.ObjectKind, id stri
|
|||
return "", errors.Wrapf(err, "failed to get user %q", id)
|
||||
}
|
||||
if user == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user with id %q doesn't exist", id), serrors.UserDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user with id %q doesn't exist", id), serrors.UserDoesNotExist())
|
||||
}
|
||||
p = path.Join("user", user.Name)
|
||||
default:
|
||||
|
|
@ -308,7 +308,7 @@ func (h *ActionHandler) GetProjectGroupHierarchy(tx *sql.Tx, projectGroup *types
|
|||
return nil, errors.Wrapf(err, "failed to get project group %q", projectGroupID)
|
||||
}
|
||||
if projectGroup == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group %q doesn't exist", projectGroupID), serrors.ProjectGroupDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group %q doesn't exist", projectGroupID), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
elements = append([]*hierarchyElement{
|
||||
{
|
||||
|
|
@ -342,7 +342,7 @@ func (h *ActionHandler) GetProjectOwnerID(tx *sql.Tx, project *types.Project) (t
|
|||
return "", "", errors.WithStack(err)
|
||||
}
|
||||
if pgroup == nil {
|
||||
return "", "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("parent project group %q for project %q doesn't exist", project.Parent.ID, project.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return "", "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("parent project group %q for project %q doesn't exist", project.Parent.ID, project.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
return h.GetProjectGroupOwnerID(tx, pgroup)
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ func (h *ActionHandler) ResolveObjectID(tx *sql.Tx, objectKind types.ObjectKind,
|
|||
return "", errors.WithStack(err)
|
||||
}
|
||||
if group == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group with ref %q doesn't exists", ref), serrors.ProjectGroupDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group with ref %q doesn't exists", ref), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
return group.ID, nil
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ func (h *ActionHandler) ResolveObjectID(tx *sql.Tx, objectKind types.ObjectKind,
|
|||
return "", errors.WithStack(err)
|
||||
}
|
||||
if project == nil {
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project with ref %q doesn't exists", ref), serrors.ProjectDoesNotExist())
|
||||
return "", util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project with ref %q doesn't exists", ref), serrors.ProjectDoesNotExist())
|
||||
}
|
||||
return project.ID, nil
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func (h *ActionHandler) GetOrgMembers(ctx context.Context, req *GetOrgMembersReq
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exist", req.OrgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exist", req.OrgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
dbOrgMembers, err = h.d.GetOrgMembers(tx, org.ID, req.StartUserName, limit, req.SortDirection)
|
||||
|
|
@ -111,7 +111,7 @@ func (h *ActionHandler) GetOrg(ctx context.Context, orgRef string) (*types.Organ
|
|||
}
|
||||
|
||||
if org == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
return org, nil
|
||||
|
|
@ -181,7 +181,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*
|
|||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("organization name required"), serrors.InvalidOrganizationName())
|
||||
}
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid organization name %q", req.Name), serrors.InvalidOrganizationName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid organization name %q", req.Name), serrors.InvalidOrganizationName())
|
||||
}
|
||||
if !types.IsValidVisibility(req.Visibility) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid organization visibility"), serrors.InvalidVisibility())
|
||||
|
|
@ -196,7 +196,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if o != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("org %q already exists", o.Name), serrors.OrganizationAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("org %q already exists", o.Name), serrors.OrganizationAlreadyExists())
|
||||
}
|
||||
|
||||
if req.CreatorUserID != "" {
|
||||
|
|
@ -205,7 +205,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("creator user %q doesn't exist", req.CreatorUserID), serrors.CreatorUserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("creator user %q doesn't exist", req.CreatorUserID), serrors.CreatorUserDoesNotExist())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ func (h *ActionHandler) UpdateOrg(ctx context.Context, orgRef string, req *Updat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q not exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q not exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
org.Visibility = req.Visibility
|
||||
|
|
@ -299,7 +299,7 @@ func (h *ActionHandler) DeleteOrg(ctx context.Context, orgRef string) error {
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteOrgMembersByOrgID(tx, org.ID); err != nil {
|
||||
|
|
@ -351,7 +351,7 @@ func (h *ActionHandler) DeleteOrg(ctx context.Context, orgRef string) error {
|
|||
// TODO(sgotti) handle invitation when implemented
|
||||
func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string, role types.MemberRole) (*types.OrganizationMember, error) {
|
||||
if !types.IsValidMemberRole(role) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid role %q", role), serrors.InvalidRole())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid role %q", role), serrors.InvalidRole())
|
||||
}
|
||||
|
||||
var orgmember *types.OrganizationMember
|
||||
|
|
@ -362,7 +362,7 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
// check existing user
|
||||
user, err := h.GetUserByRef(tx, userRef)
|
||||
|
|
@ -370,7 +370,7 @@ func (h *ActionHandler) AddOrgMember(ctx context.Context, orgRef, userRef string
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
// fetch org member if it already exist
|
||||
|
|
@ -426,7 +426,7 @@ func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef str
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
// check existing user
|
||||
user, err := h.GetUserByRef(tx, userRef)
|
||||
|
|
@ -434,7 +434,7 @@ func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef str
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
// check that org member exists
|
||||
|
|
@ -443,7 +443,7 @@ func (h *ActionHandler) RemoveOrgMember(ctx context.Context, orgRef, userRef str
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if orgmember == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("orgmember for org %q, user %q doesn't exists", orgRef, userRef), serrors.OrgMemberDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("orgmember for org %q, user %q doesn't exists", orgRef, userRef), serrors.OrgMemberDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteOrganizationMember(tx, orgmember.ID); err != nil {
|
||||
|
|
@ -467,7 +467,7 @@ func (h *ActionHandler) GetOrgInvitations(ctx context.Context, orgRef string) ([
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
orgInvitations, err = h.d.GetOrgInvitations(tx, org.ID)
|
||||
|
|
@ -493,7 +493,7 @@ func (h *ActionHandler) GetOrgInvitationByUserRef(ctx context.Context, orgRef, u
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("organization %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("organization %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
// check existing user
|
||||
user, err := h.GetUserByRef(tx, userRef)
|
||||
|
|
@ -501,7 +501,7 @@ func (h *ActionHandler) GetOrgInvitationByUserRef(ctx context.Context, orgRef, u
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
orgInvitation, err = h.d.GetOrgInvitationByOrgUserID(tx, org.ID, user.ID)
|
||||
|
|
@ -516,7 +516,7 @@ func (h *ActionHandler) GetOrgInvitationByUserRef(ctx context.Context, orgRef, u
|
|||
}
|
||||
|
||||
if orgInvitation == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("invitation for org %q user %q doesn't exist", orgRef, userRef), serrors.InvitationDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("invitation for org %q user %q doesn't exist", orgRef, userRef), serrors.InvitationDoesNotExist())
|
||||
}
|
||||
|
||||
return orgInvitation, nil
|
||||
|
|
@ -548,7 +548,7 @@ func (h *ActionHandler) CreateOrgInvitation(ctx context.Context, req *CreateOrgI
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("organization %q doesn't exist", req.OrganizationRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("organization %q doesn't exist", req.OrganizationRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
user, err := h.GetUserByRef(tx, req.UserRef)
|
||||
|
|
@ -556,7 +556,7 @@ func (h *ActionHandler) CreateOrgInvitation(ctx context.Context, req *CreateOrgI
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
// check duplicate org invitation
|
||||
|
|
@ -593,7 +593,7 @@ func (h *ActionHandler) DeleteOrgInvitation(ctx context.Context, orgRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exists", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
// check existing user
|
||||
user, err := h.GetUserByRef(tx, userRef)
|
||||
|
|
@ -601,7 +601,7 @@ func (h *ActionHandler) DeleteOrgInvitation(ctx context.Context, orgRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exists", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
// check org invitation exists
|
||||
|
|
@ -610,7 +610,7 @@ func (h *ActionHandler) DeleteOrgInvitation(ctx context.Context, orgRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if orgInvitation == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("invitation for org %q, user %q doesn't exists", orgRef, userRef), serrors.InvitationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("invitation for org %q, user %q doesn't exists", orgRef, userRef), serrors.InvitationDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteOrgInvitation(tx, orgInvitation.ID); err != nil {
|
||||
|
|
@ -643,7 +643,7 @@ func (h *ActionHandler) OrgInvitationAction(ctx context.Context, req *OrgInvitat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exists", req.OrgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exists", req.OrgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
// check existing user
|
||||
user, err := h.GetUserByRef(tx, req.UserRef)
|
||||
|
|
@ -651,7 +651,7 @@ func (h *ActionHandler) OrgInvitationAction(ctx context.Context, req *OrgInvitat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exists", req.UserRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exists", req.UserRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
// check org invitation exists
|
||||
|
|
@ -660,7 +660,7 @@ func (h *ActionHandler) OrgInvitationAction(ctx context.Context, req *OrgInvitat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if orgInvitation == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("invitation for org %q, user %q doesn't exists", req.OrgRef, req.UserRef), serrors.InvitationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("invitation for org %q, user %q doesn't exists", req.OrgRef, req.UserRef), serrors.InvitationDoesNotExist())
|
||||
}
|
||||
|
||||
if req.Action == csapitypes.Accept {
|
||||
|
|
|
|||
|
|
@ -70,19 +70,19 @@ func (h *ActionHandler) ValidateProjectReq(ctx context.Context, req *CreateUpdat
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project name required"), serrors.InvalidProjectName())
|
||||
}
|
||||
if !util.ValidateName(req.Name) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project name %q", req.Name), serrors.InvalidProjectName())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid project name %q", req.Name), serrors.InvalidProjectName())
|
||||
}
|
||||
if req.Parent.ID == "" {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project parent id required"))
|
||||
}
|
||||
if req.Parent.Kind != types.ObjectKindProjectGroup {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project parent kind %q", req.Parent.Kind))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid project parent kind %q", req.Parent.Kind))
|
||||
}
|
||||
if !types.IsValidVisibility(req.Visibility) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project visibility"))
|
||||
}
|
||||
if !types.IsValidRemoteRepositoryConfigType(req.RemoteRepositoryConfigType) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project remote repository config type %q", req.RemoteRepositoryConfigType))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid project remote repository config type %q", req.RemoteRepositoryConfigType))
|
||||
}
|
||||
if req.RemoteRepositoryConfigType == types.RemoteRepositoryConfigTypeRemoteSource {
|
||||
if req.RemoteSourceID == "" {
|
||||
|
|
@ -118,7 +118,7 @@ func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*Get
|
|||
}
|
||||
|
||||
if project == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project %q doesn't exist", projectRef), serrors.ProjectDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project %q doesn't exist", projectRef), serrors.ProjectDoesNotExist())
|
||||
}
|
||||
|
||||
projectDynamicData, err = h.projectDynamicData(tx, project)
|
||||
|
|
@ -166,7 +166,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateUpdateProj
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if group == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("parent project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("parent project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
req.Parent.ID = group.ID
|
||||
|
||||
|
|
@ -190,7 +190,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateUpdateProj
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if p != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", p.Name, pp), serrors.ProjectAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", p.Name, pp), serrors.ProjectAlreadyExists())
|
||||
}
|
||||
|
||||
if req.RemoteRepositoryConfigType == types.RemoteRepositoryConfigTypeRemoteSource {
|
||||
|
|
@ -199,7 +199,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateUpdateProj
|
|||
return errors.Wrapf(err, "failed to get user with linked account id %q", req.LinkedAccountID)
|
||||
}
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account id %q doesn't exist", req.LinkedAccountID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account id %q doesn't exist", req.LinkedAccountID))
|
||||
}
|
||||
|
||||
user, err := h.d.GetUserByID(tx, la.UserID)
|
||||
|
|
@ -207,12 +207,12 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateUpdateProj
|
|||
return errors.Wrapf(err, "failed to get user with linked account id %q", req.LinkedAccountID)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user for linked account %q doesn't exist", req.LinkedAccountID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user for linked account %q doesn't exist", req.LinkedAccountID))
|
||||
}
|
||||
|
||||
// check that the linked account matches the remote source
|
||||
if la.RemoteSourceID != req.RemoteSourceID {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account id %q remote source %q different than project remote source %q", req.LinkedAccountID, la.RemoteSourceID, req.RemoteSourceID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account id %q remote source %q different than project remote source %q", req.LinkedAccountID, la.RemoteSourceID, req.RemoteSourceID))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -269,7 +269,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if project == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project with ref %q doesn't exist", curProjectRef), serrors.ProjectDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project with ref %q doesn't exist", curProjectRef), serrors.ProjectDoesNotExist())
|
||||
}
|
||||
|
||||
// check parent project group exists
|
||||
|
|
@ -278,7 +278,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if group == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("parent project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("parent project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
req.Parent.ID = group.ID
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if ap != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", req.Name, pp), serrors.ProjectAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", req.Name, pp), serrors.ProjectAlreadyExists())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +314,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if curGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("parent project group with id %q doesn't exist", project.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("parent project group with id %q doesn't exist", project.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -324,7 +324,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
|
|||
return errors.Wrapf(err, "failed to get user with linked account id %q", req.LinkedAccountID)
|
||||
}
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account id %q doesn't exist", req.LinkedAccountID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account id %q doesn't exist", req.LinkedAccountID))
|
||||
}
|
||||
|
||||
user, err := h.d.GetUserByID(tx, la.UserID)
|
||||
|
|
@ -332,12 +332,12 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, curProjectRef string,
|
|||
return errors.Wrapf(err, "failed to get user with linked account id %q", req.LinkedAccountID)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user for linked account %q doesn't exist", req.LinkedAccountID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user for linked account %q doesn't exist", req.LinkedAccountID))
|
||||
}
|
||||
|
||||
// check that the linked account matches the remote source
|
||||
if la.RemoteSourceID != req.RemoteSourceID {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account id %q remote source %q different than project remote source %q", req.LinkedAccountID, la.RemoteSourceID, req.RemoteSourceID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account id %q remote source %q different than project remote source %q", req.LinkedAccountID, la.RemoteSourceID, req.RemoteSourceID))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ func (h *ActionHandler) DeleteProject(ctx context.Context, projectRef string) er
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if project == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project %q doesn't exist", projectRef), serrors.ProjectDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project %q doesn't exist", projectRef), serrors.ProjectDoesNotExist())
|
||||
}
|
||||
|
||||
// TODO(sgotti) implement childs garbage collection
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func (h *ActionHandler) GetProjectGroup(ctx context.Context, projectGroupRef str
|
|||
}
|
||||
|
||||
if projectGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
|
||||
projectGroupDynamicData, err = h.projectGroupDynamicData(tx, projectGroup)
|
||||
|
|
@ -114,7 +114,7 @@ func (h *ActionHandler) GetProjectGroupSubgroups(ctx context.Context, projectGro
|
|||
}
|
||||
|
||||
if projectGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
|
||||
projectGroups, err = h.d.GetProjectGroupSubgroups(tx, projectGroup.ID)
|
||||
|
|
@ -158,7 +158,7 @@ func (h *ActionHandler) GetProjectGroupProjects(ctx context.Context, projectGrou
|
|||
}
|
||||
|
||||
if projectGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
|
||||
projects, err = h.d.GetProjectGroupProjects(tx, projectGroup.ID)
|
||||
|
|
@ -190,7 +190,7 @@ func (h *ActionHandler) ValidateProjectGroupReq(ctx context.Context, req *Create
|
|||
if req.Parent.Kind != types.ObjectKindProjectGroup &&
|
||||
req.Parent.Kind != types.ObjectKindOrg &&
|
||||
req.Parent.Kind != types.ObjectKindUser {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project group parent kind %q", req.Parent.Kind))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid project group parent kind %q", req.Parent.Kind))
|
||||
}
|
||||
if req.Parent.ID == "" {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project group parent id required"))
|
||||
|
|
@ -230,7 +230,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateUpdat
|
|||
|
||||
// We cannot create a root project group for org/user since it's created on user/org creation
|
||||
if req.Parent.Kind != types.ObjectKindProjectGroup {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong project group parent kind %q", req.Parent.Kind))
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong project group parent kind %q", req.Parent.Kind))
|
||||
}
|
||||
|
||||
var projectGroup *types.ProjectGroup
|
||||
|
|
@ -241,7 +241,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateUpdat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if parentProjectGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
// TODO(sgotti) now we are doing a very ugly thing setting the request
|
||||
// projectgroup parent ID that can be both an ID or a ref. Then we are fixing
|
||||
|
|
@ -260,7 +260,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateUpdat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if tpg != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project group with name %q, path %q already exists", req.Name, pp), serrors.ProjectGroupAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project group with name %q, path %q already exists", req.Name, pp), serrors.ProjectGroupAlreadyExists())
|
||||
}
|
||||
|
||||
projectGroup = types.NewProjectGroup(tx)
|
||||
|
|
@ -301,7 +301,7 @@ func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, curProjectGroupR
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if projectGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group with ref %q doesn't exist", curProjectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group with ref %q doesn't exist", curProjectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
|
||||
if projectGroup.Parent.Kind != req.Parent.Kind {
|
||||
|
|
@ -326,7 +326,7 @@ func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, curProjectGroupR
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if group == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("parent project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("parent project group with id %q doesn't exist", req.Parent.ID), serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
// TODO(sgotti) now we are doing a very ugly thing setting the request
|
||||
// projectgroup parent ID that can be both an ID or a ref. Then we are fixing
|
||||
|
|
@ -353,7 +353,7 @@ func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, curProjectGroupR
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if ap != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project group with name %q, path %q already exists", req.Name, pgp), serrors.ProjectGroupAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project group with name %q, path %q already exists", req.Name, pgp), serrors.ProjectGroupAlreadyExists())
|
||||
}
|
||||
// Cannot move inside itself or a child project group
|
||||
if strings.HasPrefix(pgp, curPGP+"/") {
|
||||
|
|
@ -392,7 +392,7 @@ func (h *ActionHandler) DeleteProjectGroup(ctx context.Context, projectGroupRef
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if projectGroup == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
|
||||
// cannot delete root project group
|
||||
|
|
@ -424,7 +424,7 @@ func (h *ActionHandler) getAllProjectGroupSubgroups(tx *sql.Tx, projectGroupRef
|
|||
}
|
||||
|
||||
if projectGroup == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("project group %q doesn't exist", projectGroupRef), serrors.ProjectGroupDoesNotExist())
|
||||
}
|
||||
|
||||
projectGroups, err := h.d.GetProjectGroupSubgroups(tx, projectGroup.ID)
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ func (h *ActionHandler) GetRemoteSource(ctx context.Context, remoteSourceRef str
|
|||
}
|
||||
|
||||
if remoteSource == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("remotesource %q doesn't exist", remoteSourceRef), serrors.RemoteSourceDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("remotesource %q doesn't exist", remoteSourceRef), serrors.RemoteSourceDoesNotExist())
|
||||
}
|
||||
|
||||
return remoteSource, nil
|
||||
|
|
@ -94,7 +94,7 @@ func (h *ActionHandler) ValidateRemoteSourceReq(ctx context.Context, req *Create
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource name required"), serrors.InvalidRemoteSourceName())
|
||||
}
|
||||
if !util.ValidateName(req.Name) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid remotesource name %q", req.Name), serrors.InvalidRemoteSourceName())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid remotesource name %q", req.Name), serrors.InvalidRemoteSourceName())
|
||||
}
|
||||
|
||||
if req.APIURL == "" {
|
||||
|
|
@ -109,14 +109,14 @@ func (h *ActionHandler) ValidateRemoteSourceReq(ctx context.Context, req *Create
|
|||
|
||||
// validate if the remotesource type supports the required auth type
|
||||
if !types.SourceSupportsAuthType(types.RemoteSourceType(req.Type), types.RemoteSourceAuthType(req.AuthType)) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType), serrors.InvalidRemoteSourceAuthType())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType), serrors.InvalidRemoteSourceAuthType())
|
||||
}
|
||||
if req.AuthType == types.RemoteSourceAuthTypeOauth2 {
|
||||
if req.Oauth2ClientID == "" {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource oauth2clientid required for auth type %q", types.RemoteSourceAuthTypeOauth2), serrors.InvalidOauth2ClientID())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("remotesource oauth2clientid required for auth type %q", types.RemoteSourceAuthTypeOauth2), serrors.InvalidOauth2ClientID())
|
||||
}
|
||||
if req.Oauth2ClientSecret == "" {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource oauth2clientsecret required for auth type %q", types.RemoteSourceAuthTypeOauth2), serrors.InvalidOauth2ClientSecret())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("remotesource oauth2clientsecret required for auth type %q", types.RemoteSourceAuthTypeOauth2), serrors.InvalidOauth2ClientSecret())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateUpdat
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if curRemoteSource != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource %q already exists", req.Name), serrors.RemoteSourceAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("remotesource %q already exists", req.Name), serrors.RemoteSourceAlreadyExists())
|
||||
}
|
||||
|
||||
remoteSource = types.NewRemoteSource(tx)
|
||||
|
|
@ -194,7 +194,7 @@ func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, remoteSourceRef
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if remoteSource == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("remotesource with ref %q doesn't exist", remoteSourceRef), serrors.RemoteSourceDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("remotesource with ref %q doesn't exist", remoteSourceRef), serrors.RemoteSourceDoesNotExist())
|
||||
}
|
||||
|
||||
if remoteSource.Name != req.Name {
|
||||
|
|
@ -204,7 +204,7 @@ func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, remoteSourceRef
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if u != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource %q already exists", u.Name), serrors.RemoteSourceAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("remotesource %q already exists", u.Name), serrors.RemoteSourceAlreadyExists())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +241,7 @@ func (h *ActionHandler) DeleteRemoteSource(ctx context.Context, remoteSourceName
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if remoteSource == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("remotesource %q doesn't exist", remoteSourceName), serrors.RemoteSourceDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("remotesource %q doesn't exist", remoteSourceName), serrors.RemoteSourceDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteRemoteSource(tx, remoteSource.ID); err != nil {
|
||||
|
|
@ -276,7 +276,7 @@ func (h *ActionHandler) GetLinkedAccounts(ctx context.Context, req *GetLinkedAcc
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account with remote user %q for remote source %q token doesn't exist", remoteUserID, remoteSourceID), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account with remote user %q for remote source %q token doesn't exist", remoteUserID, remoteSourceID), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
linkedAccounts = []*types.LinkedAccount{la}
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func (h *ActionHandler) GetSecret(ctx context.Context, secretID string) (*types.
|
|||
}
|
||||
|
||||
if secret == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("secret %q doesn't exist", secretID), serrors.SecretDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("secret %q doesn't exist", secretID), serrors.SecretDoesNotExist())
|
||||
}
|
||||
|
||||
return secret, nil
|
||||
|
|
@ -166,10 +166,10 @@ func (h *ActionHandler) ValidateSecretReq(ctx context.Context, req *CreateUpdate
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("secret name required"), serrors.InvalidSecretName())
|
||||
}
|
||||
if !util.ValidateName(req.Name) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid secret name %q", req.Name), serrors.InvalidSecretName())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid secret name %q", req.Name), serrors.InvalidSecretName())
|
||||
}
|
||||
if req.Type != types.SecretTypeInternal {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid secret type %q", req.Type), serrors.InvalidSecretType())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid secret type %q", req.Type), serrors.InvalidSecretType())
|
||||
}
|
||||
switch req.Type {
|
||||
case types.SecretTypeInternal:
|
||||
|
|
@ -184,7 +184,7 @@ func (h *ActionHandler) ValidateSecretReq(ctx context.Context, req *CreateUpdate
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("secret parentid required"))
|
||||
}
|
||||
if req.Parent.Kind != types.ObjectKindProject && req.Parent.Kind != types.ObjectKindProjectGroup {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid secret parent kind %q", req.Parent.Kind))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid secret parent kind %q", req.Parent.Kind))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -219,7 +219,7 @@ func (h *ActionHandler) CreateSecret(ctx context.Context, req *CreateUpdateSecre
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if s != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("secret with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.SecretAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("secret with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.SecretAlreadyExists())
|
||||
}
|
||||
|
||||
secret = types.NewSecret(tx)
|
||||
|
|
@ -263,7 +263,7 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, curSecretName string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if secret == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("secret with name %q for %s with id %q doesn't exists", curSecretName, req.Parent.Kind, req.Parent.ID), serrors.SecretDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("secret with name %q for %s with id %q doesn't exists", curSecretName, req.Parent.Kind, req.Parent.ID), serrors.SecretDoesNotExist())
|
||||
}
|
||||
|
||||
if secret.Name != req.Name {
|
||||
|
|
@ -273,7 +273,7 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, curSecretName string,
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if s != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("secret with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.SecretAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("secret with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.SecretAlreadyExists())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -311,7 +311,7 @@ func (h *ActionHandler) DeleteSecret(ctx context.Context, parentKind types.Objec
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if secret == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("secret with name %q doesn't exist", secretName), serrors.SecretDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("secret with name %q doesn't exist", secretName), serrors.SecretDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteSecret(tx, secret.ID); err != nil {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func (h *ActionHandler) UserQuery(ctx context.Context, req *UserQueryRequest) (*
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user with linked account %q doesn't exist", req.LinkedAccountID), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user with linked account %q doesn't exist", req.LinkedAccountID), serrors.UserDoesNotExist())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
@ -82,7 +82,7 @@ func (h *ActionHandler) UserQuery(ctx context.Context, req *UserQueryRequest) (*
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account with remote user %q for remote source %q doesn't exist", req.RemoteUserID, req.RemoteSourceID), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account with remote user %q for remote source %q doesn't exist", req.RemoteUserID, req.RemoteSourceID), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
user, err = h.GetUserByRef(tx, la.UserID)
|
||||
|
|
@ -90,7 +90,7 @@ func (h *ActionHandler) UserQuery(ctx context.Context, req *UserQueryRequest) (*
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user with remote user %q for remote source %q doesn't exist", req.RemoteUserID, req.RemoteSourceID), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user with remote user %q for remote source %q doesn't exist", req.RemoteUserID, req.RemoteSourceID), serrors.UserDoesNotExist())
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
|
@ -117,7 +117,7 @@ func (h *ActionHandler) GetUser(ctx context.Context, userRef string) (*types.Use
|
|||
}
|
||||
|
||||
if user == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
return user, nil
|
||||
|
|
@ -180,7 +180,7 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)
|
|||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user name required"), serrors.InvalidUserName())
|
||||
}
|
||||
if !util.ValidateName(req.UserName) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid user name %q", req.UserName), serrors.InvalidUserName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid user name %q", req.UserName), serrors.InvalidUserName())
|
||||
}
|
||||
|
||||
var user *types.User
|
||||
|
|
@ -193,7 +193,7 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if u != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user with name %q already exists", u.Name), serrors.UserAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user with name %q already exists", u.Name), serrors.UserAlreadyExists())
|
||||
}
|
||||
|
||||
var rs *types.RemoteSource
|
||||
|
|
@ -203,14 +203,14 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if rs == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("remote source %q doesn't exist", req.CreateUserLARequest.RemoteSourceName), serrors.RemoteSourceDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("remote source %q doesn't exist", req.CreateUserLARequest.RemoteSourceName), serrors.RemoteSourceDoesNotExist())
|
||||
}
|
||||
la, err := h.d.GetLinkedAccountByRemoteUserIDandSource(tx, req.CreateUserLARequest.RemoteUserID, rs.ID)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get linked account for remote user id %q and remote source %q", req.CreateUserLARequest.RemoteUserID, rs.ID)
|
||||
}
|
||||
if la != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account for remote user id %q for remote source %q already exists", req.CreateUserLARequest.RemoteUserID, req.CreateUserLARequest.RemoteSourceName), serrors.LinkedAccountAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account for remote user id %q for remote source %q already exists", req.CreateUserLARequest.RemoteUserID, req.CreateUserLARequest.RemoteSourceName), serrors.LinkedAccountAlreadyExists())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -270,7 +270,7 @@ func (h *ActionHandler) DeleteUser(ctx context.Context, userRef string) error {
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteOrgMembersByUserID(tx, user.ID); err != nil {
|
||||
|
|
@ -319,7 +319,7 @@ func (h *ActionHandler) UpdateUser(ctx context.Context, req *UpdateUserRequest)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
if req.UserName != "" {
|
||||
|
|
@ -329,7 +329,7 @@ func (h *ActionHandler) UpdateUser(ctx context.Context, req *UpdateUserRequest)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if u != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user with name %q already exists", u.Name), serrors.UserAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user with name %q already exists", u.Name), serrors.UserAlreadyExists())
|
||||
}
|
||||
|
||||
user.Name = req.UserName
|
||||
|
|
@ -360,7 +360,7 @@ func (h *ActionHandler) GetUserLinkedAccounts(ctx context.Context, userRef strin
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
linkedAccounts, err = h.d.GetUserLinkedAccounts(tx, user.ID)
|
||||
|
|
@ -404,7 +404,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
rs, err := h.d.GetRemoteSourceByName(tx, req.RemoteSourceName)
|
||||
|
|
@ -412,7 +412,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if rs == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("remote source %q doesn't exist", req.RemoteSourceName), serrors.RemoteSourceDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("remote source %q doesn't exist", req.RemoteSourceName), serrors.RemoteSourceDoesNotExist())
|
||||
}
|
||||
|
||||
la, err = h.d.GetLinkedAccountByRemoteUserIDandSource(tx, req.RemoteUserID, rs.ID)
|
||||
|
|
@ -420,7 +420,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
return errors.Wrapf(err, "failed to get linked account for remote user id %q and remote source %q", req.RemoteUserID, rs.ID)
|
||||
}
|
||||
if la != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account for remote user id %q for remote source %q already exists", req.RemoteUserID, req.RemoteSourceName), serrors.LinkedAccountAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account for remote user id %q for remote source %q already exists", req.RemoteUserID, req.RemoteSourceName), serrors.LinkedAccountAlreadyExists())
|
||||
}
|
||||
|
||||
la = types.NewLinkedAccount(tx)
|
||||
|
|
@ -463,7 +463,7 @@ func (h *ActionHandler) DeleteUserLA(ctx context.Context, userRef, laID string)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
la, err := h.d.GetLinkedAccount(tx, laID)
|
||||
|
|
@ -471,12 +471,12 @@ func (h *ActionHandler) DeleteUserLA(ctx context.Context, userRef, laID string)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account id %q for user %q doesn't exist", laID, userRef), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account id %q for user %q doesn't exist", laID, userRef), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
// check that the linked account belongs to the right user
|
||||
if user.ID != la.UserID {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account id %q for user %q doesn't exist", laID, userRef), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account id %q for user %q doesn't exist", laID, userRef), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteLinkedAccount(tx, la.ID); err != nil {
|
||||
|
|
@ -516,7 +516,7 @@ func (h *ActionHandler) UpdateUserLA(ctx context.Context, req *UpdateUserLAReque
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
la, err = h.d.GetLinkedAccount(tx, req.LinkedAccountID)
|
||||
|
|
@ -524,12 +524,12 @@ func (h *ActionHandler) UpdateUserLA(ctx context.Context, req *UpdateUserLAReque
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account id %q for user %q doesn't exist", req.LinkedAccountID, req.UserRef), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account id %q for user %q doesn't exist", req.LinkedAccountID, req.UserRef), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
// check that the linked account belongs to the right user
|
||||
if user.ID != la.UserID {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account id %q for user %q doesn't exist", req.LinkedAccountID, req.UserRef), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account id %q for user %q doesn't exist", req.LinkedAccountID, req.UserRef), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
rs, err := h.d.GetRemoteSource(tx, la.RemoteSourceID)
|
||||
|
|
@ -537,7 +537,7 @@ func (h *ActionHandler) UpdateUserLA(ctx context.Context, req *UpdateUserLAReque
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if rs == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("remote source with id %q doesn't exist", la.RemoteSourceID), serrors.RemoteSourceDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("remote source with id %q doesn't exist", la.RemoteSourceID), serrors.RemoteSourceDoesNotExist())
|
||||
}
|
||||
|
||||
la.RemoteUserID = req.RemoteUserID
|
||||
|
|
@ -572,7 +572,7 @@ func (h *ActionHandler) GetUserTokens(ctx context.Context, userRef string) ([]*t
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
tokens, err = h.d.GetUserTokens(tx, user.ID)
|
||||
|
|
@ -604,7 +604,7 @@ func (h *ActionHandler) CreateUserToken(ctx context.Context, userRef, tokenName
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
userToken, err := h.d.GetUserToken(tx, user.ID, tokenName)
|
||||
|
|
@ -613,7 +613,7 @@ func (h *ActionHandler) CreateUserToken(ctx context.Context, userRef, tokenName
|
|||
}
|
||||
|
||||
if userToken != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("token %q for user %q already exists", tokenName, userRef), serrors.UserTokenAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("token %q for user %q already exists", tokenName, userRef), serrors.UserTokenAlreadyExists())
|
||||
}
|
||||
|
||||
token = types.NewUserToken(tx)
|
||||
|
|
@ -648,7 +648,7 @@ func (h *ActionHandler) DeleteUserToken(ctx context.Context, userRef, tokenName
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
userToken, err := h.d.GetUserToken(tx, user.ID, tokenName)
|
||||
|
|
@ -657,7 +657,7 @@ func (h *ActionHandler) DeleteUserToken(ctx context.Context, userRef, tokenName
|
|||
}
|
||||
|
||||
if userToken == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("token %q for user %q doesn't exist", tokenName, userRef), serrors.UserTokenDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("token %q for user %q doesn't exist", tokenName, userRef), serrors.UserTokenDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteUserToken(tx, userToken.ID); err != nil {
|
||||
|
|
@ -695,14 +695,14 @@ func (h *ActionHandler) GetUserOrg(ctx context.Context, userRef, orgRef string)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
org, err := h.GetOrgByRef(tx, orgRef)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %q doesn't exist", orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
dbUserOrg, err = h.d.GetUserOrg(tx, user.ID, org.ID)
|
||||
|
|
@ -713,7 +713,7 @@ func (h *ActionHandler) GetUserOrg(ctx context.Context, userRef, orgRef string)
|
|||
}
|
||||
|
||||
if dbUserOrg == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q is not member of org %q", userRef, orgRef), serrors.OrganizationDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q is not member of org %q", userRef, orgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
userOrg := userOrgResponse(dbUserOrg)
|
||||
|
|
@ -752,7 +752,7 @@ func (h *ActionHandler) GetUserOrgs(ctx context.Context, req *GetUserOrgsRequest
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", req.UserRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
dbUserOrgs, err = h.d.GetUserOrgs(tx, user.ID, req.StartOrgName, limit, req.SortDirection)
|
||||
|
|
@ -789,7 +789,7 @@ func (h *ActionHandler) GetUserOrgInvitations(ctx context.Context, userRef strin
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if user == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("user %q doesn't exist", userRef), serrors.UserDoesNotExist())
|
||||
}
|
||||
|
||||
orgInvitations, err = h.d.GetOrgInvitationByUserID(tx, user.ID)
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ func (h *ActionHandler) ValidateVariableReq(ctx context.Context, req *CreateUpda
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("variable name required"), serrors.InvalidVariableName())
|
||||
}
|
||||
if !util.ValidateName(req.Name) {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid variable name %q", req.Name), serrors.InvalidVariableName())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid variable name %q", req.Name), serrors.InvalidVariableName())
|
||||
}
|
||||
if len(req.Values) == 0 {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("variable values required"), serrors.InvalidVariableValues())
|
||||
|
|
@ -123,7 +123,7 @@ func (h *ActionHandler) ValidateVariableReq(ctx context.Context, req *CreateUpda
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("variable parent id required"))
|
||||
}
|
||||
if req.Parent.Kind != types.ObjectKindProject && req.Parent.Kind != types.ObjectKindProjectGroup {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid variable parent kind %q", req.Parent.Kind))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid variable parent kind %q", req.Parent.Kind))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -154,7 +154,7 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateUpdateVar
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if s != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("variable with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.VariableAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("variable with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.VariableAlreadyExists())
|
||||
}
|
||||
|
||||
variable = types.NewVariable(tx)
|
||||
|
|
@ -194,7 +194,7 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, curVariableName stri
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if variable == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("variable with name %q for %s with id %q doesn't exists", curVariableName, req.Parent.Kind, req.Parent.ID), serrors.VariableDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("variable with name %q for %s with id %q doesn't exists", curVariableName, req.Parent.Kind, req.Parent.ID), serrors.VariableDoesNotExist())
|
||||
}
|
||||
|
||||
if variable.Name != req.Name {
|
||||
|
|
@ -204,7 +204,7 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, curVariableName stri
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if u != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("variable with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.VariableAlreadyExists())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("variable with name %q for %s with id %q already exists", req.Name, req.Parent.Kind, req.Parent.ID), serrors.VariableAlreadyExists())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,7 +239,7 @@ func (h *ActionHandler) DeleteVariable(ctx context.Context, parentKind types.Obj
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if variable == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("variable with name %q doesn't exist", variableName), serrors.VariableDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("variable with name %q doesn't exist", variableName), serrors.VariableDoesNotExist())
|
||||
}
|
||||
|
||||
if err := h.d.DeleteVariable(tx, variable.ID); err != nil {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ func GetObjectKindRef(r *http.Request) (types.ObjectKind, string, error) {
|
|||
vars := mux.Vars(r)
|
||||
projectRef, err := url.PathUnescape(vars["projectref"])
|
||||
if err != nil {
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsg("wrong projectref %q", vars["projectref"]))
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsgf("wrong projectref %q", vars["projectref"]))
|
||||
}
|
||||
if projectRef != "" {
|
||||
return types.ObjectKindProject, projectRef, nil
|
||||
|
|
@ -42,7 +42,7 @@ func GetObjectKindRef(r *http.Request) (types.ObjectKind, string, error) {
|
|||
|
||||
projectGroupRef, err := url.PathUnescape(vars["projectgroupref"])
|
||||
if err != nil {
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsg("wrong projectgroupref %q", vars["projectgroupref"]))
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsgf("wrong projectgroupref %q", vars["projectgroupref"]))
|
||||
}
|
||||
if projectGroupRef != "" {
|
||||
return types.ObjectKindProjectGroup, projectGroupRef, nil
|
||||
|
|
@ -78,7 +78,7 @@ func parseRequestOptions(r *http.Request) (*requestOptions, error) {
|
|||
case types.SortDirectionAsc:
|
||||
case types.SortDirectionDesc:
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ func (s *Configstore) maintenanceModeWatcherLoop(ctx context.Context, runCtxCanc
|
|||
s.log.Info().Msgf("maintenance mode watcher: maintenance mode enabled: %t", maintenanceMode)
|
||||
|
||||
for {
|
||||
s.log.Debug().Msgf("maintenanceModeWatcherLoop")
|
||||
s.log.Debug().Msg("maintenanceModeWatcherLoop")
|
||||
|
||||
// at first watch restart from previous processed revision
|
||||
if err := s.maintenanceModeWatcher(ctx, runCtxCancel, maintenanceMode); err != nil {
|
||||
s.log.Err(err).Msgf("maintenance mode watcher error")
|
||||
s.log.Err(err).Msg("maintenance mode watcher error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(1 * time.Second).C
|
||||
|
|
@ -331,13 +331,13 @@ func (s *Configstore) setupMaintenanceRouter() http.Handler {
|
|||
func (s *Configstore) Run(ctx context.Context) error {
|
||||
for {
|
||||
if err := s.run(ctx); err != nil {
|
||||
log.Err(err).Msgf("run error")
|
||||
log.Err(err).Msg("run error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(1 * time.Second).C
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
s.log.Info().Msgf("configstore exiting")
|
||||
s.log.Info().Msg("configstore exiting")
|
||||
return nil
|
||||
case <-sleepCh:
|
||||
}
|
||||
|
|
@ -399,10 +399,10 @@ func (s *Configstore) run(ctx context.Context) error {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Info().Msgf("configstore run exiting")
|
||||
log.Info().Msg("configstore run exiting")
|
||||
case err = <-lerrCh:
|
||||
if err != nil {
|
||||
log.Err(err).Msgf("http server listen error")
|
||||
log.Err(err).Msg("http server listen error")
|
||||
}
|
||||
case err = <-errCh:
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ func TestUser(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("create duplicated user", func(t *testing.T) {
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user with name %q already exists", "user01"), serrors.UserAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user with name %q already exists", "user01"), serrors.UserAlreadyExists())
|
||||
_, err := cs.ah.CreateUser(ctx, &action.CreateUserRequest{UserName: "user01"})
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
})
|
||||
|
|
@ -432,26 +432,26 @@ func TestProjectGroupsAndProjectsCreate(t *testing.T) {
|
|||
|
||||
t.Run("create duplicated project in user root project group", func(t *testing.T) {
|
||||
projectName := "project01"
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", projectName, path.Join("user", user.Name, projectName)), serrors.ProjectAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", projectName, path.Join("user", user.Name, projectName)), serrors.ProjectAlreadyExists())
|
||||
_, err := cs.ah.CreateProject(ctx, &action.CreateUpdateProjectRequest{Name: projectName, Parent: types.Parent{Kind: types.ObjectKindProjectGroup, ID: path.Join("user", user.Name)}, Visibility: types.VisibilityPublic, RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeManual})
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
})
|
||||
t.Run("create duplicated project in org root project group", func(t *testing.T) {
|
||||
projectName := "project01"
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", projectName, path.Join("org", org.Name, projectName)), serrors.ProjectAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", projectName, path.Join("org", org.Name, projectName)), serrors.ProjectAlreadyExists())
|
||||
_, err := cs.ah.CreateProject(ctx, &action.CreateUpdateProjectRequest{Name: projectName, Parent: types.Parent{Kind: types.ObjectKindProjectGroup, ID: path.Join("org", org.Name)}, Visibility: types.VisibilityPublic, RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeManual})
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
})
|
||||
|
||||
t.Run("create duplicated project in user non root project group", func(t *testing.T) {
|
||||
projectName := "project01"
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", projectName, path.Join("user", user.Name, "projectgroup01", projectName)), serrors.ProjectAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", projectName, path.Join("user", user.Name, "projectgroup01", projectName)), serrors.ProjectAlreadyExists())
|
||||
_, err := cs.ah.CreateProject(ctx, &action.CreateUpdateProjectRequest{Name: projectName, Parent: types.Parent{Kind: types.ObjectKindProjectGroup, ID: path.Join("user", user.Name, "projectgroup01")}, Visibility: types.VisibilityPublic, RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeManual})
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
})
|
||||
t.Run("create duplicated project in org non root project group", func(t *testing.T) {
|
||||
projectName := "project01"
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", projectName, path.Join("org", org.Name, "projectgroup01", projectName)), serrors.ProjectAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", projectName, path.Join("org", org.Name, "projectgroup01", projectName)), serrors.ProjectAlreadyExists())
|
||||
_, err := cs.ah.CreateProject(ctx, &action.CreateUpdateProjectRequest{Name: projectName, Parent: types.Parent{Kind: types.ObjectKindProjectGroup, ID: path.Join("org", org.Name, "projectgroup01")}, Visibility: types.VisibilityPublic, RemoteRepositoryConfigType: types.RemoteRepositoryConfigTypeManual})
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
})
|
||||
|
|
@ -528,7 +528,7 @@ func TestProjectUpdate(t *testing.T) {
|
|||
})
|
||||
t.Run("move project to project group having project with same name", func(t *testing.T) {
|
||||
projectName := "project01"
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project with name %q, path %q already exists", projectName, path.Join("user", user.Name, projectName)), serrors.ProjectAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project with name %q, path %q already exists", projectName, path.Join("user", user.Name, projectName)), serrors.ProjectAlreadyExists())
|
||||
p02req.Parent.ID = path.Join("user", user.Name)
|
||||
_, err := cs.ah.UpdateProject(ctx, path.Join("user", user.Name, "projectgroup01", projectName), p02req)
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
|
|
@ -607,7 +607,7 @@ func TestProjectGroupUpdate(t *testing.T) {
|
|||
})
|
||||
t.Run("move project to project group having project with same name", func(t *testing.T) {
|
||||
projectGroupName := "pg01"
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project group with name %q, path %q already exists", projectGroupName, path.Join("user", user.Name, projectGroupName)), serrors.ProjectGroupAlreadyExists())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project group with name %q, path %q already exists", projectGroupName, path.Join("user", user.Name, projectGroupName)), serrors.ProjectGroupAlreadyExists())
|
||||
pg05req.Parent.ID = path.Join("user", user.Name)
|
||||
_, err := cs.ah.UpdateProjectGroup(ctx, path.Join("user", user.Name, "pg02", projectGroupName), pg05req)
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ func NewK8sDriver(log zerolog.Logger, executorID, toolboxPath, initImage string,
|
|||
sv, err := parseGitVersion(serverVersion.GitVersion)
|
||||
// if server version parsing fails just warn but ignore it
|
||||
if err != nil {
|
||||
d.log.Warn().Err(err).Msgf("failed to parse k8s server version")
|
||||
d.log.Warn().Err(err).Msg("failed to parse k8s server version")
|
||||
}
|
||||
if sv != nil {
|
||||
// for k8s version < v1.14.x use old arch label
|
||||
|
|
@ -205,7 +205,7 @@ func NewK8sDriver(log zerolog.Logger, executorID, toolboxPath, initImage string,
|
|||
go func() {
|
||||
for {
|
||||
if err := d.updateLease(ctx); err != nil {
|
||||
d.log.Err(err).Msgf("failed to update executor lease")
|
||||
d.log.Err(err).Msg("failed to update executor lease")
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
@ -221,7 +221,7 @@ func NewK8sDriver(log zerolog.Logger, executorID, toolboxPath, initImage string,
|
|||
go func() {
|
||||
for {
|
||||
if err := d.cleanStaleExecutorsLease(ctx); err != nil {
|
||||
d.log.Err(err).Msgf("failed to clean stale executors lease")
|
||||
d.log.Err(err).Msg("failed to clean stale executors lease")
|
||||
}
|
||||
|
||||
select {
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ func (e *Executor) setupTask(ctx context.Context, rt *runningTask) error {
|
|||
return errors.Errorf("executor doesn't allow executing privileged containers")
|
||||
}
|
||||
|
||||
e.log.Debug().Msgf("starting pod")
|
||||
e.log.Debug().Msg("starting pod")
|
||||
|
||||
dockerRegistriesAuth := map[string]registry.DockerRegistryAuth{}
|
||||
for n, v := range et.Spec.DockerRegistriesAuth {
|
||||
|
|
@ -1030,7 +1030,7 @@ func (e *Executor) executeTaskSteps(ctx context.Context, rt *runningTask, pod dr
|
|||
|
||||
func (e *Executor) podsCleanerLoop(ctx context.Context) {
|
||||
for {
|
||||
e.log.Debug().Msgf("podsCleaner")
|
||||
e.log.Debug().Msg("podsCleaner")
|
||||
|
||||
if err := e.podsCleaner(ctx); err != nil {
|
||||
e.log.Err(err).Send()
|
||||
|
|
@ -1086,7 +1086,7 @@ func (e *Executor) podsCleaner(ctx context.Context) error {
|
|||
|
||||
func (e *Executor) executorStatusSenderLoop(ctx context.Context) {
|
||||
for {
|
||||
e.log.Debug().Msgf("executorStatusSenderLoop")
|
||||
e.log.Debug().Msg("executorStatusSenderLoop")
|
||||
|
||||
if err := e.sendExecutorStatus(ctx); err != nil {
|
||||
e.log.Err(err).Send()
|
||||
|
|
@ -1103,7 +1103,7 @@ func (e *Executor) executorStatusSenderLoop(ctx context.Context) {
|
|||
|
||||
func (e *Executor) executorTasksStatusSenderLoop(ctx context.Context) {
|
||||
for {
|
||||
e.log.Debug().Msgf("executorTasksStatusSenderLoop")
|
||||
e.log.Debug().Msg("executorTasksStatusSenderLoop")
|
||||
|
||||
for _, rtID := range e.runningTasks.ids() {
|
||||
rt, ok := e.runningTasks.get(rtID)
|
||||
|
|
@ -1139,7 +1139,7 @@ func (e *Executor) executorTasksStatusSenderLoop(ctx context.Context) {
|
|||
|
||||
func (e *Executor) tasksUpdaterLoop(ctx context.Context) {
|
||||
for {
|
||||
e.log.Debug().Msgf("tasksUpdater")
|
||||
e.log.Debug().Msg("tasksUpdater")
|
||||
|
||||
if err := e.tasksUpdater(ctx); err != nil {
|
||||
e.log.Err(err).Send()
|
||||
|
|
@ -1267,7 +1267,7 @@ func (e *Executor) taskUpdater(ctx context.Context, et *rsapitypes.ExecutorTask)
|
|||
|
||||
func (e *Executor) tasksDataCleanerLoop(ctx context.Context) {
|
||||
for {
|
||||
e.log.Debug().Msgf("tasksDataCleaner")
|
||||
e.log.Debug().Msg("tasksDataCleaner")
|
||||
|
||||
if err := e.tasksDataCleaner(ctx); err != nil {
|
||||
e.log.Err(err).Send()
|
||||
|
|
@ -1563,11 +1563,11 @@ func (e *Executor) Run(ctx context.Context) error {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Info().Msgf("runservice executor exiting")
|
||||
log.Info().Msg("runservice executor exiting")
|
||||
httpServer.Close()
|
||||
case err := <-lerrCh:
|
||||
if err != nil {
|
||||
log.Err(err).Msgf("http server listen error")
|
||||
log.Err(err).Msg("http server listen error")
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -1577,7 +1577,7 @@ func (e *Executor) Run(ctx context.Context) error {
|
|||
|
||||
func (e *Executor) tasksTimeoutCleanerLoop(ctx context.Context) {
|
||||
for {
|
||||
e.log.Debug().Msgf("tasksTimeoutCleaner")
|
||||
e.log.Debug().Msg("tasksTimeoutCleaner")
|
||||
|
||||
e.tasksTimeoutCleaner()
|
||||
|
||||
|
|
|
|||
|
|
@ -126,14 +126,14 @@ func (h *ActionHandler) IsAuthUserVariableOwner(ctx context.Context, parentType
|
|||
case cstypes.ObjectKindProjectGroup:
|
||||
pg, _, err := h.configstoreClient.GetProjectGroup(ctx, parentRef)
|
||||
if err != nil {
|
||||
return false, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project group %q", parentRef))
|
||||
return false, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project group %q", parentRef))
|
||||
}
|
||||
ownerType = pg.OwnerType
|
||||
ownerID = pg.OwnerID
|
||||
case cstypes.ObjectKindProject:
|
||||
p, _, err := h.configstoreClient.GetProject(ctx, parentRef)
|
||||
if err != nil {
|
||||
return false, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", parentRef))
|
||||
return false, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", parentRef))
|
||||
}
|
||||
ownerType = p.OwnerType
|
||||
ownerID = p.OwnerID
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ func (h *ActionHandler) IsMaintenanceEnabled(ctx context.Context, serviceName st
|
|||
|
||||
return &MaintenanceStatusResponse{RequestedStatus: rsresp.RequestedStatus, CurrentStatus: rsresp.CurrentStatus}, nil
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid service name %q", serviceName))
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid service name %q", serviceName))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ func (h *ActionHandler) MaintenanceMode(ctx context.Context, serviceName string,
|
|||
_, err = h.runserviceClient.DisableMaintenance(ctx)
|
||||
}
|
||||
default:
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid service name %q", serviceName))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid service name %q", serviceName))
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
|
@ -108,7 +108,7 @@ func (h *ActionHandler) Export(ctx context.Context, serviceName string) (*http.R
|
|||
resp, err = h.runserviceClient.Export(ctx)
|
||||
res = resp.Response
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid service name %q", serviceName))
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid service name %q", serviceName))
|
||||
}
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
@ -129,7 +129,7 @@ func (h *ActionHandler) Import(ctx context.Context, r io.Reader, serviceName str
|
|||
case RunserviceService:
|
||||
_, err = h.runserviceClient.Import(ctx, r)
|
||||
default:
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid service name %q", serviceName))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid service name %q", serviceName))
|
||||
}
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*
|
|||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("organization name required"), serrors.InvalidOrganizationName())
|
||||
}
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid organization name %q", req.Name), serrors.InvalidOrganizationName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid organization name %q", req.Name), serrors.InvalidOrganizationName())
|
||||
}
|
||||
if !cstypes.IsValidVisibility(req.Visibility) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid organization visibility"), serrors.InvalidVisibility())
|
||||
|
|
@ -208,7 +208,7 @@ func (h *ActionHandler) CreateOrg(ctx context.Context, req *CreateOrgRequest) (*
|
|||
CreatorUserID: curUserID,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating organization")
|
||||
h.log.Info().Msg("creating organization")
|
||||
org, _, err := h.configstoreClient.CreateOrg(ctx, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create organization"))
|
||||
|
|
@ -244,7 +244,7 @@ func (h *ActionHandler) UpdateOrg(ctx context.Context, orgRef string, req *Updat
|
|||
Visibility: org.Visibility,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("updating organization")
|
||||
h.log.Info().Msg("updating organization")
|
||||
org, _, err = h.configstoreClient.UpdateOrg(ctx, orgRef, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to update organization"))
|
||||
|
|
@ -347,7 +347,7 @@ func (h *ActionHandler) GetOrgInvitations(ctx context.Context, orgRef string, li
|
|||
|
||||
org, _, err := h.configstoreClient.GetOrg(ctx, orgRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get org %s", orgRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get org %s", orgRef))
|
||||
}
|
||||
|
||||
isOrgOwner, err := h.IsAuthUserOrgOwner(ctx, org.ID)
|
||||
|
|
@ -392,7 +392,7 @@ func (h *ActionHandler) CreateOrgInvitation(ctx context.Context, req *CreateOrgI
|
|||
|
||||
org, _, err := h.configstoreClient.GetOrg(ctx, req.OrganizationRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get org %s", req.OrganizationRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get org %s", req.OrganizationRef))
|
||||
}
|
||||
|
||||
isOrgOwner, err := h.IsAuthUserOrgOwner(ctx, org.ID)
|
||||
|
|
@ -425,7 +425,7 @@ func (h *ActionHandler) CreateOrgInvitation(ctx context.Context, req *CreateOrgI
|
|||
Role: req.Role,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating org invitation")
|
||||
h.log.Info().Msg("creating org invitation")
|
||||
orgInvitation, _, err := h.configstoreClient.CreateOrgInvitation(ctx, org.ID, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create org invitation"))
|
||||
|
|
@ -458,7 +458,7 @@ func (h *ActionHandler) OrgInvitationAction(ctx context.Context, req *OrgInvitat
|
|||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get org invitation"))
|
||||
}
|
||||
if orgInvitation == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("invitation for org %s user %s not found", req.OrgRef, userID), serrors.InvitationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("invitation for org %s user %s not found", req.OrgRef, userID), serrors.InvitationDoesNotExist())
|
||||
}
|
||||
|
||||
if userID != orgInvitation.UserID {
|
||||
|
|
@ -467,11 +467,11 @@ func (h *ActionHandler) OrgInvitationAction(ctx context.Context, req *OrgInvitat
|
|||
|
||||
org, _, err := h.configstoreClient.GetOrg(ctx, req.OrgRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get org %s", req.OrgRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get org %s", req.OrgRef))
|
||||
}
|
||||
|
||||
if org == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("org %s doesn't exist", req.OrgRef), serrors.OrganizationDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("org %s doesn't exist", req.OrgRef), serrors.OrganizationDoesNotExist())
|
||||
}
|
||||
|
||||
creq := &csapitypes.OrgInvitationActionRequest{Action: req.Action}
|
||||
|
|
@ -495,7 +495,7 @@ func (h *ActionHandler) DeleteOrgInvitation(ctx context.Context, orgRef string,
|
|||
|
||||
org, _, err := h.configstoreClient.GetOrg(ctx, orgInvitation.OrganizationID)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get org %s", orgInvitation.OrganizationID))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get org %s", orgInvitation.OrganizationID))
|
||||
}
|
||||
|
||||
isOrgOwner, err := h.IsAuthUserOrgOwner(ctx, org.ID)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ import (
|
|||
func (h *ActionHandler) GetProject(ctx context.Context, projectRef string) (*csapitypes.Project, error) {
|
||||
project, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
if project.GlobalVisibility == cstypes.VisibilityPublic {
|
||||
|
|
@ -71,7 +71,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
|
||||
user, _, err := h.configstoreClient.GetUser(ctx, curUserID)
|
||||
if err != nil {
|
||||
return nil, util.NewAPIErrorWrap(util.ErrInternal, err, util.WithAPIErrorMsg("failed to get user %q", curUserID))
|
||||
return nil, util.NewAPIErrorWrap(util.ErrInternal, err, util.WithAPIErrorMsgf("failed to get user %q", curUserID))
|
||||
}
|
||||
|
||||
parentRef := req.ParentRef
|
||||
|
|
@ -85,7 +85,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
if util.RemoteErrorIs(err, util.ErrNotExist) {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get parent project group %q", req.ParentRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get parent project group %q", req.ParentRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, pg.OwnerType, pg.OwnerID)
|
||||
|
|
@ -97,7 +97,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project name %q", req.Name), serrors.InvalidProjectName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid project name %q", req.Name), serrors.InvalidProjectName())
|
||||
}
|
||||
if req.RemoteSourceName == "" {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("empty remote source name"), serrors.InvalidRemoteSourceName())
|
||||
|
|
@ -109,10 +109,10 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
projectPath := path.Join(pg.Path, req.Name)
|
||||
if _, _, err = h.configstoreClient.GetProject(ctx, projectPath); err != nil {
|
||||
if !util.RemoteErrorIs(err, util.ErrNotExist) {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", req.Name))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", req.Name))
|
||||
}
|
||||
} else {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("project %q already exists", projectPath), serrors.ProjectAlreadyExists())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("project %q already exists", projectPath), serrors.ProjectAlreadyExists())
|
||||
}
|
||||
|
||||
gitSource, rs, la, err := h.getUserGitSource(ctx, req.RemoteSourceName, curUserID)
|
||||
|
|
@ -125,7 +125,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
return nil, errors.Wrapf(err, "failed to get repository info from gitsource")
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("generating ssh key pairs")
|
||||
h.log.Info().Msg("generating ssh key pairs")
|
||||
privateKey, _, err := util.GenSSHKeyPair(4096)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to generate ssh key pair")
|
||||
|
|
@ -150,7 +150,7 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
MembersCanPerformRunActions: req.MembersCanPerformRunActions,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating project")
|
||||
h.log.Info().Msg("creating project")
|
||||
rp, _, err := h.configstoreClient.CreateProject(ctx, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create project"))
|
||||
|
|
@ -159,16 +159,16 @@ func (h *ActionHandler) CreateProject(ctx context.Context, req *CreateProjectReq
|
|||
|
||||
if serr := h.setupGitSourceRepo(ctx, rs, user, la, rp); serr != nil {
|
||||
var err error
|
||||
h.log.Err(err).Msgf("failed to setup git source repo, trying to cleanup")
|
||||
h.log.Err(err).Msg("failed to setup git source repo, trying to cleanup")
|
||||
// try to cleanup gitsource configs and remove project
|
||||
// we'll log but ignore errors
|
||||
h.log.Info().Msgf("deleting project with ID: %q", rp.ID)
|
||||
if _, err := h.configstoreClient.DeleteProject(ctx, rp.ID); err != nil {
|
||||
h.log.Err(err).Msgf("failed to delete project ")
|
||||
h.log.Err(err).Msg("failed to delete project ")
|
||||
}
|
||||
h.log.Info().Msgf("cleanup git source repo")
|
||||
h.log.Info().Msg("cleanup git source repo")
|
||||
if err := h.cleanupGitSourceRepo(ctx, rs, user, la, rp); err != nil {
|
||||
h.log.Err(err).Msgf("failed to cleanup git source repo")
|
||||
h.log.Err(err).Msg("failed to cleanup git source repo")
|
||||
}
|
||||
return nil, errors.Wrapf(serr, "failed to setup git source repo")
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ type UpdateProjectRequest struct {
|
|||
func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, req *UpdateProjectRequest) (*csapitypes.Project, error) {
|
||||
p, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
@ -231,7 +231,7 @@ func (h *ActionHandler) UpdateProject(ctx context.Context, projectRef string, re
|
|||
MembersCanPerformRunActions: p.MembersCanPerformRunActions,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("updating project")
|
||||
h.log.Info().Msg("updating project")
|
||||
rp, _, err := h.configstoreClient.UpdateProject(ctx, p.ID, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to update project"))
|
||||
|
|
@ -249,7 +249,7 @@ func (h *ActionHandler) ProjectUpdateRepoLinkedAccount(ctx context.Context, proj
|
|||
|
||||
p, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
@ -288,7 +288,7 @@ func (h *ActionHandler) ProjectUpdateRepoLinkedAccount(ctx context.Context, proj
|
|||
DefaultBranch: p.DefaultBranch,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("updating project")
|
||||
h.log.Info().Msg("updating project")
|
||||
rp, _, err := h.configstoreClient.UpdateProject(ctx, p.ID, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to update project"))
|
||||
|
|
@ -322,7 +322,7 @@ func (h *ActionHandler) setupGitSourceRepo(ctx context.Context, rs *cstypes.Remo
|
|||
if err := gitsource.UpdateDeployKey(project.RepositoryPath, deployKeyName, string(pubKey), true); err != nil {
|
||||
return errors.Wrapf(err, "failed to create deploy key")
|
||||
}
|
||||
h.log.Info().Msgf("deleting existing webhooks")
|
||||
h.log.Info().Msg("deleting existing webhooks")
|
||||
if err := gitsource.DeleteRepoWebhook(project.RepositoryPath, webhookURL); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete repository webhook")
|
||||
}
|
||||
|
|
@ -353,7 +353,7 @@ func (h *ActionHandler) cleanupGitSourceRepo(ctx context.Context, rs *cstypes.Re
|
|||
if err := gitsource.DeleteDeployKey(project.RepositoryPath, deployKeyName); err != nil {
|
||||
return errors.Wrapf(err, "failed to create deploy key")
|
||||
}
|
||||
h.log.Info().Msgf("deleting existing webhooks")
|
||||
h.log.Info().Msg("deleting existing webhooks")
|
||||
if err := gitsource.DeleteRepoWebhook(project.RepositoryPath, webhookURL); err != nil {
|
||||
return errors.Wrapf(err, "failed to delete repository webhook")
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ func (h *ActionHandler) genWebhookURL(project *csapitypes.Project) (string, erro
|
|||
func (h *ActionHandler) ReconfigProject(ctx context.Context, projectRef string) error {
|
||||
p, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
@ -402,7 +402,7 @@ func (h *ActionHandler) ReconfigProject(ctx context.Context, projectRef string)
|
|||
func (h *ActionHandler) DeleteProject(ctx context.Context, projectRef string) error {
|
||||
p, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
@ -430,7 +430,7 @@ func (h *ActionHandler) DeleteProject(ctx context.Context, projectRef string) er
|
|||
// try to cleanup gitsource configs
|
||||
// we'll log but ignore errors
|
||||
if canDoRepCleanup {
|
||||
h.log.Info().Msgf("cleanup git source repo")
|
||||
h.log.Info().Msg("cleanup git source repo")
|
||||
if err := h.cleanupGitSourceRepo(ctx, rs, user, la, p); err != nil {
|
||||
h.log.Err(err).Msgf("failed to cleanup git source repo: %+v", err)
|
||||
}
|
||||
|
|
@ -447,7 +447,7 @@ func (h *ActionHandler) ProjectCreateRun(ctx context.Context, projectRef, branch
|
|||
|
||||
p, _, err := h.configstoreClient.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
@ -502,7 +502,7 @@ func (h *ActionHandler) ProjectCreateRun(ctx context.Context, projectRef, branch
|
|||
|
||||
gitRefType, name, err := gitSource.RefType(refName)
|
||||
if err != nil {
|
||||
return util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsg("failed to get refType for ref %q", refName))
|
||||
return util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsgf("failed to get refType for ref %q", refName))
|
||||
}
|
||||
ref, err := gitSource.GetRef(p.RepositoryPath, refName)
|
||||
if err != nil {
|
||||
|
|
@ -583,12 +583,12 @@ func (h *ActionHandler) ProjectCreateRun(ctx context.Context, projectRef, branch
|
|||
func (h *ActionHandler) getRemoteRepoAccessData(ctx context.Context, linkedAccountID string) (*cstypes.User, *cstypes.RemoteSource, *cstypes.LinkedAccount, error) {
|
||||
user, _, err := h.configstoreClient.GetUserByLinkedAccount(ctx, linkedAccountID)
|
||||
if err != nil {
|
||||
return nil, nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user with linked account id %q", linkedAccountID))
|
||||
return nil, nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user with linked account id %q", linkedAccountID))
|
||||
}
|
||||
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return nil, nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
var la *cstypes.LinkedAccount
|
||||
|
|
@ -605,7 +605,7 @@ func (h *ActionHandler) getRemoteRepoAccessData(ctx context.Context, linkedAccou
|
|||
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, la.RemoteSourceID)
|
||||
if err != nil {
|
||||
return nil, nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", la.RemoteSourceID))
|
||||
return nil, nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", la.RemoteSourceID))
|
||||
}
|
||||
|
||||
return user, rs, la, nil
|
||||
|
|
@ -619,7 +619,7 @@ func (h *ActionHandler) RefreshRemoteRepositoryInfo(ctx context.Context, project
|
|||
|
||||
p, err := h.GetProject(ctx, projectRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
@ -632,7 +632,7 @@ func (h *ActionHandler) RefreshRemoteRepositoryInfo(ctx context.Context, project
|
|||
|
||||
gitSource, _, _, err := h.getUserGitSource(ctx, p.RemoteSourceID, curUserID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", p.RemoteSourceID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", p.RemoteSourceID))
|
||||
}
|
||||
|
||||
repoInfo, err := gitSource.GetRepoInfo(p.RepositoryPath)
|
||||
|
|
@ -655,7 +655,7 @@ func (h *ActionHandler) RefreshRemoteRepositoryInfo(ctx context.Context, project
|
|||
DefaultBranch: repoInfo.DefaultBranch,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("updating project")
|
||||
h.log.Info().Msg("updating project")
|
||||
rp, _, err := h.configstoreClient.UpdateProject(ctx, p.ID, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to update project"))
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje
|
|||
|
||||
user, _, err := h.configstoreClient.GetUser(ctx, curUserID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q", curUserID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q", curUserID))
|
||||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid project group name %q", req.Name), serrors.InvalidProjectName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid project group name %q", req.Name), serrors.InvalidProjectName())
|
||||
}
|
||||
|
||||
pg, _, err := h.configstoreClient.GetProjectGroup(ctx, req.ParentRef)
|
||||
|
|
@ -90,7 +90,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje
|
|||
if util.RemoteErrorIs(err, util.ErrNotExist) {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, serrors.ParentProjectGroupDoesNotExist())
|
||||
}
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get parent project group %q", req.ParentRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get parent project group %q", req.ParentRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, pg.OwnerType, pg.OwnerID)
|
||||
|
|
@ -116,7 +116,7 @@ func (h *ActionHandler) CreateProjectGroup(ctx context.Context, req *CreateProje
|
|||
Visibility: req.Visibility,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating projectGroup")
|
||||
h.log.Info().Msg("creating projectGroup")
|
||||
rp, _, err := h.configstoreClient.CreateProjectGroup(ctx, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create project group"))
|
||||
|
|
@ -136,7 +136,7 @@ type UpdateProjectGroupRequest struct {
|
|||
func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef string, req *UpdateProjectGroupRequest) (*csapitypes.ProjectGroup, error) {
|
||||
pg, _, err := h.configstoreClient.GetProjectGroup(ctx, projectGroupRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project group %q", projectGroupRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project group %q", projectGroupRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, pg.OwnerType, pg.OwnerID)
|
||||
|
|
@ -163,7 +163,7 @@ func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef
|
|||
Visibility: pg.Visibility,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("updating project group")
|
||||
h.log.Info().Msg("updating project group")
|
||||
rp, _, err := h.configstoreClient.UpdateProjectGroup(ctx, pg.ID, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create project group"))
|
||||
|
|
@ -176,7 +176,7 @@ func (h *ActionHandler) UpdateProjectGroup(ctx context.Context, projectGroupRef
|
|||
func (h *ActionHandler) DeleteProjectGroup(ctx context.Context, projectRef string) error {
|
||||
p, _, err := h.configstoreClient.GetProjectGroup(ctx, projectRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q", projectRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q", projectRef))
|
||||
}
|
||||
|
||||
isProjectOwner, err := h.IsAuthUserProjectOwner(ctx, p.OwnerType, p.OwnerID)
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemot
|
|||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid remotesource name %q", req.Name), serrors.InvalidRemoteSourceName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid remotesource name %q", req.Name), serrors.InvalidRemoteSourceName())
|
||||
}
|
||||
|
||||
if req.Name == "" {
|
||||
|
|
@ -123,7 +123,7 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemot
|
|||
|
||||
// validate if the remote source type supports the required auth type
|
||||
if !cstypes.SourceSupportsAuthType(cstypes.RemoteSourceType(req.Type), cstypes.RemoteSourceAuthType(req.AuthType)) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType), serrors.InvalidRemoteSourceAuthType())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("remotesource type %q doesn't support auth type %q", req.Type, req.AuthType), serrors.InvalidRemoteSourceAuthType())
|
||||
}
|
||||
|
||||
if req.AuthType == string(cstypes.RemoteSourceAuthTypeOauth2) {
|
||||
|
|
@ -159,7 +159,7 @@ func (h *ActionHandler) CreateRemoteSource(ctx context.Context, req *CreateRemot
|
|||
LoginEnabled: loginEnabled,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating remotesource")
|
||||
h.log.Info().Msg("creating remotesource")
|
||||
rs, _, err := h.configstoreClient.CreateRemoteSource(ctx, creq)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to create remotesource")
|
||||
|
|
@ -195,7 +195,7 @@ func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, req *UpdateRemot
|
|||
|
||||
if req.Name != nil {
|
||||
if !util.ValidateName(*req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid remotesource name %q", *req.Name), serrors.InvalidRemoteSourceName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid remotesource name %q", *req.Name), serrors.InvalidRemoteSourceName())
|
||||
}
|
||||
if *req.Name == "" {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remotesource name required"), serrors.InvalidRemoteSourceName())
|
||||
|
|
@ -257,7 +257,7 @@ func (h *ActionHandler) UpdateRemoteSource(ctx context.Context, req *UpdateRemot
|
|||
LoginEnabled: rs.LoginEnabled,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("updating remotesource")
|
||||
h.log.Info().Msg("updating remotesource")
|
||||
rs, _, err = h.configstoreClient.UpdateRemoteSource(ctx, req.RemoteSourceRef, creq)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to update remotesource")
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ func (h *ActionHandler) RunAction(ctx context.Context, req *RunActionsRequest) (
|
|||
}
|
||||
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong run action type %q", req.ActionType))
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong run action type %q", req.ActionType))
|
||||
}
|
||||
|
||||
return runResp, nil
|
||||
|
|
@ -356,7 +356,7 @@ func (h *ActionHandler) RunTaskAction(ctx context.Context, req *RunTaskActionsRe
|
|||
case RunTaskActionTypeApprove:
|
||||
rt, ok := runResp.Run.Tasks[req.TaskID]
|
||||
if !ok {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run %q doesn't have task %q", req.RunNumber, req.TaskID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("run %q doesn't have task %q", req.RunNumber, req.TaskID))
|
||||
}
|
||||
|
||||
approvers := []string{}
|
||||
|
|
@ -373,7 +373,7 @@ func (h *ActionHandler) RunTaskAction(ctx context.Context, req *RunTaskActionsRe
|
|||
|
||||
for _, approver := range approvers {
|
||||
if approver == curUserID {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user %q alredy approved the task", approver))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user %q alredy approved the task", approver))
|
||||
}
|
||||
}
|
||||
approvers = append(approvers, curUserID)
|
||||
|
|
@ -396,7 +396,7 @@ func (h *ActionHandler) RunTaskAction(ctx context.Context, req *RunTaskActionsRe
|
|||
}
|
||||
|
||||
default:
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong run task action type %q", req.ActionType))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong run task action type %q", req.ActionType))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -590,7 +590,7 @@ func (h *ActionHandler) CreateRuns(ctx context.Context, req *CreateRunRequest) e
|
|||
|
||||
config, err := config.ParseConfig([]byte(data), configFormat, configContext)
|
||||
if err != nil {
|
||||
h.log.Err(err).Msgf("failed to parse config")
|
||||
h.log.Err(err).Msg("failed to parse config")
|
||||
|
||||
// create a run (per config file) with a generic error since we cannot parse
|
||||
// it and know how many runs are defined
|
||||
|
|
@ -605,7 +605,7 @@ func (h *ActionHandler) CreateRuns(ctx context.Context, req *CreateRunRequest) e
|
|||
}
|
||||
|
||||
if _, _, err := h.runserviceClient.CreateRun(ctx, createRunReq); err != nil {
|
||||
h.log.Err(err).Msgf("failed to create run")
|
||||
h.log.Err(err).Msg("failed to create run")
|
||||
return APIErrorFromRemoteError(err)
|
||||
}
|
||||
return nil
|
||||
|
|
@ -613,12 +613,12 @@ func (h *ActionHandler) CreateRuns(ctx context.Context, req *CreateRunRequest) e
|
|||
|
||||
for _, run := range config.Runs {
|
||||
if SkipRunMessage.MatchString(req.Message) {
|
||||
h.log.Debug().Msgf("skipping run since special commit message")
|
||||
h.log.Debug().Msg("skipping run since special commit message")
|
||||
continue
|
||||
}
|
||||
|
||||
if match := types.MatchWhen(run.When.ToWhen(), req.RefType, req.Branch, req.Tag, req.Ref); !match {
|
||||
h.log.Debug().Msgf("skipping run since when condition doesn't match")
|
||||
h.log.Debug().Msg("skipping run since when condition doesn't match")
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
@ -635,7 +635,7 @@ func (h *ActionHandler) CreateRuns(ctx context.Context, req *CreateRunRequest) e
|
|||
}
|
||||
|
||||
if _, _, err := h.runserviceClient.CreateRun(ctx, createRunReq); err != nil {
|
||||
h.log.Err(err).Msgf("failed to create run")
|
||||
h.log.Err(err).Msg("failed to create run")
|
||||
return APIErrorFromRemoteError(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -653,7 +653,7 @@ func (h *ActionHandler) fetchConfigFiles(ctx context.Context, gitSource gitsourc
|
|||
if err == nil {
|
||||
return true, nil
|
||||
}
|
||||
h.log.Err(err).Msgf("get file err")
|
||||
h.log.Err(err).Msg("get file err")
|
||||
}
|
||||
return false, nil
|
||||
})
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func (h *ActionHandler) CreateSecret(ctx context.Context, req *CreateSecretReque
|
|||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid secret name %q", req.Name), serrors.InvalidSecretName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid secret name %q", req.Name), serrors.InvalidSecretName())
|
||||
}
|
||||
|
||||
creq := &csapitypes.CreateUpdateSecretRequest{
|
||||
|
|
@ -93,10 +93,10 @@ func (h *ActionHandler) CreateSecret(ctx context.Context, req *CreateSecretReque
|
|||
var rs *csapitypes.Secret
|
||||
switch req.ParentType {
|
||||
case cstypes.ObjectKindProjectGroup:
|
||||
h.log.Info().Msgf("creating project group secret")
|
||||
h.log.Info().Msg("creating project group secret")
|
||||
rs, _, err = h.configstoreClient.CreateProjectGroupSecret(ctx, req.ParentRef, creq)
|
||||
case cstypes.ObjectKindProject:
|
||||
h.log.Info().Msgf("creating project secret")
|
||||
h.log.Info().Msg("creating project secret")
|
||||
rs, _, err = h.configstoreClient.CreateProjectSecret(ctx, req.ParentRef, creq)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
@ -135,7 +135,7 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, req *UpdateSecretReque
|
|||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid secret name %q", req.Name), serrors.InvalidSecretName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid secret name %q", req.Name), serrors.InvalidSecretName())
|
||||
}
|
||||
|
||||
creq := &csapitypes.CreateUpdateSecretRequest{
|
||||
|
|
@ -147,10 +147,10 @@ func (h *ActionHandler) UpdateSecret(ctx context.Context, req *UpdateSecretReque
|
|||
var rs *csapitypes.Secret
|
||||
switch req.ParentType {
|
||||
case cstypes.ObjectKindProjectGroup:
|
||||
h.log.Info().Msgf("updating project group secret")
|
||||
h.log.Info().Msg("updating project group secret")
|
||||
rs, _, err = h.configstoreClient.UpdateProjectGroupSecret(ctx, req.ParentRef, req.SecretName, creq)
|
||||
case cstypes.ObjectKindProject:
|
||||
h.log.Info().Msgf("updating project secret")
|
||||
h.log.Info().Msg("updating project secret")
|
||||
rs, _, err = h.configstoreClient.UpdateProjectSecret(ctx, req.ParentRef, req.SecretName, creq)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
@ -172,10 +172,10 @@ func (h *ActionHandler) DeleteSecret(ctx context.Context, parentType cstypes.Obj
|
|||
|
||||
switch parentType {
|
||||
case cstypes.ObjectKindProjectGroup:
|
||||
h.log.Info().Msgf("deleting project group secret")
|
||||
h.log.Info().Msg("deleting project group secret")
|
||||
_, err = h.configstoreClient.DeleteProjectGroupSecret(ctx, parentRef, name)
|
||||
case cstypes.ObjectKindProject:
|
||||
h.log.Info().Msgf("deleting project secret")
|
||||
h.log.Info().Msg("deleting project secret")
|
||||
_, err = h.configstoreClient.DeleteProjectSecret(ctx, parentRef, name)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -68,12 +68,12 @@ func (h *ActionHandler) GetCurrentUser(ctx context.Context) (*PrivateUserRespons
|
|||
|
||||
tokens, _, err := h.configstoreClient.GetUserTokens(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q tokens", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q tokens", user.ID))
|
||||
}
|
||||
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
return &PrivateUserResponse{User: user, Tokens: tokens, LinkedAccounts: linkedAccounts}, nil
|
||||
|
|
@ -201,12 +201,12 @@ func (h *ActionHandler) GetUsers(ctx context.Context, req *GetUsersRequest) (*Ge
|
|||
for i, user := range csusers {
|
||||
tokens, _, err := h.configstoreClient.GetUserTokens(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q tokens", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q tokens", user.ID))
|
||||
}
|
||||
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
users[i] = &PrivateUserResponse{User: user, Tokens: tokens, LinkedAccounts: linkedAccounts}
|
||||
|
|
@ -233,14 +233,14 @@ func (h *ActionHandler) CreateUser(ctx context.Context, req *CreateUserRequest)
|
|||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user name required"), serrors.InvalidUserName())
|
||||
}
|
||||
if !util.ValidateName(req.UserName) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid user name %q", req.UserName), serrors.InvalidUserName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid user name %q", req.UserName), serrors.InvalidUserName())
|
||||
}
|
||||
|
||||
creq := &csapitypes.CreateUserRequest{
|
||||
UserName: req.UserName,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating user")
|
||||
h.log.Info().Msg("creating user")
|
||||
u, _, err := h.configstoreClient.CreateUser(ctx, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create user"))
|
||||
|
|
@ -276,7 +276,7 @@ func (h *ActionHandler) CreateUserToken(ctx context.Context, req *CreateUserToke
|
|||
|
||||
tokens, _, err := h.configstoreClient.GetUserTokens(ctx, user.ID)
|
||||
if err != nil {
|
||||
return "", APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q tokens", user.ID))
|
||||
return "", APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q tokens", user.ID))
|
||||
}
|
||||
|
||||
var token *cstypes.UserToken
|
||||
|
|
@ -287,10 +287,10 @@ func (h *ActionHandler) CreateUserToken(ctx context.Context, req *CreateUserToke
|
|||
}
|
||||
}
|
||||
if token != nil {
|
||||
return "", util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user %q already have a token with name %q", userRef, req.TokenName), serrors.UserTokenAlreadyExists())
|
||||
return "", util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user %q already have a token with name %q", userRef, req.TokenName), serrors.UserTokenAlreadyExists())
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating user token")
|
||||
h.log.Info().Msg("creating user token")
|
||||
creq := &csapitypes.CreateUserTokenRequest{
|
||||
TokenName: req.TokenName,
|
||||
}
|
||||
|
|
@ -320,11 +320,11 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
userRef := req.UserRef
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, req.RemoteSourceName)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", req.RemoteSourceName))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", req.RemoteSourceName))
|
||||
}
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, userRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", userRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", userRef))
|
||||
}
|
||||
|
||||
var la *cstypes.LinkedAccount
|
||||
|
|
@ -335,7 +335,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
}
|
||||
}
|
||||
if la != nil {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user %q already have a linked account for remote source %q", userRef, rs.Name), serrors.LinkedAccountAlreadyExists())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user %q already have a linked account for remote source %q", userRef, rs.Name), serrors.LinkedAccountAlreadyExists())
|
||||
}
|
||||
|
||||
userSource, err := scommon.GetUserSource(rs, req.RemoteUserName, req.RemotePassword, req.Oauth2AccessToken)
|
||||
|
|
@ -375,7 +375,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
Oauth2AccessTokenExpiresAt: req.Oauth2AccessTokenExpiresAt,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating linked account")
|
||||
h.log.Info().Msg("creating linked account")
|
||||
la, _, err = h.configstoreClient.CreateUserLA(ctx, userRef, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create linked account"))
|
||||
|
|
@ -388,7 +388,7 @@ func (h *ActionHandler) CreateUserLA(ctx context.Context, req *CreateUserLAReque
|
|||
func (h *ActionHandler) UpdateUserLA(ctx context.Context, userRef string, la *cstypes.LinkedAccount) error {
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, userRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", userRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", userRef))
|
||||
}
|
||||
|
||||
laFound := false
|
||||
|
|
@ -399,7 +399,7 @@ func (h *ActionHandler) UpdateUserLA(ctx context.Context, userRef string, la *cs
|
|||
}
|
||||
}
|
||||
if !laFound {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user %q doesn't have a linked account with id %q", userRef, la.ID), serrors.LinkedAccountDoesNotExist())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user %q doesn't have a linked account with id %q", userRef, la.ID), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
creq := &csapitypes.UpdateUserLARequest{
|
||||
|
|
@ -479,12 +479,12 @@ func (h *ActionHandler) RegisterUser(ctx context.Context, req *RegisterUserReque
|
|||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user name required"), serrors.InvalidUserName())
|
||||
}
|
||||
if !util.ValidateName(req.UserName) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid user name %q", req.UserName), serrors.InvalidUserName())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid user name %q", req.UserName), serrors.InvalidUserName())
|
||||
}
|
||||
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, req.RemoteSourceName)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", req.RemoteSourceName))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", req.RemoteSourceName))
|
||||
}
|
||||
if !rs.RegistrationEnabled {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remote source user registration is disabled"))
|
||||
|
|
@ -505,10 +505,10 @@ func (h *ActionHandler) RegisterUser(ctx context.Context, req *RegisterUserReque
|
|||
|
||||
if _, _, err := h.configstoreClient.GetLinkedAccountByRemoteUserAndSource(ctx, remoteUserInfo.ID, rs.ID); err != nil {
|
||||
if !util.RemoteErrorIs(err, util.ErrNotExist) {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get linked account for remote user id %q and remote source %q", remoteUserInfo.ID, rs.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get linked account for remote user id %q and remote source %q", remoteUserInfo.ID, rs.ID))
|
||||
}
|
||||
} else {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("linked account for remote user id %q for remote source %q already exists", remoteUserInfo.ID, rs.ID), serrors.LinkedAccountAlreadyExists())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("linked account for remote user id %q for remote source %q already exists", remoteUserInfo.ID, rs.ID), serrors.LinkedAccountAlreadyExists())
|
||||
}
|
||||
|
||||
var userAccessToken string
|
||||
|
|
@ -538,7 +538,7 @@ func (h *ActionHandler) RegisterUser(ctx context.Context, req *RegisterUserReque
|
|||
},
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating user account")
|
||||
h.log.Info().Msg("creating user account")
|
||||
u, _, err := h.configstoreClient.CreateUser(ctx, creq)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create linked account"))
|
||||
|
|
@ -569,7 +569,7 @@ type LoginUserResponse struct {
|
|||
func (h *ActionHandler) LoginUser(ctx context.Context, req *LoginUserRequest) (*LoginUserResponse, error) {
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, req.RemoteSourceName)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", req.RemoteSourceName))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", req.RemoteSourceName))
|
||||
}
|
||||
if !rs.LoginEnabled {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("remote source user login is disabled"))
|
||||
|
|
@ -590,12 +590,12 @@ func (h *ActionHandler) LoginUser(ctx context.Context, req *LoginUserRequest) (*
|
|||
|
||||
user, _, err := h.configstoreClient.GetUserByLinkedAccountRemoteUserAndSource(ctx, remoteUserInfo.ID, rs.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user for remote user id %q and remote source %q", remoteUserInfo.ID, rs.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user for remote user id %q and remote source %q", remoteUserInfo.ID, rs.ID))
|
||||
}
|
||||
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
var la *cstypes.LinkedAccount
|
||||
|
|
@ -606,7 +606,7 @@ func (h *ActionHandler) LoginUser(ctx context.Context, req *LoginUserRequest) (*
|
|||
}
|
||||
}
|
||||
if la == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("linked account for user %q for remote source %q doesn't exist", user.Name, rs.Name), serrors.LinkedAccountDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("linked account for user %q for remote source %q doesn't exist", user.Name, rs.Name), serrors.LinkedAccountDoesNotExist())
|
||||
}
|
||||
|
||||
userAccessToken := la.UserAccessToken
|
||||
|
|
@ -699,7 +699,7 @@ type AuthorizeResponse struct {
|
|||
func (h *ActionHandler) Authorize(ctx context.Context, req *AuthorizeRequest) (*AuthorizeResponse, error) {
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, req.RemoteSourceName)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", req.RemoteSourceName))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", req.RemoteSourceName))
|
||||
}
|
||||
|
||||
userSource, err := scommon.GetUserSource(rs, req.RemoteUserName, req.RemotePassword, req.Oauth2AccessToken)
|
||||
|
|
@ -729,7 +729,7 @@ type RemoteSourceAuthResponse struct {
|
|||
func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSourceName, remoteUsername, remotePassword string, requestType RemoteSourceRequestType, req interface{}) (*RemoteSourceAuthResponse, error) {
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, remoteSourceName)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", remoteSourceName))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", remoteSourceName))
|
||||
}
|
||||
|
||||
switch requestType {
|
||||
|
|
@ -738,7 +738,7 @@ func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSource
|
|||
|
||||
user, _, err := h.configstoreClient.GetUser(ctx, req.UserRef)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q", req.UserRef))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q", req.UserRef))
|
||||
}
|
||||
|
||||
// user must be already logged in the create a linked account and can create a
|
||||
|
|
@ -754,7 +754,7 @@ func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSource
|
|||
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
var la *cstypes.LinkedAccount
|
||||
|
|
@ -765,7 +765,7 @@ func (h *ActionHandler) HandleRemoteSourceAuth(ctx context.Context, remoteSource
|
|||
}
|
||||
}
|
||||
if la != nil {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("user %q already have a linked account for remote source %q", req.UserRef, rs.Name), serrors.LinkedAccountAlreadyExists())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("user %q already have a linked account for remote source %q", req.UserRef, rs.Name), serrors.LinkedAccountAlreadyExists())
|
||||
}
|
||||
|
||||
case RemoteSourceRequestTypeLoginUser:
|
||||
|
|
@ -980,7 +980,7 @@ func (h *ActionHandler) HandleOauth2Callback(ctx context.Context, code, state st
|
|||
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, remoteSourceName)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", remoteSourceName))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", remoteSourceName))
|
||||
}
|
||||
|
||||
oauth2Client, err := scommon.GetOauth2Client(rs)
|
||||
|
|
@ -1017,7 +1017,7 @@ func (h *ActionHandler) DeleteUserLA(ctx context.Context, userRef, laID string)
|
|||
|
||||
user, _, err := h.configstoreClient.GetUser(ctx, userRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q", userRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q", userRef))
|
||||
}
|
||||
|
||||
// only admin or the same logged user can create a token
|
||||
|
|
@ -1041,7 +1041,7 @@ func (h *ActionHandler) DeleteUserToken(ctx context.Context, userRef, tokenName
|
|||
|
||||
user, _, err := h.configstoreClient.GetUser(ctx, userRef)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q", userRef))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q", userRef))
|
||||
}
|
||||
|
||||
// only admin or the same logged user can create a token
|
||||
|
|
@ -1085,7 +1085,7 @@ func (h *ActionHandler) UserCreateRun(ctx context.Context, req *UserCreateRunReq
|
|||
|
||||
user, _, err := h.configstoreClient.GetUser(ctx, curUserID)
|
||||
if err != nil {
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q", curUserID))
|
||||
return APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q", curUserID))
|
||||
}
|
||||
|
||||
// Verify that the repo is owned by the user
|
||||
|
|
@ -1094,10 +1094,10 @@ func (h *ActionHandler) UserCreateRun(ctx context.Context, req *UserCreateRunReq
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("empty repo uuid"))
|
||||
}
|
||||
if len(repoParts) != 2 {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong repo path: %q", req.RepoPath))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong repo path: %q", req.RepoPath))
|
||||
}
|
||||
if repoParts[0] != user.ID {
|
||||
return util.NewAPIError(util.ErrUnauthorized, util.WithAPIErrorMsg("repo %q not owned", req.RepoPath))
|
||||
return util.NewAPIError(util.ErrUnauthorized, util.WithAPIErrorMsgf("repo %q not owned", req.RepoPath))
|
||||
}
|
||||
|
||||
branch := req.Branch
|
||||
|
|
@ -1135,7 +1135,7 @@ func (h *ActionHandler) UserCreateRun(ctx context.Context, req *UserCreateRunReq
|
|||
|
||||
gitRefType, name, err := gitSource.RefType(ref)
|
||||
if err != nil {
|
||||
return util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsg("failed to get refType for ref %q", ref))
|
||||
return util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsgf("failed to get refType for ref %q", ref))
|
||||
}
|
||||
|
||||
var pullRequestID string
|
||||
|
|
@ -1279,12 +1279,12 @@ func (h *ActionHandler) GetUserByLinkedAccountRemoteUserAndSource(ctx context.Co
|
|||
|
||||
tokens, _, err := h.configstoreClient.GetUserTokens(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q tokens", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q tokens", user.ID))
|
||||
}
|
||||
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
return &PrivateUserResponse{User: user, Tokens: tokens, LinkedAccounts: linkedAccounts}, nil
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableR
|
|||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid variable name %q", req.Name), serrors.InvalidVariableName())
|
||||
return nil, nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid variable name %q", req.Name), serrors.InvalidVariableName())
|
||||
}
|
||||
|
||||
if len(req.Values) == 0 {
|
||||
|
|
@ -108,10 +108,10 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableR
|
|||
var err error
|
||||
cssecrets, _, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, true)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project group %q secrets", req.ParentRef))
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project group %q secrets", req.ParentRef))
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating project group variable")
|
||||
h.log.Info().Msg("creating project group variable")
|
||||
rv, _, err = h.configstoreClient.CreateProjectGroupVariable(ctx, req.ParentRef, creq)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create variable"))
|
||||
|
|
@ -120,10 +120,10 @@ func (h *ActionHandler) CreateVariable(ctx context.Context, req *CreateVariableR
|
|||
var err error
|
||||
cssecrets, _, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, true)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q secrets", req.ParentRef))
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q secrets", req.ParentRef))
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating project variable")
|
||||
h.log.Info().Msg("creating project variable")
|
||||
rv, _, err = h.configstoreClient.CreateProjectVariable(ctx, req.ParentRef, creq)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create variable"))
|
||||
|
|
@ -155,7 +155,7 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
|
|||
}
|
||||
|
||||
if !util.ValidateName(req.Name) {
|
||||
return nil, nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("invalid variable name %q", req.Name), serrors.InvalidVariableName())
|
||||
return nil, nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("invalid variable name %q", req.Name), serrors.InvalidVariableName())
|
||||
}
|
||||
|
||||
if len(req.Values) == 0 {
|
||||
|
|
@ -175,10 +175,10 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
|
|||
var err error
|
||||
cssecrets, _, err = h.configstoreClient.GetProjectGroupSecrets(ctx, req.ParentRef, true)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project group %q secrets", req.ParentRef))
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project group %q secrets", req.ParentRef))
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating project group variable")
|
||||
h.log.Info().Msg("creating project group variable")
|
||||
rv, _, err = h.configstoreClient.UpdateProjectGroupVariable(ctx, req.ParentRef, req.VariableName, creq)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create variable"))
|
||||
|
|
@ -187,10 +187,10 @@ func (h *ActionHandler) UpdateVariable(ctx context.Context, req *UpdateVariableR
|
|||
var err error
|
||||
cssecrets, _, err = h.configstoreClient.GetProjectSecrets(ctx, req.ParentRef, true)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %q secrets", req.ParentRef))
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %q secrets", req.ParentRef))
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating project variable")
|
||||
h.log.Info().Msg("creating project variable")
|
||||
rv, _, err = h.configstoreClient.UpdateProjectVariable(ctx, req.ParentRef, req.VariableName, creq)
|
||||
if err != nil {
|
||||
return nil, nil, APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to create variable"))
|
||||
|
|
@ -212,10 +212,10 @@ func (h *ActionHandler) DeleteVariable(ctx context.Context, parentType cstypes.O
|
|||
|
||||
switch parentType {
|
||||
case cstypes.ObjectKindProjectGroup:
|
||||
h.log.Info().Msgf("deleting project group variable")
|
||||
h.log.Info().Msg("deleting project group variable")
|
||||
_, err = h.configstoreClient.DeleteProjectGroupVariable(ctx, parentRef, name)
|
||||
case cstypes.ObjectKindProject:
|
||||
h.log.Info().Msgf("deleting project variable")
|
||||
h.log.Info().Msg("deleting project variable")
|
||||
_, err = h.configstoreClient.DeleteProjectVariable(ctx, parentRef, name)
|
||||
}
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ func GetConfigTypeRef(r *http.Request) (cstypes.ObjectKind, string, error) {
|
|||
vars := mux.Vars(r)
|
||||
projectRef, err := url.PathUnescape(vars["projectref"])
|
||||
if err != nil {
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsg("wrong projectref %q", vars["projectref"]))
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsgf("wrong projectref %q", vars["projectref"]))
|
||||
}
|
||||
if projectRef != "" {
|
||||
return cstypes.ObjectKindProject, projectRef, nil
|
||||
|
|
@ -49,7 +49,7 @@ func GetConfigTypeRef(r *http.Request) (cstypes.ObjectKind, string, error) {
|
|||
|
||||
projectGroupRef, err := url.PathUnescape(vars["projectgroupref"])
|
||||
if err != nil {
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsg("wrong projectgroupref %q", vars["projectgroupref"]))
|
||||
return "", "", util.NewAPIErrorWrap(util.ErrBadRequest, err, util.WithAPIErrorMsgf("wrong projectgroupref %q", vars["projectgroupref"]))
|
||||
}
|
||||
if projectGroupRef != "" {
|
||||
return cstypes.ObjectKindProjectGroup, projectGroupRef, nil
|
||||
|
|
@ -92,7 +92,7 @@ func parseRequestOptions(r *http.Request) (*requestOptions, error) {
|
|||
case gwapitypes.SortDirectionAsc:
|
||||
case gwapitypes.SortDirectionDesc:
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ func (h *RuntaskHandler) do(r *http.Request) (*gwapitypes.RunTaskResponse, error
|
|||
|
||||
rt, ok := run.Tasks[taskID]
|
||||
if !ok {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run %q task %q not found", runNumber, taskID))
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run %q task %q not found", runNumber, taskID))
|
||||
}
|
||||
rct := rc.Tasks[rt.ID]
|
||||
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ func (h *UsersHandler) do(w http.ResponseWriter, r *http.Request) ([]*gwapitypes
|
|||
ausers = ares.Users
|
||||
addCursorHeader(w, ares.Cursor)
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("unknown query_type: %q", queryType))
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("unknown query_type: %q", queryType))
|
||||
}
|
||||
|
||||
users := make([]*gwapitypes.PrivateUserResponse, len(ausers))
|
||||
|
|
@ -324,7 +324,7 @@ func (h *CreateUserLAHandler) createUserLA(ctx context.Context, userRef string,
|
|||
RemoteSourceName: req.RemoteSourceName,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("creating linked account")
|
||||
h.log.Info().Msg("creating linked account")
|
||||
cresp, err := h.ah.HandleRemoteSourceAuth(ctx, req.RemoteSourceName, req.RemoteSourceLoginName, req.RemoteSourceLoginPassword, action.RemoteSourceRequestTypeCreateUserLA, creq)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
@ -629,7 +629,7 @@ func (h *LoginUserHandler) do(w http.ResponseWriter, r *http.Request) (*gwapityp
|
|||
RemoteSourceName: req.RemoteSourceName,
|
||||
}
|
||||
|
||||
h.log.Info().Msgf("logging in user")
|
||||
h.log.Info().Msg("logging in user")
|
||||
cresp, err := h.ah.HandleRemoteSourceAuth(ctx, req.RemoteSourceName, req.LoginName, req.LoginPassword, action.RemoteSourceRequestTypeLoginUser, creq)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
|
|
|
|||
|
|
@ -59,24 +59,24 @@ func (h *webhooksHandler) do(r *http.Request) error {
|
|||
|
||||
projectID := r.URL.Query().Get("projectid")
|
||||
if projectID == "" {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("bad webhook url %q. Missing projectid", r.URL))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("bad webhook url %q. Missing projectid", r.URL))
|
||||
}
|
||||
|
||||
defer r.Body.Close()
|
||||
|
||||
csProject, _, err := h.configstoreClient.GetProject(ctx, projectID)
|
||||
if err != nil {
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get project %s", projectID))
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get project %s", projectID))
|
||||
}
|
||||
project := csProject.Project
|
||||
|
||||
user, _, err := h.configstoreClient.GetUserByLinkedAccount(ctx, project.LinkedAccountID)
|
||||
if err != nil {
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user by linked account %q", project.LinkedAccountID))
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user by linked account %q", project.LinkedAccountID))
|
||||
}
|
||||
linkedAccounts, _, err := h.configstoreClient.GetUserLinkedAccounts(ctx, user.ID)
|
||||
if err != nil {
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get user %q linked accounts", user.ID))
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get user %q linked accounts", user.ID))
|
||||
}
|
||||
|
||||
var la *cstypes.LinkedAccount
|
||||
|
|
@ -88,12 +88,12 @@ func (h *webhooksHandler) do(r *http.Request) error {
|
|||
}
|
||||
|
||||
if la == nil {
|
||||
return util.NewAPIError(util.ErrInternal, util.WithAPIErrorMsg("linked account %q for user %q doesn't exist", project.LinkedAccountID, user.Name))
|
||||
return util.NewAPIError(util.ErrInternal, util.WithAPIErrorMsgf("linked account %q for user %q doesn't exist", project.LinkedAccountID, user.Name))
|
||||
}
|
||||
|
||||
rs, _, err := h.configstoreClient.GetRemoteSource(ctx, la.RemoteSourceID)
|
||||
if err != nil {
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsg("failed to get remote source %q", la.RemoteSourceID))
|
||||
return action.APIErrorFromRemoteError(err, util.WithAPIErrorMsgf("failed to get remote source %q", la.RemoteSourceID))
|
||||
}
|
||||
|
||||
gitSource, err := h.ah.GetGitSource(ctx, rs, user.Name, la)
|
||||
|
|
@ -116,7 +116,7 @@ func (h *webhooksHandler) do(r *http.Request) error {
|
|||
// skip nil webhook data
|
||||
// TODO(sgotti) report the reason of the skip
|
||||
if webhookData == nil {
|
||||
h.log.Info().Msgf("skipping webhook")
|
||||
h.log.Info().Msg("skipping webhook")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -442,11 +442,11 @@ func (g *Gateway) Run(ctx context.Context) error {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Info().Msgf("configstore exiting")
|
||||
log.Info().Msg("configstore exiting")
|
||||
httpServer.Close()
|
||||
case err := <-lerrCh:
|
||||
if err != nil {
|
||||
log.Err(err).Msgf("http server listen error")
|
||||
log.Err(err).Msg("http server listen error")
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,9 +196,9 @@ func (h *AuthChecker) checkAuthResponse(name string, res *checkerResponse) (bool
|
|||
|
||||
if res.failAuth {
|
||||
if res.authErr != nil {
|
||||
return false, util.NewAPIErrorWrap(util.ErrUnauthorized, res.authErr, util.WithAPIErrorMsg("checker %s: auth failed", name))
|
||||
return false, util.NewAPIErrorWrap(util.ErrUnauthorized, res.authErr, util.WithAPIErrorMsgf("checker %s: auth failed", name))
|
||||
}
|
||||
return false, util.NewAPIError(util.ErrUnauthorized, util.WithAPIErrorMsg("checker %s: auth failed (no auth err reported by checker)", name))
|
||||
return false, util.NewAPIError(util.ErrUnauthorized, util.WithAPIErrorMsgf("checker %s: auth failed (no auth err reported by checker)", name))
|
||||
}
|
||||
|
||||
if res.authErr != nil {
|
||||
|
|
|
|||
|
|
@ -187,11 +187,11 @@ func (s *Gitserver) Run(ctx context.Context) error {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Info().Msgf("gitserver exiting")
|
||||
log.Info().Msg("gitserver exiting")
|
||||
httpServer.Close()
|
||||
case err := <-lerrCh:
|
||||
if err != nil {
|
||||
s.log.Err(err).Msgf("http server listen error")
|
||||
s.log.Err(err).Msg("http server listen error")
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,19 +15,19 @@ func (s *Gitserver) repoCleanerLoop(ctx context.Context) {
|
|||
for {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
s.log.Info().Msgf("repoCleaner exiting")
|
||||
s.log.Info().Msg("repoCleaner exiting")
|
||||
|
||||
return
|
||||
case <-time.After(s.c.RepositoryCleanupInterval):
|
||||
if err := s.scanRepos(ctx); err != nil {
|
||||
s.log.Err(err).Msgf("scanRepos error")
|
||||
s.log.Err(err).Msg("scanRepos error")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Gitserver) scanRepos(ctx context.Context) error {
|
||||
s.log.Info().Msgf("repoCleaner scanRepos start")
|
||||
s.log.Info().Msg("repoCleaner scanRepos start")
|
||||
|
||||
usersDir, err := os.ReadDir(s.c.DataDir)
|
||||
if err != nil {
|
||||
|
|
@ -46,12 +46,12 @@ func (s *Gitserver) scanRepos(ctx context.Context) error {
|
|||
}
|
||||
|
||||
if err := s.scanRepo(ctx, filepath.Join(s.c.DataDir, u.Name(), r.Name())); err != nil {
|
||||
s.log.Err(err).Msgf("scanRepo error")
|
||||
s.log.Err(err).Msg("scanRepo error")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s.log.Info().Msgf("repoCleaner scanRepos end")
|
||||
s.log.Info().Msg("repoCleaner scanRepos end")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func (h *ActionHandler) CommitStatusRedelivery(ctx context.Context, projectID st
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if commitStatusDelivery == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("commitStatusDelivery %q doesn't exist", commitStatusDeliveryID), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("commitStatusDelivery %q doesn't exist", commitStatusDeliveryID), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
}
|
||||
|
||||
commitStatus, err := h.d.GetCommitStatusByID(tx, commitStatusDelivery.CommitStatusID)
|
||||
|
|
@ -94,10 +94,10 @@ func (h *ActionHandler) CommitStatusRedelivery(ctx context.Context, projectID st
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if commitStatus == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("commitStatus %q doesn't exist", commitStatusDelivery.CommitStatusID), serrors.CommitStatusDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("commitStatus %q doesn't exist", commitStatusDelivery.CommitStatusID), serrors.CommitStatusDoesNotExist())
|
||||
}
|
||||
if commitStatus.ProjectID != projectID {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("commitStatusDelivery %q doesn't belong to project %q", commitStatusDeliveryID, projectID), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("commitStatusDelivery %q doesn't belong to project %q", commitStatusDeliveryID, projectID), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
}
|
||||
|
||||
commitStatusDeliveries, err := h.d.GetCommitStatusDeliveriesByCommitStatusID(tx, commitStatusDelivery.CommitStatusID, []types.DeliveryStatus{types.DeliveryStatusNotDelivered}, 1, types.SortDirectionDesc)
|
||||
|
|
@ -106,7 +106,7 @@ func (h *ActionHandler) CommitStatusRedelivery(ctx context.Context, projectID st
|
|||
}
|
||||
// check if commitStatus has delivery not delivered
|
||||
if len(commitStatusDeliveries) != 0 {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("the previous delivery of commit status %q hasn't already been delivered", commitStatusDelivery.CommitStatusID), serrors.CommitStatusDeliveryAlreadyInProgress())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("the previous delivery of commit status %q hasn't already been delivered", commitStatusDelivery.CommitStatusID), serrors.CommitStatusDeliveryAlreadyInProgress())
|
||||
}
|
||||
|
||||
newCommitStatusDelivery := types.NewCommitStatusDelivery(tx)
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ func (h *ActionHandler) RunWebhookRedelivery(ctx context.Context, projectID stri
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if runWebhookDelivery == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("runWebhookDelivery %q doesn't exist", runWebhookDeliveryID), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("runWebhookDelivery %q doesn't exist", runWebhookDeliveryID), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
}
|
||||
|
||||
runWebhook, err := h.d.GetRunWebhookByID(tx, runWebhookDelivery.RunWebhookID)
|
||||
|
|
@ -94,10 +94,10 @@ func (h *ActionHandler) RunWebhookRedelivery(ctx context.Context, projectID stri
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if runWebhook == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("runWebhook %q doesn't exist", runWebhookDelivery.RunWebhookID), serrors.RunWebhookDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("runWebhook %q doesn't exist", runWebhookDelivery.RunWebhookID), serrors.RunWebhookDoesNotExist())
|
||||
}
|
||||
if runWebhook.ProjectID != projectID {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("runWebhookDelivery %q doesn't belong to project %q", runWebhookDeliveryID, projectID), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("runWebhookDelivery %q doesn't belong to project %q", runWebhookDeliveryID, projectID), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
}
|
||||
|
||||
runWebhookDeliveries, err := h.d.GetRunWebhookDeliveriesByRunWebhookID(tx, runWebhookDelivery.RunWebhookID, []types.DeliveryStatus{types.DeliveryStatusNotDelivered}, 1, types.SortDirectionDesc)
|
||||
|
|
@ -106,7 +106,7 @@ func (h *ActionHandler) RunWebhookRedelivery(ctx context.Context, projectID stri
|
|||
}
|
||||
// check if runWebhook has delivery not delivered
|
||||
if len(runWebhookDeliveries) != 0 {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("the previous delivery of run webhook %q hasn't already been delivered", runWebhookDelivery.RunWebhookID), serrors.RunWebhookDeliveryAlreadyInProgress())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("the previous delivery of run webhook %q hasn't already been delivered", runWebhookDelivery.RunWebhookID), serrors.RunWebhookDeliveryAlreadyInProgress())
|
||||
}
|
||||
|
||||
newRunWebhookDelivery := types.NewRunWebhookDelivery(tx)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ func parseRequestOptions(r *http.Request) (*requestOptions, error) {
|
|||
case types.SortDirectionAsc:
|
||||
case types.SortDirectionDesc:
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -135,11 +135,11 @@ func statusDescription(state types.CommitState) string {
|
|||
}
|
||||
|
||||
func (n *NotificationService) commitStatusesCleanerLoop(ctx context.Context, commitStatusExpireInterval time.Duration) {
|
||||
n.log.Debug().Msgf("commitStatusesCleanerLoop")
|
||||
n.log.Debug().Msg("commitStatusesCleanerLoop")
|
||||
|
||||
for {
|
||||
if err := n.commitStatusesCleaner(ctx, commitStatusExpireInterval); err != nil {
|
||||
n.log.Warn().Err(err).Msgf("commitStatusesCleaner error")
|
||||
n.log.Warn().Err(err).Msg("commitStatusesCleaner error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(commitStatusesCleanerInterval).C
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func (n *NotificationService) commitStatusDeliveriesHandler(ctx context.Context)
|
|||
|
||||
for _, c := range commitStatusDeliveries {
|
||||
if err := n.handleCommitStatusDelivery(ctx, c.ID); err != nil {
|
||||
n.log.Err(err).Msgf("failed to trigger commit status data delivery event")
|
||||
n.log.Err(err).Msg("failed to trigger commit status data delivery event")
|
||||
}
|
||||
|
||||
curCommitStatusDeliverySequence = c.Sequence
|
||||
|
|
|
|||
|
|
@ -163,13 +163,13 @@ func (n *NotificationService) setupDefaultRouter() http.Handler {
|
|||
func (n *NotificationService) Run(ctx context.Context) error {
|
||||
for {
|
||||
if err := n.run(ctx); err != nil {
|
||||
n.log.Err(err).Msgf("run error")
|
||||
n.log.Err(err).Msg("run error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(1 * time.Second).C
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
n.log.Info().Msgf("notification service exiting")
|
||||
n.log.Info().Msg("notification service exiting")
|
||||
return nil
|
||||
case <-sleepCh:
|
||||
}
|
||||
|
|
@ -216,10 +216,10 @@ func (n *NotificationService) run(ctx context.Context) error {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
n.log.Info().Msgf("notification service run exiting")
|
||||
n.log.Info().Msg("notification service run exiting")
|
||||
case err = <-lerrCh:
|
||||
if err != nil {
|
||||
n.log.Err(err).Msgf("http server listen error")
|
||||
n.log.Err(err).Msg("http server listen error")
|
||||
}
|
||||
case err = <-errCh:
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -823,7 +823,7 @@ func TestProjectRunWebhookRedelivery(t *testing.T) {
|
|||
|
||||
runWebhook := createRunWebhook(t, ctx, ns, project01)
|
||||
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("runWebhookDelivery %q doesn't exist", runWebhookDelivery01), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("runWebhookDelivery %q doesn't exist", runWebhookDelivery01), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
err := ns.ah.RunWebhookRedelivery(ctx, runWebhook.ProjectID, runWebhookDelivery01)
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
})
|
||||
|
|
@ -843,7 +843,7 @@ func TestProjectRunWebhookRedelivery(t *testing.T) {
|
|||
runWebhook = createRunWebhook(t, ctx, ns, project02)
|
||||
createRunWebhookDelivery(t, ctx, ns, runWebhook.ID, types.DeliveryStatusDelivered)
|
||||
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("runWebhookDelivery %q doesn't belong to project %q", runWebhookDelivery.ID, project02), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("runWebhookDelivery %q doesn't belong to project %q", runWebhookDelivery.ID, project02), serrors.RunWebhookDeliveryDoesNotExist())
|
||||
|
||||
err := ns.ah.RunWebhookRedelivery(ctx, project02, runWebhookDelivery.ID)
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
|
|
@ -869,7 +869,7 @@ func TestProjectRunWebhookRedelivery(t *testing.T) {
|
|||
ns.c.WebhookSecret = webhookSecret
|
||||
ns.c.WebhookURL = fmt.Sprintf("%s/%s", wr.exposedURL, "webhooks")
|
||||
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("the previous delivery of run webhook %q hasn't already been delivered", runWebhookDelivery.RunWebhookID), serrors.RunWebhookDeliveryAlreadyInProgress())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("the previous delivery of run webhook %q hasn't already been delivered", runWebhookDelivery.RunWebhookID), serrors.RunWebhookDeliveryAlreadyInProgress())
|
||||
|
||||
err := ns.ah.RunWebhookRedelivery(ctx, runWebhook.ProjectID, runWebhookDelivery.ID)
|
||||
assert.Error(t, err, expectedErr.Error())
|
||||
|
|
@ -1177,7 +1177,7 @@ func TestProjectCommitStatusRedelivery(t *testing.T) {
|
|||
|
||||
commitStatus := createCommitStatus(t, ctx, ns, 1, project01)
|
||||
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("commitStatusDelivery %q doesn't exist", commitStatusDelivery01), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("commitStatusDelivery %q doesn't exist", commitStatusDelivery01), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
err := ns.ah.CommitStatusRedelivery(ctx, commitStatus.ProjectID, commitStatusDelivery01)
|
||||
if err == nil {
|
||||
t.Fatalf("expected error %v, got nil err", expectedErr)
|
||||
|
|
@ -1202,7 +1202,7 @@ func TestProjectCommitStatusRedelivery(t *testing.T) {
|
|||
commitStatus = createCommitStatus(t, ctx, ns, 1, project02)
|
||||
createCommitStatusDelivery(t, ctx, ns, commitStatus.ID, types.DeliveryStatusDelivered)
|
||||
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("commitStatusDelivery %q doesn't belong to project %q", commitStatusDelivery.ID, project02), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
expectedErr := util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("commitStatusDelivery %q doesn't belong to project %q", commitStatusDelivery.ID, project02), serrors.CommitStatusDeliveryDoesNotExist())
|
||||
|
||||
err := ns.ah.CommitStatusRedelivery(ctx, project02, commitStatusDelivery.ID)
|
||||
if err == nil {
|
||||
|
|
@ -1230,7 +1230,7 @@ func TestProjectCommitStatusRedelivery(t *testing.T) {
|
|||
cs := setupStubCommitStatusUpdater()
|
||||
ns.u = cs
|
||||
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("the previous delivery of commit status %q hasn't already been delivered", commitStatusDelivery.CommitStatusID), serrors.CommitStatusDeliveryAlreadyInProgress())
|
||||
expectedErr := util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("the previous delivery of commit status %q hasn't already been delivered", commitStatusDelivery.CommitStatusID), serrors.CommitStatusDeliveryAlreadyInProgress())
|
||||
|
||||
err := ns.ah.CommitStatusRedelivery(ctx, commitStatus.ProjectID, commitStatusDelivery.ID)
|
||||
if err == nil {
|
||||
|
|
|
|||
|
|
@ -124,13 +124,13 @@ func (n *NotificationService) runEventsHandler(ctx context.Context) error {
|
|||
case rstypes.RunPhaseChanged:
|
||||
commitStatus, err = n.generateCommitStatus(ctx, ev)
|
||||
if err != nil {
|
||||
n.log.Error().Msgf("failed to generate commit status")
|
||||
n.log.Error().Msg("failed to generate commit status")
|
||||
}
|
||||
if n.c.WebhookURL != "" {
|
||||
runWebhook := n.generatewebhook(ctx, ev)
|
||||
webhookPayload, err = json.Marshal(runWebhook)
|
||||
if err != nil {
|
||||
n.log.Error().Msgf("failed to unmarshal run webhook")
|
||||
n.log.Error().Msg("failed to unmarshal run webhook")
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func (n *NotificationService) runWebhookDeliveriesHandler(ctx context.Context) e
|
|||
|
||||
for _, r := range runWebhookDeliveries {
|
||||
if err := n.handleRunWebhookDelivery(ctx, r.ID); err != nil {
|
||||
n.log.Err(err).Msgf("failed to trigger run webhook delivery event")
|
||||
n.log.Err(err).Msg("failed to trigger run webhook delivery event")
|
||||
}
|
||||
|
||||
curRunWebhookDeliverySequence = r.Sequence
|
||||
|
|
|
|||
|
|
@ -129,11 +129,11 @@ func (n *NotificationService) generatewebhook(ctx context.Context, ev *rstypes.R
|
|||
}
|
||||
|
||||
func (n *NotificationService) runWebhooksCleanerLoop(ctx context.Context, runWebhookExpireInterval time.Duration) {
|
||||
n.log.Debug().Msgf("webhookCleanerLoop")
|
||||
n.log.Debug().Msg("webhookCleanerLoop")
|
||||
|
||||
for {
|
||||
if err := n.runWebhooksCleaner(ctx, runWebhookExpireInterval); err != nil {
|
||||
n.log.Warn().Err(err).Msgf("webhooksCleaner error")
|
||||
n.log.Warn().Err(err).Msg("webhooksCleaner error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(runWebhooksCleanerInterval).C
|
||||
|
|
|
|||
|
|
@ -354,21 +354,21 @@ func (h *ActionHandler) newRun(ctx context.Context, req *RunCreateRequest) (*typ
|
|||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run group is empty"), serrors.InvalidRunGroup())
|
||||
}
|
||||
if !path.IsAbs(req.Group) {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run group %q must be an absolute path", req.Group), serrors.InvalidRunGroup())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("run group %q must be an absolute path", req.Group), serrors.InvalidRunGroup())
|
||||
}
|
||||
if req.RunConfigTasks == nil && len(setupErrors) == 0 {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("empty run config tasks and setup errors"))
|
||||
}
|
||||
|
||||
if err := runconfig.CheckRunConfigTasks(rcts); err != nil {
|
||||
h.log.Err(err).Msgf("check run config tasks failed")
|
||||
h.log.Err(err).Msg("check run config tasks failed")
|
||||
setupErrors = append(setupErrors, err.Error())
|
||||
}
|
||||
|
||||
// generate tasks levels
|
||||
if len(setupErrors) == 0 {
|
||||
if err := runconfig.GenTasksLevels(rcts); err != nil {
|
||||
h.log.Err(err).Msgf("gen tasks leveles failed")
|
||||
h.log.Err(err).Msg("gen tasks leveles failed")
|
||||
setupErrors = append(setupErrors, err.Error())
|
||||
}
|
||||
}
|
||||
|
|
@ -394,7 +394,7 @@ func (h *ActionHandler) newRun(ctx context.Context, req *RunCreateRequest) (*typ
|
|||
|
||||
func (h *ActionHandler) recreateRun(ctx context.Context, req *RunCreateRequest) (*types.RunBundle, error) {
|
||||
// fetch the existing runconfig and run
|
||||
h.log.Info().Msgf("creating run from existing run")
|
||||
h.log.Info().Msg("creating run from existing run")
|
||||
|
||||
var rc *types.RunConfig
|
||||
var run *types.Run
|
||||
|
|
@ -406,7 +406,7 @@ func (h *ActionHandler) recreateRun(ctx context.Context, req *RunCreateRequest)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if run == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run %q doesn't exist", req.RunID), serrors.RunDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run %q doesn't exist", req.RunID), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
rc, err = h.d.GetRunConfig(tx, run.RunConfigID)
|
||||
|
|
@ -414,7 +414,7 @@ func (h *ActionHandler) recreateRun(ctx context.Context, req *RunCreateRequest)
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if rc == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("runconfig %q doesn't exist", run.RunConfigID), serrors.RunDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("runconfig %q doesn't exist", run.RunConfigID), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -428,11 +428,11 @@ func (h *ActionHandler) recreateRun(ctx context.Context, req *RunCreateRequest)
|
|||
|
||||
if req.FromStart {
|
||||
if canRestart, reason := run.CanRestartFromScratch(); !canRestart {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run cannot be restarted: %s", reason), serrors.RunCannotBeRestarted())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("run cannot be restarted: %s", reason), serrors.RunCannotBeRestarted())
|
||||
}
|
||||
} else {
|
||||
if canRestart, reason := run.CanRestartFromFailedTasks(); !canRestart {
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run cannot be restarted: %s", reason), serrors.RunCannotBeRestarted())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("run cannot be restarted: %s", reason), serrors.RunCannotBeRestarted())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -709,7 +709,7 @@ func (h *ActionHandler) RunTaskSetAnnotations(ctx context.Context, req *RunTaskS
|
|||
|
||||
task, ok := r.Tasks[req.TaskID]
|
||||
if !ok {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run %q doesn't have task %q", r.ID, req.TaskID), serrors.RunTaskDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run %q doesn't have task %q", r.ID, req.TaskID), serrors.RunTaskDoesNotExist())
|
||||
}
|
||||
|
||||
task.Annotations = req.Annotations
|
||||
|
|
@ -755,15 +755,15 @@ func (h *ActionHandler) ApproveRunTask(ctx context.Context, req *RunTaskApproveR
|
|||
|
||||
task, ok := r.Tasks[req.TaskID]
|
||||
if !ok {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run %q doesn't have task %q", r.ID, req.TaskID), serrors.RunTaskDoesNotExist())
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run %q doesn't have task %q", r.ID, req.TaskID), serrors.RunTaskDoesNotExist())
|
||||
}
|
||||
|
||||
if !task.WaitingApproval {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run %q, task %q is not in waiting approval state", r.ID, req.TaskID), serrors.RunTaskNotWaitingApproval())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("run %q, task %q is not in waiting approval state", r.ID, req.TaskID), serrors.RunTaskNotWaitingApproval())
|
||||
}
|
||||
|
||||
if task.Approved {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("run %q, task %q is already approved", r.ID, req.TaskID), serrors.RunTaskAlreadyApproved())
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("run %q, task %q is already approved", r.ID, req.TaskID), serrors.RunTaskAlreadyApproved())
|
||||
}
|
||||
|
||||
task.WaitingApproval = false
|
||||
|
|
@ -807,7 +807,7 @@ func (h *ActionHandler) GetExecutorTask(ctx context.Context, etID string) (*GetE
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if et == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("executor task %q not found", etID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("executor task %q not found", etID))
|
||||
}
|
||||
|
||||
r, err := h.d.GetRun(tx, et.RunID)
|
||||
|
|
@ -823,7 +823,7 @@ func (h *ActionHandler) GetExecutorTask(ctx context.Context, etID string) (*GetE
|
|||
return errors.Wrapf(err, "cannot get run config %q", r.ID)
|
||||
}
|
||||
if rc == nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("runconfig %q doesn't exist", r.RunConfigID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("runconfig %q doesn't exist", r.RunConfigID))
|
||||
}
|
||||
|
||||
rt, ok := r.Tasks[et.RunTaskID]
|
||||
|
|
@ -867,7 +867,7 @@ func (h *ActionHandler) GetExecutorTasks(ctx context.Context, executorID string)
|
|||
return errors.Wrapf(err, "cannot get run config %q", r.ID)
|
||||
}
|
||||
if rc == nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("runconfig %q doesn't exist", r.RunConfigID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("runconfig %q doesn't exist", r.RunConfigID))
|
||||
}
|
||||
|
||||
rt, ok := r.Tasks[et.RunTaskID]
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func parseRequestOptions(r *http.Request) (*requestOptions, error) {
|
|||
case types.SortDirectionAsc:
|
||||
case types.SortDirectionDesc:
|
||||
default:
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
return nil, util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("wrong sort direction %q", sortDirection), serrors.InvalidSortDirection())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -173,15 +173,15 @@ func (h *LogsHandler) readTaskLogs(ctx context.Context, runID, taskID string, se
|
|||
}
|
||||
|
||||
if r == nil {
|
||||
return true, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("no such run with id: %s", runID), serrors.RunDoesNotExist())
|
||||
return true, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("no such run with id: %s", runID), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
task, ok := r.Tasks[taskID]
|
||||
if !ok {
|
||||
return true, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("no such task with ID %s in run %s", taskID, runID), serrors.RunTaskDoesNotExist())
|
||||
return true, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("no such task with ID %s in run %s", taskID, runID), serrors.RunTaskDoesNotExist())
|
||||
}
|
||||
if len(task.Steps) <= step {
|
||||
return true, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("no such step for task %s in run %s", taskID, runID), serrors.RunTaskStepDoesNotExist())
|
||||
return true, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("no such step for task %s in run %s", taskID, runID), serrors.RunTaskStepDoesNotExist())
|
||||
}
|
||||
|
||||
// if the log has been already fetched use it, otherwise fetch it from the executor
|
||||
|
|
@ -213,7 +213,7 @@ func (h *LogsHandler) readTaskLogs(ctx context.Context, runID, taskID string, se
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if et == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("executor task for run task with id %q doesn't exist", task.ID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("executor task for run task with id %q doesn't exist", task.ID))
|
||||
}
|
||||
|
||||
executor, err = h.d.GetExecutorByExecutorID(tx, et.ExecutorID)
|
||||
|
|
@ -221,7 +221,7 @@ func (h *LogsHandler) readTaskLogs(ctx context.Context, runID, taskID string, se
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if executor == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("executor with id %q doesn't exist", et.ExecutorID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("executor with id %q doesn't exist", et.ExecutorID))
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -346,7 +346,7 @@ func (h *LogsDeleteHandler) do(r *http.Request) error {
|
|||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("setup is false and step is empty"))
|
||||
}
|
||||
if setup && stepStr != "" {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("setup is true and step is %s", stepStr))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("setup is true and step is %s", stepStr))
|
||||
}
|
||||
|
||||
var step int
|
||||
|
|
@ -354,7 +354,7 @@ func (h *LogsDeleteHandler) do(r *http.Request) error {
|
|||
var err error
|
||||
step, err = strconv.Atoi(stepStr)
|
||||
if err != nil {
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("step %s is not a valid number", stepStr))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("step %s is not a valid number", stepStr))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -386,15 +386,15 @@ func (h *LogsDeleteHandler) deleteTaskLogs(ctx context.Context, runID, taskID st
|
|||
}
|
||||
|
||||
if r == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("no such run with id: %s", runID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("no such run with id: %s", runID))
|
||||
}
|
||||
|
||||
task, ok := r.Tasks[taskID]
|
||||
if !ok {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("no such task with ID %s in run %s", taskID, runID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("no such task with ID %s in run %s", taskID, runID))
|
||||
}
|
||||
if len(task.Steps) <= step {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("no such step for task %s in run %s", taskID, runID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("no such step for task %s in run %s", taskID, runID))
|
||||
}
|
||||
|
||||
if task.Steps[step].LogPhase == types.RunTaskFetchPhaseFinished {
|
||||
|
|
@ -413,7 +413,7 @@ func (h *LogsDeleteHandler) deleteTaskLogs(ctx context.Context, runID, taskID st
|
|||
}
|
||||
return nil
|
||||
}
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsg("Log for task %s in run %s is not yet archived", taskID, runID))
|
||||
return util.NewAPIError(util.ErrBadRequest, util.WithAPIErrorMsgf("Log for task %s in run %s is not yet archived", taskID, runID))
|
||||
}
|
||||
|
||||
type ChangeGroupsUpdateTokensHandler struct {
|
||||
|
|
@ -528,11 +528,11 @@ func (h *RunHandler) do(r *http.Request) (*rsapitypes.RunResponse, error) {
|
|||
}
|
||||
|
||||
if run == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run with id %q doesn't exist", runRef), serrors.RunDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run with id %q doesn't exist", runRef), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
if rc == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run config for run with id %q doesn't exist", runRef), serrors.RunDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run config for run with id %q doesn't exist", runRef), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
cgts, err := types.MarshalChangeGroupsUpdateToken(cgt)
|
||||
|
|
@ -628,11 +628,11 @@ func (h *RunByGroupHandler) do(r *http.Request) (*rsapitypes.RunResponse, error)
|
|||
return nil, errors.WithStack(err)
|
||||
}
|
||||
if run == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run for group %q with counter %d doesn't exist", group, runCounter), serrors.RunDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run for group %q with counter %d doesn't exist", group, runCounter), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
if rc == nil {
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("run config for run with id %q doesn't exist", run.ID), serrors.RunDoesNotExist())
|
||||
return nil, util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("run config for run with id %q doesn't exist", run.ID), serrors.RunDoesNotExist())
|
||||
}
|
||||
|
||||
cgts, err := types.MarshalChangeGroupsUpdateToken(cgt)
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ func (h *ExecutorDeleteHandler) do(r *http.Request) error {
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if executor == nil {
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsg("executor with executor id %s doesn't exist", executorID))
|
||||
return util.NewAPIError(util.ErrNotExist, util.WithAPIErrorMsgf("executor with executor id %s doesn't exist", executorID))
|
||||
}
|
||||
|
||||
if err := h.d.DeleteExecutor(tx, executor.ID); err != nil {
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ func (s *Runservice) maintenanceModeWatcherLoop(ctx context.Context, runCtxCance
|
|||
s.log.Info().Msgf("maintenance mode watcher: maintenance mode enabled: %t", maintenanceMode)
|
||||
|
||||
for {
|
||||
s.log.Debug().Msgf("maintenanceModeWatcherLoop")
|
||||
s.log.Debug().Msg("maintenanceModeWatcherLoop")
|
||||
|
||||
// at first watch restart from previous processed revision
|
||||
if err := s.maintenanceModeWatcher(ctx, runCtxCancel, maintenanceMode); err != nil {
|
||||
s.log.Err(err).Msgf("maintenance mode watcher error")
|
||||
s.log.Err(err).Msg("maintenance mode watcher error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(1 * time.Second).C
|
||||
|
|
@ -253,13 +253,13 @@ func (s *Runservice) setupMaintenanceRouter() http.Handler {
|
|||
func (s *Runservice) Run(ctx context.Context) error {
|
||||
for {
|
||||
if err := s.run(ctx); err != nil {
|
||||
s.log.Err(err).Msgf("run error")
|
||||
s.log.Err(err).Msg("run error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(1 * time.Second).C
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
s.log.Info().Msgf("runservice exiting")
|
||||
s.log.Info().Msg("runservice exiting")
|
||||
return nil
|
||||
case <-sleepCh:
|
||||
}
|
||||
|
|
@ -331,10 +331,10 @@ func (s *Runservice) run(ctx context.Context) error {
|
|||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
s.log.Info().Msgf("runservice run exiting")
|
||||
s.log.Info().Msg("runservice run exiting")
|
||||
case err = <-lerrCh:
|
||||
if err != nil {
|
||||
s.log.Err(err).Msgf("http server listen error")
|
||||
s.log.Err(err).Msg("http server listen error")
|
||||
}
|
||||
case err = <-errCh:
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ func (s *Runservice) submitRunTasks(ctx context.Context, r *types.Run, rc *types
|
|||
return errors.WithStack(err)
|
||||
}
|
||||
if executor == nil {
|
||||
s.log.Warn().Msgf("cannot choose an executor")
|
||||
s.log.Warn().Msg("cannot choose an executor")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -846,7 +846,7 @@ func (s *Runservice) executorTaskUpdateHandler(ctx context.Context, c <-chan str
|
|||
|
||||
func (s *Runservice) executorTasksCleanerLoop(ctx context.Context) {
|
||||
for {
|
||||
s.log.Debug().Msgf("executorTasksCleaner")
|
||||
s.log.Debug().Msg("executorTasksCleaner")
|
||||
|
||||
if err := s.executorTasksCleaner(ctx); err != nil {
|
||||
s.log.Err(err).Send()
|
||||
|
|
@ -967,7 +967,7 @@ func (s *Runservice) executorTaskCleaner(ctx context.Context, executorTaskID str
|
|||
|
||||
func (s *Runservice) runTasksUpdaterLoop(ctx context.Context) {
|
||||
for {
|
||||
s.log.Debug().Msgf("runTasksUpdater")
|
||||
s.log.Debug().Msg("runTasksUpdater")
|
||||
|
||||
if err := s.runTasksUpdater(ctx); err != nil {
|
||||
s.log.Err(err).Send()
|
||||
|
|
@ -983,7 +983,7 @@ func (s *Runservice) runTasksUpdaterLoop(ctx context.Context) {
|
|||
}
|
||||
|
||||
func (s *Runservice) runTasksUpdater(ctx context.Context) error {
|
||||
s.log.Debug().Msgf("runTasksUpdater")
|
||||
s.log.Debug().Msg("runTasksUpdater")
|
||||
|
||||
l := s.lf.NewLock(common.TaskUpdaterLockKey)
|
||||
if err := l.Lock(ctx); err != nil {
|
||||
|
|
@ -1212,7 +1212,7 @@ func (s *Runservice) finishArchivePhase(ctx context.Context, runID, runTaskID st
|
|||
}
|
||||
|
||||
func (s *Runservice) fetchTaskLogs(ctx context.Context, runID string, rt *types.RunTask) {
|
||||
s.log.Debug().Msgf("fetchTaskLogs")
|
||||
s.log.Debug().Msg("fetchTaskLogs")
|
||||
|
||||
// fetch setup log
|
||||
if rt.SetupStep.LogPhase == types.RunTaskFetchPhaseNotStarted {
|
||||
|
|
@ -1323,7 +1323,7 @@ func (s *Runservice) fetchArchive(ctx context.Context, runID string, rt *types.R
|
|||
}
|
||||
|
||||
func (s *Runservice) fetchTaskArchives(ctx context.Context, runID string, rt *types.RunTask) {
|
||||
s.log.Debug().Msgf("fetchTaskArchives")
|
||||
s.log.Debug().Msg("fetchTaskArchives")
|
||||
|
||||
for i, stepnum := range rt.WorkspaceArchives {
|
||||
phase := rt.WorkspaceArchivesPhase[i]
|
||||
|
|
@ -1342,7 +1342,7 @@ func (s *Runservice) fetchTaskArchives(ctx context.Context, runID string, rt *ty
|
|||
|
||||
func (s *Runservice) fetcherLoop(ctx context.Context) {
|
||||
for {
|
||||
s.log.Debug().Msgf("fetcher")
|
||||
s.log.Debug().Msg("fetcher")
|
||||
|
||||
if err := s.fetcher(ctx); err != nil {
|
||||
s.log.Err(err).Send()
|
||||
|
|
@ -1358,7 +1358,7 @@ func (s *Runservice) fetcherLoop(ctx context.Context) {
|
|||
}
|
||||
|
||||
func (s *Runservice) fetcher(ctx context.Context) error {
|
||||
s.log.Debug().Msgf("fetcher")
|
||||
s.log.Debug().Msg("fetcher")
|
||||
|
||||
var runs []*types.Run
|
||||
err := s.d.Do(ctx, func(tx *sql.Tx) error {
|
||||
|
|
@ -1447,7 +1447,7 @@ func (s *Runservice) taskFetcher(ctx context.Context, r *types.Run, rt *types.Ru
|
|||
|
||||
func (s *Runservice) runsSchedulerLoop(ctx context.Context) {
|
||||
for {
|
||||
s.log.Debug().Msgf("runsSchedulerLoop")
|
||||
s.log.Debug().Msg("runsSchedulerLoop")
|
||||
|
||||
if err := s.runsScheduler(ctx); err != nil {
|
||||
s.log.Err(err).Send()
|
||||
|
|
@ -1463,7 +1463,7 @@ func (s *Runservice) runsSchedulerLoop(ctx context.Context) {
|
|||
}
|
||||
|
||||
func (s *Runservice) runsScheduler(ctx context.Context) error {
|
||||
s.log.Debug().Msgf("runsScheduler")
|
||||
s.log.Debug().Msg("runsScheduler")
|
||||
var runs []*types.Run
|
||||
err := s.d.Do(ctx, func(tx *sql.Tx) error {
|
||||
var err error
|
||||
|
|
@ -1492,7 +1492,7 @@ func (s *Runservice) runScheduler(ctx context.Context, r *types.Run) error {
|
|||
|
||||
func (s *Runservice) finishedRunsArchiverLoop(ctx context.Context) {
|
||||
for {
|
||||
s.log.Debug().Msgf("finished run archiver loop")
|
||||
s.log.Debug().Msg("finished run archiver loop")
|
||||
|
||||
if err := s.finishedRunsArchiver(ctx); err != nil {
|
||||
s.log.Err(err).Send()
|
||||
|
|
@ -1508,7 +1508,7 @@ func (s *Runservice) finishedRunsArchiverLoop(ctx context.Context) {
|
|||
}
|
||||
|
||||
func (s *Runservice) finishedRunsArchiver(ctx context.Context) error {
|
||||
s.log.Debug().Msgf("finished run archiver")
|
||||
s.log.Debug().Msg("finished run archiver")
|
||||
var runs []*types.Run
|
||||
err := s.d.Do(ctx, func(tx *sql.Tx) error {
|
||||
var err error
|
||||
|
|
@ -1596,7 +1596,7 @@ func (s *Runservice) cacheCleanerLoop(ctx context.Context, cacheExpireInterval t
|
|||
}
|
||||
|
||||
func (s *Runservice) cacheCleaner(ctx context.Context, cacheExpireInterval time.Duration) error {
|
||||
s.log.Debug().Msgf("cacheCleaner")
|
||||
s.log.Debug().Msg("cacheCleaner")
|
||||
|
||||
l := s.lf.NewLock(common.CacheCleanerLockKey)
|
||||
if err := l.Lock(ctx); err != nil {
|
||||
|
|
@ -1621,7 +1621,7 @@ func (s *Runservice) cacheCleaner(ctx context.Context, cacheExpireInterval time.
|
|||
}
|
||||
|
||||
func (s *Runservice) workspaceCleanerLoop(ctx context.Context, workspaceExpireInterval time.Duration) {
|
||||
s.log.Debug().Msgf("workspaceCleanerLoop")
|
||||
s.log.Debug().Msg("workspaceCleanerLoop")
|
||||
|
||||
for {
|
||||
if err := s.objectsCleaner(ctx, store.OSTArchivesBaseDir(), common.WorkspaceCleanerLockKey, workspaceExpireInterval); err != nil {
|
||||
|
|
@ -1638,11 +1638,11 @@ func (s *Runservice) workspaceCleanerLoop(ctx context.Context, workspaceExpireIn
|
|||
}
|
||||
|
||||
func (s *Runservice) logCleanerLoop(ctx context.Context, logExpireInterval time.Duration) {
|
||||
s.log.Debug().Msgf("logCleanerLoop")
|
||||
s.log.Debug().Msg("logCleanerLoop")
|
||||
|
||||
for {
|
||||
if err := s.objectsCleaner(ctx, store.OSTLogsBaseDir(), common.LogCleanerLockKey, logExpireInterval); err != nil {
|
||||
s.log.Warn().Err(err).Msgf("objectsCleaner error")
|
||||
s.log.Warn().Err(err).Msg("objectsCleaner error")
|
||||
}
|
||||
|
||||
sleepCh := time.NewTimer(logCleanerInterval).C
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func (s *Scheduler) schedule(ctx context.Context) error {
|
|||
|
||||
for groupID := range groups {
|
||||
if err := s.scheduleRun(ctx, groupID); err != nil {
|
||||
s.log.Err(err).Msgf("scheduler err")
|
||||
s.log.Err(err).Msg("scheduler err")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,7 +209,7 @@ func (s *Scheduler) Run(ctx context.Context) error {
|
|||
go s.approveLoop(ctx)
|
||||
|
||||
<-ctx.Done()
|
||||
log.Info().Msgf("scheduler exiting")
|
||||
log.Info().Msg("scheduler exiting")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import (
|
|||
// direct call to litter.Sdump.
|
||||
// In this way litter.Sdump will be executed only when really needed without
|
||||
// consuming CPU when not required.
|
||||
// I.E. if logging with zerolog using log.Debug().Msgf("dumped value: ", util.Dump(value)),
|
||||
// I.E. if logging with zerolog using log.Debug().Msg("dumped value: ", util.Dump(value)),
|
||||
// the formatting (and so the call to litter.Sdump) won't happen if the log
|
||||
// level is less than debug.
|
||||
type dump struct {
|
||||
|
|
@ -32,7 +32,7 @@ type dump struct {
|
|||
}
|
||||
|
||||
func (d *dump) Format(f fmt.State, c rune) {
|
||||
f.Write([]byte(litter.Sdump(d.data)))
|
||||
_, _ = f.Write([]byte(litter.Sdump(d.data)))
|
||||
}
|
||||
|
||||
func Dump(data interface{}) *dump {
|
||||
|
|
|
|||
|
|
@ -116,12 +116,18 @@ func NewWrapperError(err error, options ...WrapperErrorOption) *WrapperError {
|
|||
|
||||
type WrapperErrorOption func(e *WrapperError)
|
||||
|
||||
func WithWrapperErrorMsg(format string, args ...interface{}) WrapperErrorOption {
|
||||
func WithWrapperErrorMsgf(format string, args ...any) WrapperErrorOption {
|
||||
return func(e *WrapperError) {
|
||||
e.msg = fmt.Sprintf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
func WithWrapperErrorMsg(format string, a ...any) WrapperErrorOption {
|
||||
return func(e *WrapperError) {
|
||||
e.msg = fmt.Sprint(a...)
|
||||
}
|
||||
}
|
||||
|
||||
func WithWrapperErrorCallerDepth(depth int) WrapperErrorOption {
|
||||
return func(e *WrapperError) {
|
||||
e.stack = errors.Callers(depth + 1)
|
||||
|
|
@ -264,12 +270,21 @@ func (e *APIError) message() string {
|
|||
|
||||
type APIErrorOption func(e *APIError)
|
||||
|
||||
// WithAPIErrorMsgf adds an internal message to the error. This message could
|
||||
// contain sensitive data so it's just for internal logging and will not be sent
|
||||
// to the api caller.
|
||||
func WithAPIErrorMsgf(format string, args ...any) APIErrorOption {
|
||||
return func(e *APIError) {
|
||||
e.msg = fmt.Sprintf(format, args...)
|
||||
}
|
||||
}
|
||||
|
||||
// WithAPIErrorMsg adds an internal message to the error. This message could
|
||||
// contain sensitive data so it's just for internal logging and will not be sent
|
||||
// to the api caller.
|
||||
func WithAPIErrorMsg(format string, args ...interface{}) APIErrorOption {
|
||||
func WithAPIErrorMsg(a ...any) APIErrorOption {
|
||||
return func(e *APIError) {
|
||||
e.msg = fmt.Sprintf(format, args...)
|
||||
e.msg = fmt.Sprint(a...)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue