gitlab

package
v3.42.1 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: BSD-3-Clause Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CheckResult added in v3.19.0

type CheckResult struct {
	Course     string
	Students   []*StudentCheck
	Groups     []*GroupCheck
	Duplicates []*DuplicateCheck
	Errors     int
	OK         bool
}

CheckResult is the data behind CheckCourse: per-student classification for the course's students and groups, the students that appear in more than one group, and whether the whole course checks out.

type Client

type Client struct {
	*gitlab.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient builds a GitLab client from the given options. host and token are required; a bad configuration is an error rather than a panic, so a server can report it instead of dying.

func NewClientFromViper added in v3.0.1

func NewClientFromViper() (*Client, error)

NewClientFromViper builds a client from the global config. It is the CLI's entry point, keeping the single-token model; the web server uses NewClient with a per-user token instead.

func (*Client) AddGroupGuests

func (c *Client) AddGroupGuests(courseName string) error

AddGroupGuests adds all students from an assignment config as guests to the course subgroup (coursepath/semesterpath). This enables students to use the Dependency-Proxy.

func (*Client) Archive

func (c *Client) Archive(assignmentCfg *config.AssignmentConfig, unarchive bool) error

func (*Client) CheckCourse

func (c *Client) CheckCourse(cfg *config.CourseConfig) bool

func (*Client) CheckCourseData added in v3.19.0

func (c *Client) CheckCourseData(cfg *config.CourseConfig) *CheckResult

CheckCourseData resolves every roster entry of the course against GitLab and returns the classification, reporting progress per student through c.rep (so a streaming reporter can forward it live). It never prints; the CLI's CheckCourse keeps its own colored rendering.

func (*Client) Delete

func (c *Client) Delete(assignmentCfg *config.AssignmentConfig) error

func (*Client) ExistingRepoNames added in v3.35.0

func (c *Client) ExistingRepoNames(assignmentCfg *config.AssignmentConfig) (map[string]bool, error)

ExistingRepoNames lists the names of the projects that actually exist in an assignment's GitLab group — one paginated group listing rather than a GetProject per student, so a whole-course overview stays cheap (one call per assignment, not per repository). The caller matches these against RepoTargets to see which repos have been generated. A missing group (assignment never generated) surfaces as an error the caller can treat as "nothing generated".

func (*Client) Generate

func (c *Client) Generate(assignmentCfg *config.AssignmentConfig, skipInvite bool) error

Generate creates the repositories for an assignment. When skipInvite is true, the repos are created and seeded with starter code but students/groups are NOT added or invited — a debugging aid to exercise generation without notifying anyone.

func (*Client) ProtectToBranch

func (c *Client) ProtectToBranch(assignmentCfg *config.AssignmentConfig) error

func (*Client) Push

func (c *Client) Push(assignmentCfg *config.AssignmentConfig, branchname string) error

func (*Client) Report

func (c *Client) Report(assignmentCfg *config.AssignmentConfig, templateFile *string, output *string) error

func (*Client) ReportData added in v3.16.0

func (c *Client) ReportData(assignmentCfg *config.AssignmentConfig) (*r.Reports, error)

ReportData returns the structured report for an assignment without rendering it to text/HTML. It is the data-returning entry point the web server uses; the CLI's Report/ReportHTML render this same data.

func (*Client) ReportHTML

func (c *Client) ReportHTML(assignmentCfg *config.AssignmentConfig, templateFile *string, output *string) error

func (*Client) ReportJSON

func (c *Client) ReportJSON(assignmentCfg *config.AssignmentConfig, output *string) error

func (*Client) Setaccess

func (c *Client) Setaccess(assignmentCfg *config.AssignmentConfig) error

func (*Client) Update

func (c *Client) Update(assignmentCfg *config.AssignmentConfig) error

type DuplicateCheck added in v3.19.0

type DuplicateCheck struct {
	Student string
	Groups  []string
}

DuplicateCheck is one student that appears in more than one group.

type GroupCheck added in v3.19.0

type GroupCheck struct {
	Name    string
	Members []*StudentCheck
}

GroupCheck is the classification of one group's members.

type Option added in v3.0.1

type Option func(*clientOptions)

func WithCommitter added in v3.30.0

func WithCommitter(name, email string) Option

WithCommitter sets the identity that authors starter-code commits. Empty values fall back to the glabs bot identity. The web server passes the acting user so a generated commit is attributed to them.

func WithHTTPClient added in v3.0.1

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient injects the underlying HTTP client.

func WithHost added in v3.0.1

func WithHost(host string) Option

func WithReporter added in v3.0.1

func WithReporter(r reporter.Reporter) Option

WithReporter sets where the client's progress goes. Defaults to a ConsoleReporter (spinners on stdout); the web server passes a streaming one.

func WithToken added in v3.0.1

func WithToken(token string) Option

func WithoutRetries added in v3.0.1

func WithoutRetries() Option

WithoutRetries disables the client's retry-on-5xx wrapper. The contract tests use it so a mocked 5xx returns immediately instead of retrying with backoff.

type StudentCheck added in v3.19.0

type StudentCheck struct {
	Input   string // the raw roster entry, as written
	Status  StudentCheckStatus
	Message string
}

StudentCheck is the classification of one roster entry.

type StudentCheckStatus added in v3.19.0

type StudentCheckStatus string

StudentCheckStatus classifies how a roster entry resolved against GitLab.

const (
	// CheckOK: the user resolved (pinned by ID, or matched uniquely by email).
	CheckOK StudentCheckStatus = "ok"
	// CheckInvite: no GitLab user found, but there is an email → invite by email.
	CheckInvite StudentCheckStatus = "invite"
	// CheckDeprecated: resolved by username — works, but pinning by ID is safer.
	CheckDeprecated StudentCheckStatus = "deprecated"
	// CheckError: cannot resolve and there is no email to fall back to.
	CheckError StudentCheckStatus = "error"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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