-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch version/0-42-0-RC1 to adopt changes from PR #2844
- Loading branch information
Showing
6 changed files
with
225 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package initialize | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/ActiveState/cli/internal/errs" | ||
"github.com/ActiveState/cli/internal/locale" | ||
bpModel "github.com/ActiveState/cli/pkg/platform/api/buildplanner/model" | ||
) | ||
|
||
func rationalizeError(err *error) { | ||
if err == nil { | ||
return | ||
} | ||
|
||
pcErr := &bpModel.ProjectCreatedError{} | ||
if !errors.As(*err, &pcErr) { | ||
return | ||
} | ||
switch pcErr.Type { | ||
case bpModel.AlreadyExistsErrorType: | ||
*err = errs.NewUserFacing(locale.Tl("err_create_project_exists", "That project already exists."), errs.SetInput()) | ||
case bpModel.ForbiddenErrorType: | ||
*err = errs.NewUserFacing( | ||
locale.Tl("err_create_project_forbidden", "You do not have permission to create that project"), | ||
errs.SetInput(), | ||
errs.SetTips(locale.T("err_init_authenticated"))) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package request | ||
|
||
import "github.com/ActiveState/cli/pkg/platform/runtime/buildexpression" | ||
|
||
func CreateProject(owner, project string, private bool, expr *buildexpression.BuildExpression, description string) *createProject { | ||
return &createProject{map[string]interface{}{ | ||
"organization": owner, | ||
"project": project, | ||
"private": private, | ||
"expr": expr, | ||
"description": description, | ||
}} | ||
} | ||
|
||
type createProject struct { | ||
vars map[string]interface{} | ||
} | ||
|
||
func (c *createProject) Query() string { | ||
return ` | ||
mutation ($organization: String!, $project: String!, $private: Boolean!, $expr: BuildExpr!, $description: String!) { | ||
createProject(input:{organization:$organization, project:$project, private:$private, expr:$expr, description:$description}) { | ||
... on ProjectCreated { | ||
__typename | ||
commit { | ||
__typename | ||
commitId | ||
} | ||
} | ||
... on AlreadyExists { | ||
__typename | ||
message | ||
} | ||
... on NotFound { | ||
__typename | ||
message | ||
} | ||
... on ParseError { | ||
__typename | ||
message | ||
path | ||
} | ||
... on ValidationError { | ||
__typename | ||
message | ||
} | ||
... on Forbidden { | ||
__typename | ||
message | ||
} | ||
} | ||
}` | ||
} | ||
|
||
func (c *createProject) Vars() map[string]interface{} { | ||
return c.vars | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters