metadata

package
v0.14.7 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2025 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package metadata contains data structures for platform metadata that is sent to TMC, i.e. information about CI/CD environments, pull requests, VCS details. A large chunk of definitions can also be found in terramate/cloud/types.go.

How the metadata has been handled historically:

  • Initially, it was a flat string->string map with key prefixes for grouping and simple values.
  • For PR data, we needed more complex data structures that can hold lists etc, so a separate API object review_request was introduced, which did both hold new data, but also implement some logic on how to abstract pull requests from different structures under a single concept.

In the future, we would like to move away from this and use the following approach:

  • Use a single API object. We keep using the existing metadata map, but relax it to accept string->any.
  • Group related data by storing them under a top-level key in metadata. No longer flatten data types into prefixed keys.
  • Do not abstract between different platforms on the CLI level, instead send the data as-is, i.e. "github_pull_request": {...}, "gitlab_merge_request": {...}, each having different definitions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BitbucketActor

type BitbucketActor struct {
	Type string         `json:"type,omitempty"`
	User *BitbucketUser `json:"user,omitempty"`
	// Role can be PARTICIPANT, REVIEWER.
	Role     string `json:"role,omitempty"`
	Approved *bool  `json:"approved,omitempty"`
	// State can be changes_requested, approved.
	State          string `json:"state,omitempty"`
	ParticipatedOn string `json:"participated_on,omitempty"`
}

BitbucketActor is a Bitbucket actor.

func NewBitbucketActor

func NewBitbucketActor(in *bitbucket.Actor) *BitbucketActor

NewBitbucketActor returns a new BitbucketActor.

type BitbucketPullRequest

type BitbucketPullRequest struct {
	Author *BitbucketUser `json:"author,omitempty"`

	// Participants contains reviewers, users that approved (assigned or not assigned), and commenters.
	Participants []BitbucketActor `json:"participants,omitempty"`

	// Reviewers contains only assigned reviewers.
	Reviewers []BitbucketUser `json:"reviewers,omitempty"`
}

BitbucketPullRequest is a Bitbuckt pull request.

func NewBitbucketPullRequest

func NewBitbucketPullRequest(in *bitbucket.PR) *BitbucketPullRequest

NewBitbucketPullRequest returns a new BitbucketPullRequest.

type BitbucketUser

type BitbucketUser struct {
	UUID        string `json:"uuid,omitempty"`
	DisplayName string `json:"display_name,omitempty"`
	AccountID   string `json:"account_id,omitempty"`
	Nickname    string `json:"nickname,omitempty"`
	AvatarURL   string `json:"avatar_url,omitempty"`
}

BitbucketUser is a Bitbucket user.

func NewBitbucketUser

func NewBitbucketUser(in *bitbucket.User) *BitbucketUser

NewBitbucketUser returns a new BitbucketUser.

type CommitAuthor

type CommitAuthor struct {
	Name  string     `json:"name,omitempty"`
	Email string     `json:"email,omitempty"`
	Time  *time.Time `json:"time,omitempty"`
}

CommitAuthor is a Github commit author.

func NewCommitAuthor

func NewCommitAuthor(in *github.CommitAuthor) *CommitAuthor

NewCommitAuthor returns a new CommitAuthor.

type GithubCommit

type GithubCommit struct {
	// GithubAuthor is the Github author from the Github perspective.
	GithubAuthor *GithubUser `json:"github_author,omitempty"`

	// GitAuthor is the Git author from the Github perspective.
	GitAuthor *CommitAuthor `json:"git_author,omitempty"`

	// GithubCommitter is the Github committer from the Git perspective.
	GithubCommitter *GithubUser `json:"github_committer,omitempty"`

	// GitCommitter is the Git committer from the Git perspective.
	GitCommitter *CommitAuthor `json:"git_committer,omitempty"`
}

GithubCommit is a Github commit.

func NewGithubCommit

func NewGithubCommit(in *github.RepositoryCommit) *GithubCommit

NewGithubCommit returns a new GithubCommit.

type GithubPullRequest

type GithubPullRequest struct {
	// Author of the PR.
	User *GithubUser `json:"user,omitempty"`
	// Author of latest commit on the PR branch.
	HeadUser *GithubUser `json:"head_user,omitempty"`
	// Author of latest commit on base branch.
	BaseUser *GithubUser `json:"base_user,omitempty"`

	RequestedReviewers []GithubUser `json:"requested_reviewers,omitempty"`
	RequestedTeams     []GithubTeam `json:"requested_teams,omitempty"`

	Reviews []GithubPullRequestReview `json:"reviews,omitempty"`

	Assignees []GithubUser `json:"assignees,omitempty"`
}

