gitlabsanitycli

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PageSize is the limit of results per result page (from API). Maximum is 100
	PageSize = 100

	// Config Parameters
	List        = "list"
	Archive     = "archive"
	ArchiveAll  = "archive-all"
	Delete      = "delete"
	DeleteAll   = "delete-all"
	Project     = "project"
	Runner      = "runner"
	GroupRunner = "groupRunner"
	User        = "user"
	Pipeline    = "pipeline"
)

Variables

View Source
var (
	// ConcurrentAPIRequest set the amount of concurrent goroutines
	ConcurrentAPIRequest = 10
)

Functions

func Run

func Run(a AbstractHandler, channelHandlerFunc ChannelHandlerFunc)

Run is the entry func() of AbstractHandler to call the Controller() implementation

Types

type AbstractHandler

type AbstractHandler interface {
	Pipe(*sync.WaitGroup, chan<- content, <-chan int)
	Controller(ChannelHandlerFunc)
	ApiCallFunc(int) ([]int, *gitlab.Response, error)
}

AbstractHandler Interface Pipe() implements the Pull and Push logic to grab Data from API and Push back to output Channel Controller() implements the logic to start and run Pipe() and takes the ChannelHandlerFunc (example logic: see genericHandler() func) ApiCallFunc() takes the current page and respones with the ID slice, respose and error

type ChannelHandlerFunc

type ChannelHandlerFunc func(<-chan content)

ChannelHandlerFunc gets results from Pipe

type Config

type Config struct {
	URL                   string        `goptions:"-u, --url, description='Gitlab API Url, can also be set via env \"GITLAB_URL\"', obligatory"`
	Insecure              bool          `goptions:"--insecure, description='Skip certificate Verfication for Gitlab API URL, (bool)'"`
	Token                 string        `goptions:"-t, --token, description='Gitlab API access token, can also be set via env \"GITLAB_TOKEN\" or file \".token\"'"`
	Operation             string        `goptions:"-o, --operation, description='Operation to start, (list, archive, archive-all, delete, delete-all)', obligatory"`
	Resource              string        `` /* 126-byte string literal not displayed */
	ResourceId            int           `goptions:"-i, --identifier, description='Resource ID to interact with, (int)'"`
	PipelineId            int           `goptions:"--pipelineId, description='Pipeline ID to interact with, (int)'"`
	ProjectType           string        `goptions:"-p, --project-type, description='Type of project (internal, private, public), (default: internal), (string)'"`
	Age                   int           `goptions:"-a, --age, description='Filter by last activity in months (not available for runner), (int)'"`
	Query                 string        `goptions:"-q, --query, description='Search by name, (string)'"`
	Status                string        `goptions:"-s, --state, description='Filter list by state, (string)'"`
	DryRun                bool          `goptions:"-d, --dry-run, description='Dry run, does not change/delete any resources, (bool)'"`
	Help                  goptions.Help `goptions:"-h, --help, description='Show this help'"`
	Version               bool          `goptions:"-v, --version, description='Show Version'"`
	NumConCurrentApiCalls int           `goptions:"-n, --num-concurrent-api-calls, description='Limit the amount of concurrent API Calls (default: 10), (int)'"`
}

Application Configuration

type GroupRunnerHandler

type GroupRunnerHandler struct {
	Git         *gitlab.Client
	Printer     Printer
	Config      *Config
	ListOptions gitlab.ListGroupsRunnersOptions
	GroupID     int
}

GroupRunnerHandler implements AbstractHandler implementation for interacting with Gitlab Grouprunner Resources

func (GroupRunnerHandler) ApiCallFunc

func (g GroupRunnerHandler) ApiCallFunc(page int) ([]int, *gitlab.Response, error)

func (GroupRunnerHandler) Controller

func (g GroupRunnerHandler) Controller(channelHandlerFunc ChannelHandlerFunc)

func (*GroupRunnerHandler) Delete

func (g *GroupRunnerHandler) Delete()

func (*GroupRunnerHandler) DeleteAll

func (g *GroupRunnerHandler) DeleteAll()

func (*GroupRunnerHandler) List

func (g *GroupRunnerHandler) List()

func (GroupRunnerHandler) Pipe

func (g GroupRunnerHandler) Pipe(wg *sync.WaitGroup, wc chan<- content, rc <-chan int)

