crawler

package
v0.13.6 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: MIT Imports: 13 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"`
	// 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

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"`
	Children []RemoteInclude
}

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