Documentation
¶
Index ¶
- func CreateRandomProject(client *gitlab.Client, parentGroup *gitlab.Group, projectBaseName string, ...) error
- func CreateRandomProjects(client *gitlab.Client, parentGroup string, projectBaseName string, ...) error
- func DeleteProject(s *gitlab.ProjectsService, p *gitlab.Project, dryRun bool) error
- func DeleteProjects(client *gitlab.Client, group string, expr string, recursive bool, dryRun bool) error
- func GetOptionsXMLFileName(args []string) (string, error)
- type BasicCommand
- type GitlabCommand
- type GlobalCommand
- type GlobalOptions
- type Options
- type ParentCommand
- type ProjectsApprovalRulesCommand
- type ProjectsApprovalRulesListCommand
- type ProjectsApprovalRulesListOptions
- type ProjectsApprovalRulesOptions
- type ProjectsApprovalRulesUpdateCommand
- type ProjectsApprovalRulesUpdateOptions
- type ProjectsCommand
- type ProjectsCreateRandomCommand
- type ProjectsCreateRandomOptions
- type ProjectsDeleteCommand
- type ProjectsDeleteOptions
- type ProjectsListCommand
- type ProjectsListOptions
- type ProjectsOptions
- type Runner
- type UsersCommand
- type UsersListCommand
- type UsersListOptions
- type UsersOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateRandomProject ¶
func CreateRandomProject( client *gitlab.Client, parentGroup *gitlab.Group, projectBaseName string, dryRun bool, ) error
CreateRandomProject creates a project in the parent group specified by parentGroupID. The parentGroup string is only use for logging. The name of each project is a combination of the project base name and a UUID. If dryRun is true, this function only prints what it would without actually doing it.
func CreateRandomProjects ¶
func CreateRandomProjects( client *gitlab.Client, parentGroup string, projectBaseName string, projectCount uint64, dryRun bool, ) error
CreateRandomProjects creates the specified number of projects in the parent group. The name of each project is a combination of the project base name and a UUID. If dryRun is true, this function only prints what it would without actually doing it.
func DeleteProject ¶
DeleteProject deletes the project. If dryRun is true, this function only prints what it would without actually doing it.
func DeleteProjects ¶
func DeleteProjects( client *gitlab.Client, group string, expr string, recursive bool, dryRun bool, ) error
DeleteProjects deletes all the projects in a group (recursively or not) for each project whose full path name matches the regular expression. An empty regular expression matches any string. If dryRun is true, this function only prints what it would without actually doing it.
func GetOptionsXMLFileName ¶
GetOptionsXMLFileName returns the location of the options.xml file as specified on the command-line arguments or, if not set as a command-line argument, the default location.
Types ¶
type BasicCommand ¶
type BasicCommand[T any] struct { // contains filtered or unexported fields }
Command holds common data needed for each command. The parameterized type T should be the Options struct for the command. For example, BasicCommand[FooOptions] configures this command to work with the options for the "foo" command. Also see GitlabCommand and ParentCommand.
type GitlabCommand ¶
type GitlabCommand[T any] struct { // Embed BasicCommand members. BasicCommand[T] // contains filtered or unexported fields }
GitlabCommand is a BasicCommand with a Gitlab communications client. The parameterized type T should be the Options struct for the command. For example, GitlabCommand[ProjectListOptions] configures this command to work with the options for the "project list" command.
type GlobalCommand ¶
type GlobalCommand struct { // Embed the ParentCommand members. ParentCommand[GlobalOptions] // contains filtered or unexported fields }
GlobalCommand is used to parse the global command-line arguments and invoke the first subcommand.
func NewGlobalCommand ¶
func NewGlobalCommand(name string, version string) *GlobalCommand
NewGlobalCommand returns a new, initialized GlobalCommand instance having the specified name.
func (*GlobalCommand) Run ¶
func (cmd *GlobalCommand) Run(args []string) error
Run is the entry point for this command.
type GlobalOptions ¶
type GlobalOptions struct { // AuthFileName is an alternative file name for auth.xml which // holds authentication information like an OAuth token or // personal access token. Defaults to "auth.xml". AuthFileName string `xml:"auth-file-name"` // BaseURL is the base URL for connecting to Gitlab REST // endpoints. It does not include the "api/v4" part. Defaults to // "https://gitlab.com/". BaseURL string `xml:"base-url"` // Help is whether the user wants help. Defaults to false. Help bool `xml:"help"` // OptionsFileName is an alternative file name for options.xml. // Note that the user can only change this option on the command // line, not in the options.xml file (because it leads to circular // logic having the user specify the location of the options.xml // file in the options.xml file). Defaults to "options.xml". OptionsFileName string `xml:"-"` // ShowOptions is whether to print options as XML and immediately // exit. Defaults to false. ShowOptions bool `xml:"-"` // Version is whether the user wants the version. Defaults to false. Version bool `xml:"version"` }
GlobalOptions are the options needed by this command.
func PeakAtGlobalOptions ¶
func PeakAtGlobalOptions(args []string) (*GlobalOptions, error)
Peek at the global options which helps to resolve two circular dependencies. Values for program options come from the following three locations in increasing order of priority:
from the Initialize() calls for each specific data structure which establishes defaults that are hard-coded
from the options.xml file
from the command-line
The first circular dependency is that we need to create all of the subcommands which call Initialize() to establish the hard-coded defaults, but we cannot create the subcommands until after parsing options.xml and the command-line to determine the correct set of parameters to pass into the subcommands.
The second circular dependency is that we need to read from options.xml before parsing the command-line arguments to establish defaults for the program options, but we also need to parse the command-line arguments first to determine if the user specified an alternative location for the options.xml file.
func (*GlobalOptions) Initialize ¶
func (opts *GlobalOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this GlobalOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type Options ¶
type Options struct { // Name of the root XML element. XMLName xml.Name `xml:"options"` // Global Options GlobalOpts GlobalOptions `xml:"global-options"` // Options for the "projects" command. ProjectsOpts ProjectsOptions `xml:"projects-options"` // Options for the "users" command. UsersOpts UsersOptions `xml:"users-options"` }
Options is the top-level structure that holds all the options read from options.xml and from the command-line. It is used by GlobalCommand when configuring its subcommands. Each member of Options represents a subcommand that can be directly invoked by GlobalCommand. For example, if a subcommand is invoked by another subcommand (e.g. "glcmds projects list"), the subcommand options (i.e., ProjectsListOptions) will be present in their parent subcommand options (i.e., ProjectsOptions) which in turn will be present in this data structure (i.e. Options).
func (*Options) LoadFromXMLFile ¶
LoadFromXMLFile loads options from the XML file.
type ParentCommand ¶
type ParentCommand[T any] struct { // Embed BasicCommand members. BasicCommand[T] // contains filtered or unexported fields }
ParentCommand is a BasicCommand with a subcommand map that maps the name of subcommands to their Runner. The parameterized type T should be the Options struct for the command. For example, ParentCommand[ProjectOptions] configures this command to work with the options for the "project" command.
func (*ParentCommand[T]) DispatchSubcommand ¶
func (p *ParentCommand[T]) DispatchSubcommand(args []string) error
DispatchSubcommand dispatches the subcommand specified by the name args[0] using the remaining arguments are arguments for the subcommand.
func (*ParentCommand[T]) SortedCommandNames ¶
func (cmd *ParentCommand[T]) SortedCommandNames() []string
SortedCommandNames returns a slice that holds the sorted command names.
type ProjectsApprovalRulesCommand ¶
type ProjectsApprovalRulesCommand struct { // Embed the Command members. ParentCommand[ProjectsApprovalRulesOptions] }
ProjectsApprovalRulesCommand provides subcommands for Gitlab project related maintenance.
func NewProjectsApprovalRulesCommand ¶
func NewProjectsApprovalRulesCommand( name string, opts *ProjectsApprovalRulesOptions, client *gitlab.Client, ) *ProjectsApprovalRulesCommand
NewProjectsApprovalRulesCommand returns a new, initialized ProjectsApprovalRulesCommand instance having the specified name.
func (*ProjectsApprovalRulesCommand) Run ¶
func (cmd *ProjectsApprovalRulesCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsApprovalRulesListCommand ¶
type ProjectsApprovalRulesListCommand struct { // Embed the Command members. GitlabCommand[ProjectsApprovalRulesListOptions] }
ProjectsApprovalRulesListCommand implements the command "projects approval-rules list" which lists approval rules in all projects recursively found in a group where the projects are selected by a regular expression.
func NewProjectsApprovalRulesListCommand ¶
func NewProjectsApprovalRulesListCommand( name string, opts *ProjectsApprovalRulesListOptions, client *gitlab.Client, ) *ProjectsApprovalRulesListCommand
NewProjectsApprovalRulesListCommand returns a new, initialized ProjectsApprovalRulesListCommand instance.
func (*ProjectsApprovalRulesListCommand) Run ¶
func (cmd *ProjectsApprovalRulesListCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsApprovalRulesListOptions ¶
type ProjectsApprovalRulesListOptions struct { // Expr is the regular expression that filters the projects. // Defaults to "". Expr string `xml:"expr"` // Group for which projects will be listed. Defaults to "". Group string `xml:"group"` // Recursive controls whether the projects are listed recursively. // Defaults to false. Recursive bool `xml:"recursive"` }
ProjectsApprovalRulesListOptions are the options needed by this command.
func (*ProjectsApprovalRulesListOptions) Initialize ¶
func (opts *ProjectsApprovalRulesListOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsApprovalRulesListOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type ProjectsApprovalRulesOptions ¶
type ProjectsApprovalRulesOptions struct { // Options for the "projects approval-rules list" command. ProjectsApprovalRulesListOpts ProjectsApprovalRulesListOptions `xml:"list-options"` // Options for the "projects approval-rules update" command. ProjectsApprovalRulesUpdateOpts ProjectsApprovalRulesUpdateOptions `xml:"update-options"` }
ProjectsApprovalRulesOptions are the options needed by this command.
func (*ProjectsApprovalRulesOptions) Initialize ¶
func (opts *ProjectsApprovalRulesOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsApprovalRulesOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type ProjectsApprovalRulesUpdateCommand ¶
type ProjectsApprovalRulesUpdateCommand struct { // Embed the Command members. GitlabCommand[ProjectsApprovalRulesUpdateOptions] }
ProjectsApprovalRulesUpdateCommand implements the command "projects approval-rules update" which updates approval rules in all projects recursively found in a group where the projects are selected by a regular expression.
func NewProjectsApprovalRulesUpdateCommand ¶
func NewProjectsApprovalRulesUpdateCommand( name string, opts *ProjectsApprovalRulesUpdateOptions, client *gitlab.Client, ) *ProjectsApprovalRulesUpdateCommand
NewProjectsApprovalRulesUpdateCommand returns a new, initialized ProjectsApprovalRulesUpdateCommand instance.
func (*ProjectsApprovalRulesUpdateCommand) Run ¶
func (cmd *ProjectsApprovalRulesUpdateCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsApprovalRulesUpdateOptions ¶
type ProjectsApprovalRulesUpdateOptions struct { // ApproversFileName is the name of the XML file holding the list // of allowed approvers which should contain the output of the // "glmcds users list" command which is the serialization of an // [xml_users.XmlUsers] instance. ApproversFileName string `xml:"approvers-file-name"` // DryRun should cause the command to print what it would do // instead of actually doing it. Defaults to false. DryRun bool `xml:"dry-run"` // Expr is the regular expression that filters the projects. // Defaults to "". Expr string `xml:"expr"` // Group for which projects will be updated. Defaults to "". Group string `xml:"group"` // Recursive controls whether the projects are found recursively. // Defaults to false. Recursive bool `xml:"recursive"` }
ProjectsApprovalRulesUpdateOptions are the options needed by this command.
func (*ProjectsApprovalRulesUpdateOptions) Initialize ¶
func (opts *ProjectsApprovalRulesUpdateOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsApprovalRulesUpdateOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type ProjectsCommand ¶
type ProjectsCommand struct { // Embed the Command members. ParentCommand[ProjectsOptions] }
ProjectsCommand provides subcommands for Gitlab project related maintenance.
func NewProjectsCommand ¶
func NewProjectsCommand( name string, opts *ProjectsOptions, client *gitlab.Client, ) *ProjectsCommand
NewProjectsCommand returns a new, initialized ProjectsCommand instance having the specified name.
func (*ProjectsCommand) Run ¶
func (cmd *ProjectsCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsCreateRandomCommand ¶
type ProjectsCreateRandomCommand struct { // Embed the Command members. GitlabCommand[ProjectsCreateRandomOptions] }
ProjectsCreateRandomCommand implements the "projects create-random" command which creates random projects en masse.
func NewProjectsCreateRandomCommand ¶
func NewProjectsCreateRandomCommand( name string, opts *ProjectsCreateRandomOptions, client *gitlab.Client, ) *ProjectsCreateRandomCommand
NewProjectsCreateRandomCommand returns a new, initialized ProjectsCreateRandomCommand instance.
func (*ProjectsCreateRandomCommand) Run ¶
func (cmd *ProjectsCreateRandomCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsCreateRandomOptions ¶
type ProjectsCreateRandomOptions struct { // DryRun should cause the command to print what it would do // instead of actually doing it. Defaults to false. DryRun bool `xml:"dry-run"` // ParentGroup is the group where projects will be created. The // parent group must already exist. Defaults to "". ParentGroup string `xml:"parent-group"` // ProjectBaseName is the base name all new projects will have. // The full name for the project will include random characters // after the base name. Defaults to "". ProjectBaseName string `xml:"project-base-name"` // ProjectCount is the number of projects to create. Defaults to 0. ProjectCount uint64 `xml:"project-count"` }
ProjectsCreateRandomOptions are the options needed by this command.
func (*ProjectsCreateRandomOptions) Initialize ¶
func (opts *ProjectsCreateRandomOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsCreateRandomOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type ProjectsDeleteCommand ¶
type ProjectsDeleteCommand struct { // Embed the Command members. GitlabCommand[ProjectsDeleteOptions] }
ProjectsDeleteCommand implements the "projects delete" command which optionally recursively deletes projects in a group where the deleted projects are selected by a regular expression.
func NewProjectsDeleteCommand ¶
func NewProjectsDeleteCommand( name string, opts *ProjectsDeleteOptions, client *gitlab.Client, ) *ProjectsDeleteCommand
NewProjectsDeleteCommand returns a new, initialized ProjectsDeleteCommand instance.
func (*ProjectsDeleteCommand) Run ¶
func (cmd *ProjectsDeleteCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsDeleteOptions ¶
type ProjectsDeleteOptions struct { // DryRun should cause the command to print what it would do // instead of actually doing it. Defaults to false. DryRun bool `xml:"dry-run"` // Expr is the regular expression that filters the projects. // Defaults to "". Expr string `xml:"expr"` // Group for which projects will be listed. Defaults to "". Group string `xml:"group"` // Recursive controls whether the projects are deleted // recursively. Defaults to false. Recursive bool `xml:"recursive"` }
ProjectsDeleteOptions are the options needed by this command.
func (*ProjectsDeleteOptions) Initialize ¶
func (opts *ProjectsDeleteOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsDeleteOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type ProjectsListCommand ¶
type ProjectsListCommand struct { // Embed the Command members. GitlabCommand[ProjectsListOptions] }
ProjectsListCommand implements the "projects list" command which optionally recursively lists projects in a group where the listed projects are selected by a regular expression.
func NewProjectsListCommand ¶
func NewProjectsListCommand( name string, opts *ProjectsListOptions, client *gitlab.Client, ) *ProjectsListCommand
NewProjectsListCommand returns a new, initialized ProjectsListCommand instance.
func (*ProjectsListCommand) Run ¶
func (cmd *ProjectsListCommand) Run(args []string) error
Run is the entry point for this command.
type ProjectsListOptions ¶
type ProjectsListOptions struct { // Expr is the regular expression that filters the projects. // Defaults to "". Expr string `xml:"expr"` // Group for which projects will be listed. Defaults to "". Group string `xml:"group"` // Recursive controls whether the projects are listed recursively. // Defaults to false. Recursive bool `xml:"recursive"` }
ProjectsListOptions are the options needed by this command.
func (*ProjectsListOptions) Initialize ¶
func (opts *ProjectsListOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsListOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type ProjectsOptions ¶
type ProjectsOptions struct { ProjectsApprovalRulesOpts ProjectsApprovalRulesOptions `xml:"approval-rules-options"` ProjectsCreateRandomOpts ProjectsCreateRandomOptions `xml:"create-random-options"` ProjectsDeleteOpts ProjectsDeleteOptions `xml:"delete-options"` ProjectsListOpts ProjectsListOptions `xml:"list-options"` }
ProjectsOptions are the options needed by this command.
func (*ProjectsOptions) Initialize ¶
func (opts *ProjectsOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this ProjectsOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type Runner ¶
type Runner interface { // Run runs the command as specified by its arguments. Run(args []string) error }
Runner defines the interface for running commands.
type UsersCommand ¶
type UsersCommand struct { // Embed the Command members. ParentCommand[UsersOptions] }
UsersCommand provides subcommands for Gitlab project related maintenance.
func NewUsersCommand ¶
func NewUsersCommand( name string, opts *UsersOptions, client *gitlab.Client, ) *UsersCommand
NewUsersCommand returns a new, initialized UsersCommand instance having the specified name.
func (*UsersCommand) Run ¶
func (cmd *UsersCommand) Run(args []string) error
Run is the entry point for this command.
type UsersListCommand ¶
type UsersListCommand struct { // Embed the Command members. GitlabCommand[UsersListOptions] }
UsersListCommand implements the "users list" command which lists (or looks up) specific users so they can be used with other commands.
func NewUsersListCommand ¶
func NewUsersListCommand( name string, opts *UsersListOptions, client *gitlab.Client, ) *UsersListCommand
NewUsersListCommand returns a new, initialized UsersListCommand instance.
func (*UsersListCommand) Run ¶
func (cmd *UsersListCommand) Run(args []string) error
Run is the entry point for this command.
type UsersListOptions ¶
type UsersListOptions struct { // CreatedDate is the date after which users must have been // created in order to be listed. CreatedAfter date_arg.DateArg `xml:"created-after"` // OutputFileName is the name of XML output file to which users // will be appended. If empty, no XML output file is written, but // there will still be logging to the console. If set to "-", XML // output will be written to os.Stdout. OutputFileName string `xml:"output-file-name"` // MatchSubstrings controls whether all substrings matches are // reported instead of only reporting exact matches. MatchSubstrings bool `xml:"match-substrings"` // Users (for the --users option) Users string_slice.StringSlice `xml:"users>user"` }
UsersListOptions are the options needed by this command.
func (*UsersListOptions) Initialize ¶
func (opts *UsersListOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this UsersListOptions instance so it can be used with the "flag" package to parse the command-line arguments.
type UsersOptions ¶
type UsersOptions struct {
UsersListOpts UsersListOptions `xml:"list-options"`
}
UsersOptions are the options needed by this command.
func (*UsersOptions) Initialize ¶
func (opts *UsersOptions) Initialize(flags *flag.FlagSet)
Initialize initializes this UsersOptions instance so it can be used with the "flag" package to parse the command-line arguments.