entity

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareRulesetParameters

func CompareRulesetParameters(ruletype string, left RuleSetParameters, right RuleSetParameters) bool

func ReadAndAdjustTeamDirectory

func ReadAndAdjustTeamDirectory(fs billy.Filesystem, dirname string, users map[string]*User) ([]string, error)

*

  • AdjustTeamDirectory adjust team's defintion depending on user availability.
  • The goal is that if a user has been removed, we must update the team definition.
  • Returns:
  • - a list of (team's) file changes (to commit to Github)

func StringArrayEquivalent

func StringArrayEquivalent(a, b []string) (bool, []string, []string)

* Compare 2 string arrays to see if they contains the same elements * Returns * - true if both are the same * - left only * - rigght only

Types

type Entity

type Entity struct {
	ApiVersion string `yaml:"apiVersion"`
	Kind       string `yaml:"kind"`
	Name       string `yaml:"name"`
}

type Repository

type Repository struct {
	Entity `yaml:",inline"`
	Spec   struct {
		Writers             []string `yaml:"writers,omitempty"`
		Readers             []string `yaml:"readers,omitempty"`
		ExternalUserReaders []string `yaml:"externalUserReaders,omitempty"`
		ExternalUserWriters []string `yaml:"externalUserWriters,omitempty"`
		IsPublic            bool     `yaml:"public,omitempty"`
		AllowAutoMerge      bool     `yaml:"allow_auto_merge,omitempty"`
		DeleteBranchOnMerge bool     `yaml:"delete_branch_on_merge,omitempty"`
		AllowUpdateBranch   bool     `yaml:"allow_update_branch,omitempty"`
	} `yaml:"spec,omitempty"`
	Archived bool    `yaml:"archived,omitempty"` // implicit: will be set by Goliac
	Owner    *string `yaml:"owner,omitempty"`    // implicit. team name owning the repo (if any)
}

func NewRepository

func NewRepository(fs billy.Filesystem, filename string) (*Repository, error)

* NewRepository reads a file and returns a Repository object * The next step is to validate the Repository object using the Validate method

func (*Repository) Validate

func (r *Repository) Validate(filename string, teams map[string]*Team, externalUsers map[string]*User) error

type RuleSet

type RuleSet struct {
	Entity `yaml:",inline"`
	Spec   struct {
		// Target // branch, tag
		Enforcement string // disabled, active, evaluate
		BypassApps  []struct {
			AppName string
			Mode    string // always, pull_request
		}
		On struct {
			Include []string // ~DEFAULT_BRANCH, ~ALL, branch_name, ...
			Exclude []string //  branch_name, ...
		}

		Rules []struct {
			Ruletype   string // required_signatures, pull_request, required_status_checks...
			Parameters RuleSetParameters
		} `yaml:"rules"`
	} `yaml:"spec"`
}

* Ruleset are applied per repos based on the goliac configuration file (pattern x ruleset name)

func NewRuleSet

func NewRuleSet(fs billy.Filesystem, filename string) (*RuleSet, error)

* NewRuleSet reads a file and returns a RuleSet object * The next step is to validate the RuleSet object using the Validate method

func (*RuleSet) Validate

func (r *RuleSet) Validate(filename string) error

type RuleSetParameters

type RuleSetParameters struct {
	// PullRequestParameters
	DismissStaleReviewsOnPush      bool `yaml:"dismissStaleReviewsOnPush"`
	RequireCodeOwnerReview         bool `yaml:"requireCodeOwnerReview"`
	RequiredApprovingReviewCount   int  `yaml:"requiredApprovingReviewCount"`
	RequiredReviewThreadResolution bool `yaml:"requiredReviewThreadResolution"`
	RequireLastPushApproval        bool `yaml:"requireLastPushApproval"`

	// RequiredStatusChecksParameters
	RequiredStatusChecks             []string `yaml:"requiredStatusChecks"`
	StrictRequiredStatusChecksPolicy bool     `yaml:"strictRequiredStatusChecksPolicy"`
}

type Team

type Team struct {
	Entity `yaml:",inline"`
	Spec   struct {
		Owners  []string `yaml:"owners,omitempty"`
		Members []string `yaml:"members,omitempty"`
	} `yaml:"spec"`
}

func NewTeam

func NewTeam(fs billy.Filesystem, filename string) (*Team, error)

* NewTeam reads a file and returns a Team object * The next step is to validate the Team object using the Validate method

func (*Team) Update

func (t *Team) Update(fs billy.Filesystem, filename string, users map[string]*User) (bool, error)

Update is telling if the team needs to be adjust (and the team's definition was changed on disk), based on the list of (still) existing users

func (*Team) Validate

func (t *Team) Validate(dirname string, users map[string]*User) (error, []Warning)

type User

type User struct {
	Entity `yaml:",inline"`
	Spec   struct {
		GithubID string `yaml:"githubID"`
	} `yaml:"spec"`
}

func NewUser

func NewUser(fs billy.Filesystem, filename string) (*User, error)

* NewUser reads a file and returns a User object * The next step is to validate the User object using the Validate method

func (*User) Equals

func (u *User) Equals(a *User) bool

func (*User) Validate

func (u *User) Validate(filename string) error

type Warning

type Warning error

func ReadRepositories

func ReadRepositories(fs billy.Filesystem, archivedDirname string, teamDirname string, teams map[string]*Team, externalUsers map[string]*User) (map[string]*Repository, []error, []Warning)

*

  • ReadRepositories reads all the files in the dirname directory and
  • add them to the owner's team and returns
  • - a map of Repository objects
  • - a slice of errors that must stop the validation process
  • - a slice of warning that must not stop the validation process

func ReadRuleSetDirectory

func ReadRuleSetDirectory(fs billy.Filesystem, dirname string) (map[string]*RuleSet, []error, []Warning)

*

  • ReadRuleSetDirectory reads all the files in the dirname directory and returns
  • - a map of RuleSet objects
  • - a slice of errors that must stop the validation process
  • - a slice of warning that must not stop the validation process

func ReadTeamDirectory

func ReadTeamDirectory(fs billy.Filesystem, dirname string, users map[string]*User) (map[string]*Team, []error, []Warning)

*

  • ReadTeamDirectory reads all the files in the dirname directory and returns
  • - a map of Team objects
  • - a slice of errors that must stop the validation process
  • - a slice of warning that must not stop the validation process

func ReadUserDirectory

func ReadUserDirectory(fs billy.Filesystem, dirname string) (map[string]*User, []error, []Warning)

*

  • ReadUserDirectory reads all the files in the dirname directory and returns
  • - a map of User objects
  • - a slice of errors that must stop the vlidation process
  • - a slice of warning that must not stop the validation process

Jump to

Keyboard shortcuts

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