Documentation ¶
Overview ¶
Forked from https://github.com/cli/cli/blob/929e082c13909044e2585af292ae952c9ca6f25c/pkg/cmd/factory/default.go
Index ¶
- Constants
- Variables
- func AssigneesPrompt(response *[]string, apiClient *gitlab.Client, repoRemote *glrepo.Remote, ...) (err error)
- func CancelError(log ...interface{}) error
- func EditorPrompt(response *string, question, templateContent, editorCommand string) error
- func EnableRepoOverride(cmd *cobra.Command, f *Factory)
- func GetEditor(cf func() (config.Config, error)) (string, error)
- func HTTPClientFactory(f *Factory)
- func IDsFromUsers(users []*gitlab.User) []int
- func LabClientFunc(repoHost string, cfg config.Config, isGraphQL bool) (*gitlab.Client, error)
- func LabelsPrompt(response *[]string, apiClient *gitlab.Client, repoRemote *glrepo.Remote) (err error)
- func ListGitLabTemplates(tmplType string) ([]string, error)
- func LoadGitLabTemplate(tmplType, tmplName string) (string, error)
- func MilestonesPrompt(response *int, apiClient *gitlab.Client, repoRemote *glrepo.Remote, ...) (err error)
- func MinimumArgs(n int, msg string) cobra.PositionalArgs
- func OverrideAPIProtocol(cfg config.Config, repo glrepo.Interface)
- func ParseMilestone(apiClient *gitlab.Client, repo glrepo.Interface, milestoneTitle string) (int, error)
- type Action
- type ExitError
- type Factory
- type FlagError
- type UserAssignmentType
- type UserAssignments
Constants ¶
const ( IssueTemplate = "issue_templates" MergeRequestTemplate = "merge_request_templates" )
Variables ¶
var ( CachedConfig config.Config ConfigError error )
var GroupMemberLevel = map[int]string{
0: "no access",
5: "minimal access",
10: "guest",
20: "reporter",
30: "developer",
40: "maintainer",
50: "owner",
}
GroupMemberLevel maps a number representing the access level to a string shown to the user. API docs: https://docs.gitlab.com/ce/api/members.html#valid-access-levels
var SilentError = errors.New("SilentError")
SilentError is an error that triggers exit Code 1 without any error messaging
Functions ¶
func AssigneesPrompt ¶ added in v1.14.0
func AssigneesPrompt(response *[]string, apiClient *gitlab.Client, repoRemote *glrepo.Remote, io *iostreams.IOStreams, minimumAccessLevel int) (err error)
AssigneesPrompt creates a multi-selection prompt of all the users below the given access level for the remote referenced by the `*glrepo.Remote`
func CancelError ¶ added in v1.18.0
func CancelError(log ...interface{}) error
func EditorPrompt ¶ added in v1.17.0
func EnableRepoOverride ¶
func HTTPClientFactory ¶
func HTTPClientFactory(f *Factory)
func IDsFromUsers ¶ added in v1.13.0
func IDsFromUsers(users []*gitlab.User) []int
IDsFromUsers collects all user IDs from a slice of users
func LabClientFunc ¶ added in v1.12.0
func LabelsPrompt ¶ added in v1.12.0
func ListGitLabTemplates ¶ added in v1.12.0
TODO: properly handle errors in this function.
For now, it returns nil and empty slice if there's an error
func LoadGitLabTemplate ¶ added in v1.12.0
LoadGitLabTemplate finds and loads the GitLab template from the working git directory Follows the format officially supported by GitLab https://docs.gitlab.com/ee/user/project/description_templates.html#setting-a-default-template-for-issues-and-merge-requests.
TODO: load from remote repository if repo is overriden by -R flag
func MilestonesPrompt ¶ added in v1.14.0
func MinimumArgs ¶ added in v1.18.0
func MinimumArgs(n int, msg string) cobra.PositionalArgs
func OverrideAPIProtocol ¶
OverrideAPIProtocol sets api protocol for host to initialize http client
Types ¶
type Action ¶ added in v1.13.0
type Action int
func ConfirmSubmission ¶ added in v1.13.0
func PickMetadata ¶ added in v1.14.0
type ExitError ¶ added in v1.18.0
func WrapErrorWithCode ¶ added in v1.18.0
type Factory ¶
type Factory struct { HttpClient func() (*gitlab.Client, error) BaseRepo func() (glrepo.Interface, error) Remotes func() (glrepo.Remotes, error) Config func() (config.Config, error) Branch func() (string, error) IO *iostreams.IOStreams }
func NewFactory ¶
func NewFactory() *Factory
func (*Factory) RepoOverride ¶
type FlagError ¶
type FlagError struct {
Err error
}
FlagError is the kind of error raised in flag processing
type UserAssignmentType ¶ added in v1.17.0
type UserAssignmentType int
const ( AssigneeAssignment UserAssignmentType = iota ReviewerAssignment )
type UserAssignments ¶ added in v1.14.0
type UserAssignments struct { ToAdd []string ToRemove []string ToReplace []string AssignmentType UserAssignmentType }
UserAssignments holds 3 slice strings that represent which assignees should be added, removed, and replaced helper functions are also provided
func ParseAssignees ¶ added in v1.14.0
func ParseAssignees(assignees []string) *UserAssignments
ParseAssignees takes a String Slice and splits them into 3 Slice Strings based on the first character of a string.
'+' is put in the first slice, '!' and '-' in the second slice and all other cases in the third slice.
The 3 String slices are returned regardless if anything was put it in or not the user is responsible for checking the length to see if anything is in it
func (*UserAssignments) UsersFromAddRemove ¶ added in v1.14.0
func (ua *UserAssignments) UsersFromAddRemove( issueAssignees []*gitlab.IssueAssignee, mergeRequestAssignees []*gitlab.BasicUser, apiClient *gitlab.Client, actions []string, ) ([]int, []string, error)
UsersFromAddRemove works with both `ToAdd` and `ToRemove` members to produce a Slice of Ints that represents the final collection of IDs to assigned.
It starts by getting all IDs already assigned, but ignoring ones present in `ToRemove`, it then converts all `usernames` in `ToAdd` into IDs by using the `api` package and adds them to the IDs to be assigned
func (*UserAssignments) UsersFromReplaces ¶ added in v1.14.0
func (ua *UserAssignments) UsersFromReplaces(apiClient *gitlab.Client, actions []string) ([]int, []string, error)
UsersFromReplaces converts all users from the `ToReplace` member of the struct into an Slice of String representing the Users' IDs, it also takes a Slice of Strings and writes a proper action message to it
func (*UserAssignments) VerifyAssignees ¶ added in v1.14.0
func (ua *UserAssignments) VerifyAssignees() error
VerifyAssignees is a method for UserAssignments that checks them for validity