spec

package
v0.0.0-...-8cf1ac8 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KindRepo - repository model kind
	KindRepo = Kind("Repository")
	// KindReadme - repository readme model kind
	KindReadme = Kind("Readme")
	// KindOrg - organization model kind
	KindOrg = Kind("Organization")
	// KindHook - repository webhook
	KindHook = Kind("WebHook")
	// KindTeam - organization team
	KindTeam = Kind("Team")
	// KindProtection - repository branch protection rule
	KindProtection = Kind("Protection")
)
View Source
const (
	FeatureIssues    = "issues"
	FeatureWiki      = "wiki"
	FeaturePages     = "pages"
	FeatureProjects  = "projects"
	FeatureDownloads = "downloads"
)
View Source
const (
	RepoVisibilityPublic  = "public"
	RepoVisibilityPrivate = "private"
)
View Source
const (
	MergeCommit = "commit"
	MergeRebase = "rebase"
	MergeSquash = "squash"
)
View Source
const (
	// Version of spec
	Version = "v2"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrInvalidKind

type ErrInvalidKind struct {
	// Expected and Actual values of kind
	Expected, Actual Kind
}

ErrInvalidKind - error that kind is not the value as expected

func (*ErrInvalidKind) Error

func (e *ErrInvalidKind) Error() string

func (*ErrInvalidKind) RecoverHandler

func (e *ErrInvalidKind) RecoverHandler(out *error)

RecoverHandler could be used to catch this error on panic with defer

type Hook

type Hook struct {
	URL         string   `yaml:"url" default:"http://example.com/hook"`
	ContentType string   `yaml:"contentType" default:"json"`
	InsecureSsl bool     `yaml:"insecureSsl,omitempty" default:"false"`
	Secret      string   `yaml:"secret,omitempty"`
	Events      []string `yaml:"events,omitempty" default:"[\"push\"]"`
	Active      bool     `yaml:"active" default:"true"`
	Selector    struct {
		Repository   string `yaml:"repository,omitempty"`
		Organization string `yaml:"organization,omitempty"`
	} `yaml:"selector"`
}

func (*Hook) FromGithub

func (h *Hook) FromGithub(g *github.Hook) error

func (*Hook) ToGithub

func (h *Hook) ToGithub(g *github.Hook) error

type Kind

type Kind string

Kind of specification

func (Kind) Require

func (k Kind) Require(req Kind)

Require this kind to be another kind panics with ErrInvalidKind error if doesn't. Could be handlerd with ErrInvalidKind.RecoverHandler

type Metadata

type Metadata struct {
	Name        string            `yaml:"name,omitempty"`
	Repo        string            `yaml:"repo,omitempty"`
	Owner       string            `yaml:"owner,omitempty"`
	ID          *int64            `yaml:"id,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
}

Metadata for spec

func (*Metadata) FromGithubOrg

func (m *Metadata) FromGithubOrg(o *github.Organization)

func (*Metadata) FromGithubRepo

func (m *Metadata) FromGithubRepo(r *github.Repository)

func (*Metadata) FromGithubTeam

func (m *Metadata) FromGithubTeam(t *github.Team)

func (*Metadata) Info

func (m *Metadata) Info() string

type Model

type Model struct {
	Version  string      `yaml:"version"`
	Kind     Kind        `yaml:"kind"`
	Metadata *Metadata   `yaml:"metadata,omitempty"`
	Spec     interface{} `yaml:"-"`
}

Model of spec

func NewModel

func NewModel(kind Kind) (*Model, error)

NewModel with kind

func ReadFile

func ReadFile(name string) ([]*Model, error)

ReadFile models from file

func ReadStream

func ReadStream(r io.Reader) ([]*Model, error)

ReadStream of models from reader

func (*Model) FromDecoder

func (m *Model) FromDecoder(d *yaml.Decoder) error

FromDecoder creates model from yaml decoder

func (*Model) FromReader

func (m *Model) FromReader(r io.Reader) error

FromReader creates model from io reader

func (*Model) GetSpec

func (m *Model) GetSpec(out interface{}) (re error)

GetSpec extracts a spec from model

func (*Model) Info

func (m *Model) Info() string

func (*Model) MarshalYAML

func (m *Model) MarshalYAML() (interface{}, error)

func (*Model) UnmarshalYAML

func (m *Model) UnmarshalYAML(value *yaml.Node) error

type Org

type Org struct {
	Name        string `yaml:"name"`
	Description string `yaml:"description,omitempty"`
	Company     string `yaml:"company,omitempty"`
	Blog        string `yaml:"blog,omitempty"`
	Location    string `yaml:"location,omitempty"`
	Email       string `yaml:"email,omitempty"`
	Twitter     string `yaml:"twitter,omitempty"`
	Verified    bool   `yaml:"verified,omitempty"`
}

func (*Org) FromGithub

func (o *Org) FromGithub(g *github.Organization)

func (*Org) ToGithub

func (o *Org) ToGithub(g *github.Organization) error

type Protection

type Protection struct {
	// Checks represents required status checks for merge
	Checks []string `yaml:"checks,omitempty"`
	// Strict update with target branch is requried
	Strict bool `yaml:"strictUpdate,omitempty"`
	// Review represents pull request review enforcement
	Review struct {
		// Require pull request reviews enforcement of a protected branch.
		Require bool `yaml:"require,omitempty"`
		// Dismiss pull request review
		Dismiss struct {
			// Users who can dismiss review
			Users []string `yaml:"users,omitempty"`
			// Teams who can dismiss review
			Teams []string `yaml:"teams,omitempty"`
			// Automatically dismiss approving reviews when someone pushes a new commit.
			Stale bool `yaml:"stale,omitempty"`
		} `yaml:"dismiss,omitempty"`
		// RequireOwner blocks merging pull requests until code owners review them.
		RequireOwner bool `yaml:"requireOwner,omitempty"`
		// Count is the number of reviewers required to approve pull requests.
		Count int `yaml:"count,omitempty"`
	} `yaml:"review,omitempty"`
	// EnforceAdmins the same rules
	EnforceAdmins bool `yaml:"enforceAdmins,omitempty"`
	// LinearHistory is required for merging branch
	LinearHistory bool `yaml:"linearHistory,omitempty"`
	// ForcePush is allowed
	ForcePush bool `yaml:"forcePush,omitempty"`
	// CanDelete target branch
	CanDelete bool `yaml:"canDelete,omitempty"`
	// Permissions
	Permissions struct {
		// Restrict permissions is enabled
		Restrict bool `yaml:"restrict,omitempty"`
		// Users with push access
		Users []string `yaml:"users,omitempty"`
		// Teams with push access
		Teams []string `yaml:"teams,omitempty"`
		// Apps with push access
		Apps []string `yaml:"apps,omitempty"`
	} `yaml:"permissions,omitempty"`
	// ConversationResolution, if set to true, requires all comments
	// on the pull request to be resolved before it can be merged to a protected branch.
	ConversationResolution bool `yaml:"conversationResolution,omitempty"`
}

Protection rule of repositry branch

func (*Protection) FromGithub

func (bp *Protection) FromGithub(g *github.Protection) error

func (*Protection) ToGithub

func (bp *Protection) ToGithub(pr *github.ProtectionRequest) error

type Readme

type Readme struct {
	Selector struct {
		Repository string `yaml:"repository"`
	} `yaml:"selector"`
	Title    string `yaml:"title,omitempty"`
	Abstract string `yaml:"abstract,omitempty"`
	Topics   []struct {
		Heading string `yaml:"heading"`
		Body    string `yaml:"body"`
	} `yaml:"topics,omitempty"`
}

func (*Readme) String

func (s *Readme) String() string

type Repo

type Repo struct {
	Description         *string  `yaml:"description,omitempty"`
	Homepage            *string  `yaml:"homepage,omitempty"`
	DefaultBranch       string   `yaml:"defaultBranch,omitempty" default:"master"`
	MergeStrategy       []string `yaml:"mergeStrategy,omitempty" default:"[\"merge\"]"`
	DeleteBranchOnMerge *bool    `yaml:"deleteBranchOnMerge,omitempty"`
	Topics              []string `yaml:"topics,omitempty"`
	Archived            *bool    `yaml:"archived,omitempty"`
	Disabled            *bool    `yaml:"disabled,omitempty"`
	License             *string  `yaml:"license,omitempty"`
	Visibiliy           *string  `yaml:"visibility,omitempty" default:"public"`
	Features            []string `yaml:"features,omitempty"`
}

Repo spec

func (*Repo) FromGithub

func (spec *Repo) FromGithub(repo *github.Repository)

func (*Repo) ToGithub

func (s *Repo) ToGithub(r *github.Repository) error

type Team

type Team struct {
	Name        string `yaml:"name,omitempty" default:"NewTeam"`
	Description string `yaml:"description,omitempty"`
	Permission  string `yaml:"permission,omitempty"`
	Privacy     string `yaml:"privacy,omitempty"`
}

func (*Team) FromGithub

func (t *Team) FromGithub(g *github.Team) error

func (*Team) ToGithub

func (t *Team) ToGithub(g *github.NewTeam) error

Jump to

Keyboard shortcuts

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