type PipelineHandler added in v1.1.0

type PipelineHandler struct {
	Git         *gitlab.Client
	Printer     Printer
	Config      *Config
	ListOptions gitlab.ListProjectPipelinesOptions
}

PipelineHandler implements AbstractHandler implementation for interacting with Gitlab Project Pipelines

func (PipelineHandler) ApiCallFunc added in v1.1.0

func (p PipelineHandler) ApiCallFunc(page int) ([]int, *gitlab.Response, error)

func (PipelineHandler) Controller added in v1.1.0

func (p PipelineHandler) Controller(channelHandlerFunc ChannelHandlerFunc)

func (PipelineHandler) Delete added in v1.1.0

func (p PipelineHandler) Delete()

func (PipelineHandler) DeleteAll added in v1.1.0

func (p PipelineHandler) DeleteAll()

func (PipelineHandler) List added in v1.1.0

func (p PipelineHandler) List()

func (PipelineHandler) Pipe added in v1.1.0

func (p PipelineHandler) Pipe(wg *sync.WaitGroup, wc chan<- content, rc <-chan int)

type Printer

type Printer interface {
	Print(rc <-chan content)
}

Printer interface for rendering output

type ProjectHandler

type ProjectHandler struct {
	Git         *gitlab.Client
	Printer     Printer
	Config      *Config
	ListOptions gitlab.ListProjectsOptions
}

ProjectHandler implements AbstractHandler implementation for interacting with Gitlab Project Resources

func (ProjectHandler) ApiCallFunc

func (p ProjectHandler) ApiCallFunc(page int) ([]int, *gitlab.Response, error)

func (ProjectHandler) Archive

func (p ProjectHandler) Archive()

func (ProjectHandler) ArchiveAll

func (p ProjectHandler) ArchiveAll()

func (ProjectHandler) Controller

func (p ProjectHandler) Controller(channelHandlerFunc ChannelHandlerFunc)

func (ProjectHandler) Delete

func (p ProjectHandler) Delete()

func (ProjectHandler) DeleteAll

func (p ProjectHandler) DeleteAll()

func (ProjectHandler) List

func (p ProjectHandler) List()

func (ProjectHandler) Pipe

func (p ProjectHandler) Pipe(wg *sync.WaitGroup, wc chan<- content, rc <-chan int)

type RunnerHandler

type RunnerHandler struct {
	Git         *gitlab.Client
	Printer     Printer
	Config      *Config
	ListOptions gitlab.ListRunnersOptions
}

RunnerHandler implements AbstractHandler implementation for interacting with Gitlab Runner Resources

func (RunnerHandler) ApiCallFunc

func (r RunnerHandler) ApiCallFunc(page int) ([]int, *gitlab.Response, error)

func (RunnerHandler) Controller

func (r RunnerHandler) Controller(channelHandlerFunc ChannelHandlerFunc)

func (*RunnerHandler) Delete

func (r *RunnerHandler) Delete()

func (RunnerHandler) DeleteAll

func (r RunnerHandler) DeleteAll()

func (*RunnerHandler) List

func (r *RunnerHandler) List()

func (RunnerHandler) Pipe

func (r RunnerHandler) Pipe(wg *sync.WaitGroup, wc chan<- content, rc <-chan int)

type TemplatePrinter

type TemplatePrinter struct {
}

TemplatePrinter implementation of Printer for templated output (see ../config/stdout.tpl)

func (TemplatePrinter) Print

func (p TemplatePrinter) Print(rc <-chan content)

Print get results from egress channels and prints to stdout by using a template

type UserHandler

type UserHandler struct {
	Git     *gitlab.Client
	Printer Printer
	Config  *Config
	// contains filtered or unexported fields
}

UserHandler implements AbstractHandler implementation for interacting with Gitlab User Resources

func (UserHandler) ApiCallFunc

func (u UserHandler) ApiCallFunc(page int) ([]int, *gitlab.Response, error)

func (UserHandler) Controller

func (u UserHandler) Controller(channelHandlerFunc ChannelHandlerFunc)

func (*UserHandler) List

func (u *UserHandler) List()

func (UserHandler) Pipe

func (u UserHandler) Pipe(wg *sync.WaitGroup, wc chan<- content, rc <-chan int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL