crawler

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StorageUnknown = -1
	StorageNeo4j   = 0
)

Variables

This section is empty.

Functions

func ParseConfig

func ParseConfig(cfg *Config) error

Types

type Config

type Config struct {
	GitlabHost             string        `conf:"required,short:g,env:GITLAB_HOST"`
	GitlabToken            string        `conf:"required,short:t,env:GITLAB_TOKEN"`
	GitlabMaxRPS           int           `conf:"default:1,short:r,env:GITLAB_MAX_RPS"`
	Storage                string        `conf:"required,short:s,env:STORAGE_BACKEND"`
	StorageCleanup         bool          `conf:"default:false,short:c,env:STORAGE_CLEANUP"`
	DefaultRefName         string        `conf:"default:HEAD,short:d,env:DEFAULT_REF_NAME"`
	HTTPClientTimeout      time.Duration `conf:"default:5s,short:x,env:HTTP_CLIENT_TIMEOUT"`
	HTTPClientMaxRetry     int           `conf:"default:2,short,m,env:HTTP_CLIENT_MAX_RETRY"`
	HTTPClientMaxRetryWait time.Duration `conf:"default:30s,short:w,env:HTTP_CLIENT_MAX_RETRY_WAIT"`
	HTTPClientMinRetryWait time.Duration `conf:"default:5s,short:n,env:HTTP_CLIENT_MIN_RETRY_WAIT"`
	NumberOfWorkers        int           `conf:"default:20,short:c,env:NUMBER_OF_WORKERS"`
	// There should be global config composition maybe? For not this lives here
	// though this is the global log level
	LogLevel  int    `conf:"default:1,env:LOG_LEVEL"`
	LogFormat string `conf:"default:json,env:LOG_FORMAT"`
}

type Crawler

type Crawler struct {
	// contains filtered or unexported fields
}

func New

func New(cfg *Config, logger zerolog.Logger, store storage.Storage) (*Crawler, error)

New creates a new project crawler The caller is responsible for closing the neo4j driver and session the Crawl func handles this already.

func (*Crawler) Crawl

func (c *Crawler) Crawl(ctx context.Context) error

Crawl iterates through every project in the given GitLab host and parses the CI file, and it's includes into the given Neo4j instance

func (*Crawler) UnmarshalCIFile added in v0.14.0

func (c *Crawler) UnmarshalCIFile(file []byte) (map[string]interface{}, error)

type RawTrigger added in v0.14.0

type RawTrigger struct {
	Include string `yaml:"include"`
	Project string `yaml:"project"`
	Branch  string `yaml:"branch"`
}

type RemoteInclude

type RemoteInclude struct {
	Project  string      `yaml:"project"`
	Ref      string      `yaml:"ref"`
	Files    StringArray `yaml:"file"`
	Local    string      `yaml:"local"`
	Remote   string      `yaml:"remote"`
	Template string      `yaml:"template"`
}

type Storage

type Storage int

func StorageFromString

func StorageFromString(s string) (Storage, error)

func (Storage) String

func (sb Storage) String() (string, error)

type StringArray

type StringArray []string

func (*StringArray) UnmarshalYAML

func (a *StringArray) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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