GithubPullRequest is a Github pull request.

func NewGithubPullRequest

func NewGithubPullRequest(inPR *github.PullRequest, inReviews []*github.PullRequestReview) *GithubPullRequest

NewGithubPullRequest returns a new GithubPullRequest.

type GithubPullRequestReview

type GithubPullRequestReview struct {
	ID          string      `json:"id,omitempty"`
	NodeID      string      `json:"node_id,omitempty"`
	User        *GithubUser `json:"user,omitempty"`
	SubmittedAt *time.Time  `json:"submitted_at,omitempty"`
	// State can have values CHANGES_REQUESTED, APPROVED, DISMISSED, COMMENTED
	State             string `json:"state,omitempty"`
	AuthorAssociation string `json:"author_association,omitempty"`
}

GithubPullRequestReview is a Github pull request review.

func NewGithubPullRequestReview

func NewGithubPullRequestReview(in *github.PullRequestReview) *GithubPullRequestReview

NewGithubPullRequestReview returns a new GithubPullRequestReview.

type GithubTeam

type GithubTeam struct {
	ID     string `json:"id,omitempty"`
	NodeID string `json:"node_id,omitempty"`
	Name   string `json:"name,omitempty"`
	Slug   string `json:"slug,omitempty"`
}

GithubTeam is a Github team.

func NewGithubTeam

func NewGithubTeam(in *github.Team) *GithubTeam

NewGithubTeam returns a new GithubTeam.

type GithubUser

type GithubUser struct {
	ID         string `json:"id,omitempty"`
	NodeID     string `json:"node_id,omitempty"`
	Login      string `json:"author_login,omitempty"`
	Name       string `json:"author_gravatar_id,omitempty"`
	AvatarURL  string `json:"avatar_url,omitempty"`
	GravatarID string `json:"gravatar_id,omitempty"`
	Email      string `json:"email,omitempty"`
}

GithubUser is a Github user.

func NewGithubUser

func NewGithubUser(in *github.User) *GithubUser

NewGithubUser returns a new GithubUser.

type GitlabMergeRequest

type GitlabMergeRequest struct {
	Author *GitlabUser `json:"user,omitempty"`

	DetailedMergeStatus string `json:"detailed_merge_status,omitempty"`

	// Reviewers contains only the latest review per reviewer.
	Reviewers    []GitlabMergeRequestReviewer `json:"reviewers,omitempty"`
	Participants []GitlabUser                 `json:"participants,omitempty"`
	Assignees    []GitlabUser                 `json:"assignees,omitempty"`
}

GitlabMergeRequest is a Gitlab merge request.

func NewGitlabMergeRequest

func NewGitlabMergeRequest(inMR *gitlab.MR, inReviewers []gitlab.MRReviewer, inParticipants []gitlab.User) *GitlabMergeRequest

NewGitlabMergeRequest is a Gitlab merge request.

type GitlabMergeRequestReviewer

type GitlabMergeRequestReviewer struct {
	User      *GitlabUser `json:"user,omitempty"`
	CreatedAt *time.Time  `json:"created_at,omitempty"`
	// State can contain the following values:
	// * unreviewed - reviewer is assigned but has not reviewed yet
	// * reviewed - reviewed with comments, but no approval decision yet
	// * requested_changes - reviewed with requested changes
	// * approved - reviewed and approved
	// * unapproved - previous approval was revoked
	// These cases have been tested, but there may be more potential values.
	State string `json:"state,omitempty"`
}

GitlabMergeRequestReviewer is a Gitlab merge request reviewer.

func NewGitlabMergeRequestReviewer

func NewGitlabMergeRequestReviewer(in *gitlab.MRReviewer) *GitlabMergeRequestReviewer

NewGitlabMergeRequestReviewer returns a new GitlabMergeRequestReviewer.

type GitlabUser

type GitlabUser struct {
	ID        string `json:"id,omitempty"`
	Username  string `json:"username,omitempty"`
	Name      string `json:"name,omitempty"`
	WebURL    string `json:"web_url,omitempty"`
	AvatarURL string `json:"avatar_url,omitempty"`
}

GitlabUser is a Gitlab user.

func NewGitlabUser

func NewGitlabUser(in *gitlab.User) *GitlabUser

NewGitlabUser returns a new GitlabUser.

Jump to

Keyboard shortcuts

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