engine

package
v0.11.12 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const FORLOOP_STOP = 100

Variables

This section is empty.

Functions

func CompareEntities

func CompareEntities[A Comparable, B Comparable](a map[string]A, b map[string]B, compareFunction CompareEqualAB[A, B], onAdded CompareCallback[A, B], onRemoved CompareCallback[A, B], onChanged CompareCallback[A, B])

func LoadGithubLoginPendingInvitations added in v0.11.6

func LoadGithubLoginPendingInvitations(ctx context.Context, client github.GitHubClient) (map[string]bool, error)

Listing only pending invitations for the organization for login (and not email)

func LoadUsersFromGithubOrgSaml

func LoadUsersFromGithubOrgSaml(ctx context.Context, client github.GitHubClient, feedback observability.RemoteObservability) (map[string]*entity.User, error)

* This function works only for Github organization that have the Entreprise plan ANAD use SAML integration

func RegisterPlugin

func RegisterPlugin(name string, plugin UserSyncPlugin)

Types

type Comparable

type Comparable interface {
	*GithubTeamComparable | *GithubRepoComparable | *GithubRuleSet
}

type CompareCallback

type CompareCallback[A Comparable, B Comparable] func(key string, value1 A, value2 B)

type CompareEqualAB

type CompareEqualAB[A Comparable, B Comparable] func(value1 A, value2 B) bool

type CreateRepositoryResponse

type CreateRepositoryResponse struct {
	Id     int    `json:"id"`
	NodeId string `json:"node_id"`
}

type CreateTeamResponse

type CreateTeamResponse struct {
	Name string
	Slug string
}

type GHESInfo added in v0.3.0

type GHESInfo struct {
	InstalledVersion string `json:"installed_version"`
}

type GithubRepoComparable

type GithubRepoComparable struct {
	BoolProperties      map[string]bool
	Writers             []string
	Readers             []string
	ExternalUserReaders []string // githubids
	ExternalUserWriters []string // githubids
	InternalUsers       []string // githubids
}

type GithubRepository

type GithubRepository struct {
	Name           string
	Id             int
	RefId          string
	BoolProperties map[string]bool   // archived, private, allow_auto_merge, delete_branch_on_merge, allow_update_branch
	ExternalUsers  map[string]string // [githubid]permission
	InternalUsers  map[string]string // [githubid]permission
}

type GithubRuleSet

type GithubRuleSet struct {
	Name        string
	Id          int               // for tracking purpose
	Enforcement string            // disabled, active, evaluate
	BypassApps  map[string]string // appname, mode (always, pull_request)

	OnInclude []string // ~DEFAULT_BRANCH, ~ALL, branch_name, ...
	OnExclude []string //  branch_name, ...

	Rules map[string]entity.RuleSetParameters

	Repositories []string
}

type GithubRuleSetApp

type GithubRuleSetApp struct {
	Actor struct {
		DatabaseId int
		Name       string
	}
	BypassMode string // ALWAYS, PULL_REQUEST
}

type GithubRuleSetRule

type GithubRuleSetRule struct {
	Parameters struct {
		// PullRequestParameters
		DismissStaleReviewsOnPush      bool
		RequireCodeOwnerReview         bool
		RequiredApprovingReviewCount   int
		RequiredReviewThreadResolution bool
		RequireLastPushApproval        bool

		// RequiredStatusChecksParameters
		RequiredStatusChecks             []GithubRuleSetRuleStatusCheck
		StrictRequiredStatusChecksPolicy bool
	}
	ID   int
	Type string // CREATION, UPDATE, DELETION, REQUIRED_LINEAR_HISTORY, REQUIRED_DEPLOYMENTS, REQUIRED_SIGNATURES, PULL_REQUEST, REQUIRED_STATUS_CHECKS, NON_FAST_FORWARD, COMMIT_MESSAGE_PATTERN, COMMIT_AUTHOR_EMAIL_PATTERN, COMMITTER_EMAIL_PATTERN, BRANCH_NAME_PATTERN, TAG_NAME_PATTERN
}

type GithubRuleSetRuleStatusCheck

type GithubRuleSetRuleStatusCheck struct {
	Context       string
	IntegrationId int
}

type GithubTeam

type GithubTeam struct {
	Name        string
	Id          int
	Slug        string
	Members     []string // user login, aka githubid
	Maintainers []string // user login (that are not in the Members array)
	ParentTeam  *int
}

type GithubTeamComparable added in v0.8.0

type GithubTeamComparable struct {
	Name        string
	Slug        string
	Members     []string
	Maintainers []string
	ParentTeam  *string
}

type GithubTeamRepo

type GithubTeamRepo struct {
	Name       string // repository name
	Permission string // possible values: ADMIN, MAINTAIN, WRITE, TRIAGE, READ
}

type GoliacLocal

type GoliacLocal interface {
	GoliacLocalGit
	GoliacLocalResources
}

* GoliacLocal * This interface is used to load the goliac organization from a local directory * and mount it in memory

func NewGoliacLocalImpl

func NewGoliacLocalImpl() GoliacLocal

func NewGoliacLocalImplWithRepo added in v0.9.7

func NewGoliacLocalImplWithRepo(repo *git.Repository) GoliacLocal

NewMockGoliacLocalImpl is used for testing purposes

type GoliacLocalGit

type GoliacLocalGit interface {
	Clone(fs billy.Filesystem, accesstoken, repositoryUrl, branch string) error

	// Return commits from tagname to HEAD
	ListCommitsFromTag(tagname string) ([]*object.Commit, error)
	GetHeadCommit() (*object.Commit, error)
	CheckoutCommit(commit *object.Commit) error
	PushTag(tagname string, hash plumbing.Hash, accesstoken string) error

	LoadRepoConfig() (*config.RepositoryConfig, error)

	// Load and Validate from a github repository
	LoadAndValidate() ([]error, []entity.Warning)
	// whenever someone create/delete a team, we must update the github CODEOWNERS
	UpdateAndCommitCodeOwners(repoconfig *config.RepositoryConfig, dryrun bool, accesstoken string, branch string, tagname string, githubOrganization string) error
	// whenever repos are not deleted but archived
	ArchiveRepos(reposToArchiveList []string, accesstoken string, branch string, tagname string) error
	// whenever the users list is changing, reload users and teams, and commit them
	// (force will bypass the max_changesets check)
	// return true if some changes were done
	SyncUsersAndTeams(repoconfig *config.RepositoryConfig, plugin UserSyncPlugin, accesstoken string, dryrun bool, force bool, feedback observability.RemoteObservability) (bool, error)
	Close(fs billy.Filesystem)

	// Load and Validate from a local directory
	LoadAndValidateLocal(fs billy.Filesystem) ([]error, []entity.Warning)
}

type GoliacLocalImpl

type GoliacLocalImpl struct {
	// contains filtered or unexported fields
}

func (*GoliacLocalImpl) ArchiveRepos added in v0.4.3

func (g *GoliacLocalImpl) ArchiveRepos(reposToArchiveList []string, accesstoken string, branch string, tagname string) error

func (*GoliacLocalImpl) CheckoutCommit

func (g *GoliacLocalImpl) CheckoutCommit(commit *object.Commit) error

func (*GoliacLocalImpl) Clone

func (g *GoliacLocalImpl) Clone(fs billy.Filesystem, accesstoken, repositoryUrl, branch string) error

func (*GoliacLocalImpl) Close

func (g *GoliacLocalImpl) Close(fs billy.Filesystem)

func (*GoliacLocalImpl) ExternalUsers

func (g *GoliacLocalImpl) ExternalUsers() map[string]*entity.User

func (*GoliacLocalImpl) GetHeadCommit added in v0.2.3

func (g *GoliacLocalImpl) GetHeadCommit() (*object.Commit, error)

func (*GoliacLocalImpl) ListCommitsFromTag

func (g *GoliacLocalImpl) ListCommitsFromTag(tagname string) ([]*object.Commit, error)

func (*GoliacLocalImpl) LoadAndValidate

func (g *GoliacLocalImpl) LoadAndValidate() ([]error, []entity.Warning)

* Load the goliac organization from Github (after the repository has been cloned) * - read the organization files * - validate the organization

func (*GoliacLocalImpl) LoadAndValidateLocal

func (g *GoliacLocalImpl) LoadAndValidateLocal(fs billy.Filesystem) ([]error, []entity.Warning)

*

  • readOrganization reads all the organization files and returns
  • - a slice of errors that must stop the vlidation process
  • - a slice of warning that must not stop the validation process

func (*GoliacLocalImpl) LoadRepoConfig

func (g *GoliacLocalImpl) LoadRepoConfig() (*config.RepositoryConfig, error)

func (*GoliacLocalImpl) PushTag

func (g *GoliacLocalImpl) PushTag(tagname string, hash plumbing.Hash, accesstoken string) error

func (*GoliacLocalImpl) Repositories

func (g *GoliacLocalImpl) Repositories() map[string]*entity.Repository

func (*GoliacLocalImpl) RuleSets

func (g *GoliacLocalImpl) RuleSets() map[string]*entity.RuleSet

func (*GoliacLocalImpl) SyncUsersAndTeams

func (g *GoliacLocalImpl) SyncUsersAndTeams(repoconfig *config.RepositoryConfig, userplugin UserSyncPlugin, accesstoken string, dryrun bool, force bool, feedback observability.RemoteObservability) (bool, error)

func (*GoliacLocalImpl) Teams

func (g *GoliacLocalImpl) Teams() map[string]*entity.Team

func (*GoliacLocalImpl) UpdateAndCommitCodeOwners

func (g *GoliacLocalImpl) UpdateAndCommitCodeOwners(repoconfig *config.RepositoryConfig, dryrun bool, accesstoken string, branch string, tagname string, githubOrganization string) error

* UpdateAndCommitCodeOwners will collects all teams definition to update the .github/CODEOWNERS file * cf https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners

func (*GoliacLocalImpl) Users

func (g *GoliacLocalImpl) Users() map[string]*entity.User

type GoliacLocalResources

type GoliacLocalResources interface {
	Teams() map[string]*entity.Team              // teamname, team definition
	Repositories() map[string]*entity.Repository // reponame, repo definition
	Users() map[string]*entity.User              // github username, user definition
	ExternalUsers() map[string]*entity.User
	RuleSets() map[string]*entity.RuleSet
}

type GoliacReconciliator

type GoliacReconciliator interface {
	Reconciliate(ctx context.Context, local GoliacLocal, remote GoliacRemote, teamreponame string, dryrun bool, goliacAdminSlug string, reposToArchive map[string]*GithubRepoComparable) (*UnmanagedResources, error)
}

* GoliacReconciliator is here to sync the local state to the remote state

func NewGoliacReconciliatorImpl

func NewGoliacReconciliatorImpl(executor ReconciliatorExecutor, repoconfig *config.RepositoryConfig) GoliacReconciliator

type GoliacReconciliatorImpl

type GoliacReconciliatorImpl struct {
	// contains filtered or unexported fields
}

func (*GoliacReconciliatorImpl) AddRuleset

func (r *GoliacReconciliatorImpl) AddRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)

func (*GoliacReconciliatorImpl) AddUserToOrg

func (r *GoliacReconciliatorImpl) AddUserToOrg(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, ghuserid string)

func (*GoliacReconciliatorImpl) Begin

func (r *GoliacReconciliatorImpl) Begin(ctx context.Context, dryrun bool)

func (*GoliacReconciliatorImpl) Commit

func (r *GoliacReconciliatorImpl) Commit(ctx context.Context, dryrun bool) error

func (*GoliacReconciliatorImpl) CreateRepository

func (r *GoliacReconciliatorImpl) CreateRepository(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, descrition string, writers []string, readers []string, boolProperties map[string]bool)

func (*GoliacReconciliatorImpl) CreateTeam

func (r *GoliacReconciliatorImpl) CreateTeam(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, teamname string, description string, parentTeam *int, members []string)

func (*GoliacReconciliatorImpl) DeleteRepository

func (r *GoliacReconciliatorImpl) DeleteRepository(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string)

func (*GoliacReconciliatorImpl) DeleteRuleset

func (r *GoliacReconciliatorImpl) DeleteRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)

func (*GoliacReconciliatorImpl) DeleteTeam

func (r *GoliacReconciliatorImpl) DeleteTeam(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, teamslug string)

func (*GoliacReconciliatorImpl) Reconciliate

func (r *GoliacReconciliatorImpl) Reconciliate(ctx context.Context, local GoliacLocal, remote GoliacRemote, teamsreponame string, dryrun bool, goliacAdminSlug string, reposToArchive map[string]*GithubRepoComparable) (*UnmanagedResources, error)

func (*GoliacReconciliatorImpl) RemoveUserFromOrg

func (r *GoliacReconciliatorImpl) RemoveUserFromOrg(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, ghuserid string)

func (*GoliacReconciliatorImpl) Rollback

func (r *GoliacReconciliatorImpl) Rollback(ctx context.Context, dryrun bool, err error)

func (*GoliacReconciliatorImpl) UpdateRepositoryAddTeamAccess

func (r *GoliacReconciliatorImpl) UpdateRepositoryAddTeamAccess(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, teamslug string, permission string)

func (*GoliacReconciliatorImpl) UpdateRepositoryRemoveExternalUser added in v0.2.1

func (r *GoliacReconciliatorImpl) UpdateRepositoryRemoveExternalUser(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, collaboatorGithubId string)

func (*GoliacReconciliatorImpl) UpdateRepositoryRemoveInternalUser added in v0.11.8

func (r *GoliacReconciliatorImpl) UpdateRepositoryRemoveInternalUser(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, collaboatorGithubId string)

func (*GoliacReconciliatorImpl) UpdateRepositoryRemoveTeamAccess

func (r *GoliacReconciliatorImpl) UpdateRepositoryRemoveTeamAccess(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, teamslug string)

func (*GoliacReconciliatorImpl) UpdateRepositorySetExternalUser added in v0.2.1

func (r *GoliacReconciliatorImpl) UpdateRepositorySetExternalUser(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, collaboatorGithubId string, permission string)

func (*GoliacReconciliatorImpl) UpdateRepositoryUpdateBoolProperty added in v0.5.0

func (r *GoliacReconciliatorImpl) UpdateRepositoryUpdateBoolProperty(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, propertyName string, propertyValue bool)

func (*GoliacReconciliatorImpl) UpdateRepositoryUpdateTeamAccess

func (r *GoliacReconciliatorImpl) UpdateRepositoryUpdateTeamAccess(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, reponame string, teamslug string, permission string)

func (*GoliacReconciliatorImpl) UpdateRuleset

func (r *GoliacReconciliatorImpl) UpdateRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)

func (*GoliacReconciliatorImpl) UpdateTeamAddMember

func (r *GoliacReconciliatorImpl) UpdateTeamAddMember(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, teamslug string, ghuserid string, role string)

func (*GoliacReconciliatorImpl) UpdateTeamChangeMaintainerToMember added in v0.10.5

func (r *GoliacReconciliatorImpl) UpdateTeamChangeMaintainerToMember(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, teamslug string, ghuserid string)

func (*GoliacReconciliatorImpl) UpdateTeamRemoveMember

func (r *GoliacReconciliatorImpl) UpdateTeamRemoveMember(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, teamslug string, ghuserid string)

func (*GoliacReconciliatorImpl) UpdateTeamSetParent added in v0.8.0

func (r *GoliacReconciliatorImpl) UpdateTeamSetParent(ctx context.Context, dryrun bool, remote *MutableGoliacRemoteImpl, teamslug string, parentTeam *int, parentTeamName string)

type GoliacRemote

type GoliacRemote interface {
	// Load from a github repository. continueOnError is used for scaffolding
	Load(ctx context.Context, continueOnError bool) error

	// Flush all assets from the cache
	FlushCache()

	// Flush only the users, and teams from the cache
	FlushCacheUsersTeamsOnly()

	Users(ctx context.Context) map[string]string // key is the login, value is the role (member, admin)
	TeamSlugByName(ctx context.Context) map[string]string
	Teams(ctx context.Context) map[string]*GithubTeam                           // the key is the team slug
	Repositories(ctx context.Context) map[string]*GithubRepository              // the key is the repository name
	TeamRepositories(ctx context.Context) map[string]map[string]*GithubTeamRepo // key is team slug, second key is repo name
	RuleSets(ctx context.Context) map[string]*GithubRuleSet
	AppIds(ctx context.Context) map[string]int

	IsEnterprise() bool // check if we are on an Enterprise version, or if we are on GHES 3.11+

	CountAssets(ctx context.Context) (int, error)                      // return the number of (some) assets that will be loaded (to be used with the RemoteObservability/progress bar)
	SetRemoteObservability(feedback observability.RemoteObservability) // if you want to get feedback on the loading process
}

* GoliacRemote * This interface is used to load the goliac organization from a Github * and mount it in memory

type GoliacRemoteExecutor

type GoliacRemoteExecutor interface {
	GoliacRemote
	ReconciliatorExecutor
}

type GoliacRemoteImpl

type GoliacRemoteImpl struct {
	// contains filtered or unexported fields
}

func NewGoliacRemoteImpl

func NewGoliacRemoteImpl(client github.GitHubClient) *GoliacRemoteImpl

func (*GoliacRemoteImpl) AddRuleset

func (g *GoliacRemoteImpl) AddRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)

func (*GoliacRemoteImpl) AddUserToOrg

func (g *GoliacRemoteImpl) AddUserToOrg(ctx context.Context, dryrun bool, ghuserid string)

func (*GoliacRemoteImpl) AppIds

func (g *GoliacRemoteImpl) AppIds(ctx context.Context) map[string]int

func (*GoliacRemoteImpl) Begin

func (g *GoliacRemoteImpl) Begin(dryrun bool)

func (*GoliacRemoteImpl) Commit

func (g *GoliacRemoteImpl) Commit(ctx context.Context, dryrun bool) error

func (*GoliacRemoteImpl) CountAssets added in v0.11.0

func (g *GoliacRemoteImpl) CountAssets(ctx context.Context) (int, error)

func (*GoliacRemoteImpl) CreateRepository

func (g *GoliacRemoteImpl) CreateRepository(ctx context.Context, dryrun bool, reponame string, description string, writers []string, readers []string, boolProperties map[string]bool)

boolProperties are: - private - archived - allow_auto_merge - delete_branch_on_merge - allow_update_branch - ...

func (*GoliacRemoteImpl) CreateTeam

func (g *GoliacRemoteImpl) CreateTeam(ctx context.Context, dryrun bool, teamname string, description string, parentTeam *int, members []string)

func (*GoliacRemoteImpl) DeleteRepository

func (g *GoliacRemoteImpl) DeleteRepository(ctx context.Context, dryrun bool, reponame string)

func (*GoliacRemoteImpl) DeleteRuleset

func (g *GoliacRemoteImpl) DeleteRuleset(ctx context.Context, dryrun bool, rulesetid int)

func (*GoliacRemoteImpl) DeleteTeam

func (g *GoliacRemoteImpl) DeleteTeam(ctx context.Context, dryrun bool, teamslug string)

func (*GoliacRemoteImpl) FlushCache

func (g *GoliacRemoteImpl) FlushCache()

func (*GoliacRemoteImpl) FlushCacheUsersTeamsOnly added in v0.9.7

func (g *GoliacRemoteImpl) FlushCacheUsersTeamsOnly()

func (*GoliacRemoteImpl) IsEnterprise added in v0.3.0

func (g *GoliacRemoteImpl) IsEnterprise() bool

func (*GoliacRemoteImpl) Load

func (g *GoliacRemoteImpl) Load(ctx context.Context, continueOnError bool) error

func (*GoliacRemoteImpl) RemoveUserFromOrg

func (g *GoliacRemoteImpl) RemoveUserFromOrg(ctx context.Context, dryrun bool, ghuserid string)

func (*GoliacRemoteImpl) Repositories

func (g *GoliacRemoteImpl) Repositories(ctx context.Context) map[string]*GithubRepository

func (*GoliacRemoteImpl) Rollback

func (g *GoliacRemoteImpl) Rollback(dryrun bool, err error)

func (*GoliacRemoteImpl) RuleSets

func (g *GoliacRemoteImpl) RuleSets(ctx context.Context) map[string]*GithubRuleSet

func (*GoliacRemoteImpl) SetRemoteObservability added in v0.11.0

func (g *GoliacRemoteImpl) SetRemoteObservability(feedback observability.RemoteObservability)

func (*GoliacRemoteImpl) TeamRepositories

func (g *GoliacRemoteImpl) TeamRepositories(ctx context.Context) map[string]map[string]*GithubTeamRepo

func (*GoliacRemoteImpl) TeamSlugByName

func (g *GoliacRemoteImpl) TeamSlugByName(ctx context.Context) map[string]string

func (*GoliacRemoteImpl) Teams

func (g *GoliacRemoteImpl) Teams(ctx context.Context) map[string]*GithubTeam

func (*GoliacRemoteImpl) UpdateRepositoryAddTeamAccess

func (g *GoliacRemoteImpl) UpdateRepositoryAddTeamAccess(ctx context.Context, dryrun bool, reponame string, teamslug string, permission string)

func (*GoliacRemoteImpl) UpdateRepositoryRemoveExternalUser added in v0.2.1

func (g *GoliacRemoteImpl) UpdateRepositoryRemoveExternalUser(ctx context.Context, dryrun bool, reponame string, githubid string)

func (*GoliacRemoteImpl) UpdateRepositoryRemoveInternalUser added in v0.11.8

func (g *GoliacRemoteImpl) UpdateRepositoryRemoveInternalUser(ctx context.Context, dryrun bool, reponame string, githubid string)

func (*GoliacRemoteImpl) UpdateRepositoryRemoveTeamAccess

func (g *GoliacRemoteImpl) UpdateRepositoryRemoveTeamAccess(ctx context.Context, dryrun bool, reponame string, teamslug string)

func (*GoliacRemoteImpl) UpdateRepositorySetExternalUser added in v0.2.1

func (g *GoliacRemoteImpl) UpdateRepositorySetExternalUser(ctx context.Context, dryrun bool, reponame string, githubid string, permission string)

func (*GoliacRemoteImpl) UpdateRepositoryUpdateBoolProperty added in v0.5.0

func (g *GoliacRemoteImpl) UpdateRepositoryUpdateBoolProperty(ctx context.Context, dryrun bool, reponame string, propertyName string, propertyValue bool)

Used for - private - allow_auto_merge - delete_branch_on_merge - allow_update_branch - archived

func (*GoliacRemoteImpl) UpdateRepositoryUpdateTeamAccess

func (g *GoliacRemoteImpl) UpdateRepositoryUpdateTeamAccess(ctx context.Context, dryrun bool, reponame string, teamslug string, permission string)

func (*GoliacRemoteImpl) UpdateRuleset

func (g *GoliacRemoteImpl) UpdateRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)

func (*GoliacRemoteImpl) UpdateTeamAddMember

func (g *GoliacRemoteImpl) UpdateTeamAddMember(ctx context.Context, dryrun bool, teamslug string, username string, role string)

role = member or maintainer (usually we use member)

func (*GoliacRemoteImpl) UpdateTeamRemoveMember

func (g *GoliacRemoteImpl) UpdateTeamRemoveMember(ctx context.Context, dryrun bool, teamslug string, username string)

func (*GoliacRemoteImpl) UpdateTeamSetParent added in v0.8.0

func (g *GoliacRemoteImpl) UpdateTeamSetParent(ctx context.Context, dryrun bool, teamslug string, parentTeam *int)

func (*GoliacRemoteImpl) UpdateTeamUpdateMember added in v0.10.5

func (g *GoliacRemoteImpl) UpdateTeamUpdateMember(ctx context.Context, dryrun bool, teamslug string, username string, role string)

role = member or maintainer (usually we use member)

func (*GoliacRemoteImpl) Users

func (g *GoliacRemoteImpl) Users(ctx context.Context) map[string]string

type GraphQLGithubRuleSet

type GraphQLGithubRuleSet struct {
	DatabaseId   int
	Name         string
	Target       string // BRANCH, TAG
	Enforcement  string // DISABLED, ACTIVE, EVALUATE
	BypassActors struct {
		App []GithubRuleSetApp
	}
	Conditions struct {
		RefName struct {
			Include []string // ~DEFAULT_BRANCH, ~ALL,
			Exclude []string
		}
		RepositoryName struct {
			Include   []string
			Exclude   []string
			Protected bool
		}
		RepositoryId struct {
			RepositoryIds []string
		}
	}
	Rules struct {
		Nodes []GithubRuleSetRule
	}
}

type GraplQLAssets added in v0.11.0

type GraplQLAssets struct {
	Data struct {
		Organization struct {
			Repositories struct {
				TotalCount int `json:"totalCount"`
			} `json:"repositories"`
			Teams struct {
				TotalCount int `json:"totalCount"`
			} `json:"teams"`
			MembersWithRole struct {
				TotalCount int `json:"totalCount"`
			} `json:"membersWithRole"`
			SamlIdentityProvider struct {
				ExternalIdentities struct {
					TotalCount int `json:"totalCount"`
				} `json:"externalIdentities"`
			} `json:"samlIdentityProvider"`
		} `json:"organization"`
	}
	Errors []struct {
		Path       []interface{} `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type GraplQLRepositories

type GraplQLRepositories struct {
	Data struct {
		Organization struct {
			Repositories struct {
				Nodes []struct {
					Name                string
					Id                  string
					DatabaseId          int
					IsArchived          bool
					IsPrivate           bool
					AutoMergeAllowed    bool
					DeleteBranchOnMerge bool
					AllowUpdateBranch   bool
					DirectCollaborators struct {
						Edges []struct {
							Node struct {
								Login string
							}
							Permission string
						}
					}
					OutsideCollaborators struct {
						Edges []struct {
							Node struct {
								Login string
							}
							Permission string
						}
					}
				} `json:"nodes"`
				PageInfo struct {
					HasNextPage bool
					EndCursor   string
				} `json:"pageInfo"`
				TotalCount int `json:"totalCount"`
			} `json:"repositories"`
		}
	}
	Errors []struct {
		Path       []interface{} `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type GraplQLRuleSets

type GraplQLRuleSets struct {
	Data struct {
		Organization struct {
			Rulesets struct {
				Nodes    []GraphQLGithubRuleSet
				PageInfo struct {
					HasNextPage bool
					EndCursor   string
				} `json:"pageInfo"`
				TotalCount int `json:"totalCount"`
			} `json:"rulesets"`
		}
	}
	Errors []struct {
		Path       []string `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type GraplQLTeamMembers

type GraplQLTeamMembers struct {
	Data struct {
		Organization struct {
			Team struct {
				Members struct {
					Edges []struct {
						Node struct {
							Login string
						}
						Role string
					} `json:"edges"`
					PageInfo struct {
						HasNextPage bool
						EndCursor   string
					} `json:"pageInfo"`
					TotalCount int `json:"totalCount"`
				} `json:"members"`
			} `json:"team"`
		}
	}
	Errors []struct {
		Path       []interface{} `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type GraplQLTeams

type GraplQLTeams struct {
	Data struct {
		Organization struct {
			Teams struct {
				Nodes []struct {
					Name       string
					DatabaseId int `json:"databaseId"`
					Slug       string
					ParentTeam struct {
						DatabaseId int `json:"databaseId"`
					} `json:"parentTeam"`
				} `json:"nodes"`
				PageInfo struct {
					HasNextPage bool
					EndCursor   string
				} `json:"pageInfo"`
				TotalCount int `json:"totalCount"`
			} `json:"teams"`
		}
	}
	Errors []struct {
		Path       []interface{} `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type GraplQLUsers

type GraplQLUsers struct {
	Data struct {
		Organization struct {
			MembersWithRole struct {
				Edges []struct {
					Node struct {
						Login string
					} `json:"node"`
					Role string `json:"role"`
				} `json:"edges"`
				PageInfo struct {
					HasNextPage bool
					EndCursor   string
				} `json:"pageInfo"`
				TotalCount int `json:"totalCount"`
			} `json:"membersWithRole"`
		}
	}
	Errors []struct {
		Path       []interface{} `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type GraplQLUsersFromGithubOrgSaml

type GraplQLUsersFromGithubOrgSaml struct {
	Data struct {
		Organization struct {
			SamlIdentityProvider struct {
				ExternalIdentities struct {
					Edges []struct {
						Node struct {
							Guid         string
							SamlIdentity struct {
								NameId string
							}
							User struct {
								Login string
							}
						}
					}
					PageInfo struct {
						HasNextPage bool
						EndCursor   string
					} `json:"pageInfo"`
					TotalCount int `json:"totalCount"`
				} `json:"externalIdentities"`
			}
		}
	}
	Errors []struct {
		Path []struct {
			Query string `json:"query"`
		} `json:"path"`
		Extensions struct {
			Code         string
			ErrorMessage string
		} `json:"extensions"`
		Message string
	} `json:"errors"`
}

type MutableGoliacRemoteImpl

type MutableGoliacRemoteImpl struct {
	// contains filtered or unexported fields
}

* MutableGoliacRemoteImpl is used by GoliacReconciliatorImpl to update * the internal status of Github representation before appyling it for real * (or running in drymode)

func NewMutableGoliacRemoteImpl

func NewMutableGoliacRemoteImpl(ctx context.Context, remote GoliacRemote) *MutableGoliacRemoteImpl

func (*MutableGoliacRemoteImpl) AddRuleset

func (m *MutableGoliacRemoteImpl) AddRuleset(ruleset *GithubRuleSet)

func (*MutableGoliacRemoteImpl) AddUserToOrg

func (m *MutableGoliacRemoteImpl) AddUserToOrg(ghuserid string)

func (*MutableGoliacRemoteImpl) AppIds

func (g *MutableGoliacRemoteImpl) AppIds() map[string]int

func (*MutableGoliacRemoteImpl) CreateRepository

func (m *MutableGoliacRemoteImpl) CreateRepository(reponame string, descrition string, writers []string, readers []string, boolProperties map[string]bool)

func (*MutableGoliacRemoteImpl) CreateTeam

func (m *MutableGoliacRemoteImpl) CreateTeam(teamname string, description string, members []string)

func (*MutableGoliacRemoteImpl) DeleteRepository

func (m *MutableGoliacRemoteImpl) DeleteRepository(reponame string)

func (*MutableGoliacRemoteImpl) DeleteRuleset

func (m *MutableGoliacRemoteImpl) DeleteRuleset(rulesetid int)

func (*MutableGoliacRemoteImpl) DeleteTeam

func (m *MutableGoliacRemoteImpl) DeleteTeam(teamslug string)

func (*MutableGoliacRemoteImpl) RemoveUserFromOrg

func (m *MutableGoliacRemoteImpl) RemoveUserFromOrg(ghuserid string)

func (*MutableGoliacRemoteImpl) Repositories

func (m *MutableGoliacRemoteImpl) Repositories() map[string]*GithubRepository

func (*MutableGoliacRemoteImpl) RuleSets

func (m *MutableGoliacRemoteImpl) RuleSets() map[string]*GithubRuleSet

func (*MutableGoliacRemoteImpl) TeamRepositories

func (m *MutableGoliacRemoteImpl) TeamRepositories() map[string]map[string]*GithubTeamRepo

func (*MutableGoliacRemoteImpl) TeamSlugByName

func (m *MutableGoliacRemoteImpl) TeamSlugByName() map[string]string

func (*MutableGoliacRemoteImpl) Teams

func (m *MutableGoliacRemoteImpl) Teams() map[string]*GithubTeam

func (*MutableGoliacRemoteImpl) UpdateRepositoryAddTeamAccess

func (m *MutableGoliacRemoteImpl) UpdateRepositoryAddTeamAccess(reponame string, teamslug string, permission string)

func (*MutableGoliacRemoteImpl) UpdateRepositoryRemoveExternalUser added in v0.2.1

func (m *MutableGoliacRemoteImpl) UpdateRepositoryRemoveExternalUser(reponame string, collaboatorGithubId string)

func (*MutableGoliacRemoteImpl) UpdateRepositoryRemoveInternalUser added in v0.11.8

func (m *MutableGoliacRemoteImpl) UpdateRepositoryRemoveInternalUser(reponame string, collaboatorGithubId string)

func (*MutableGoliacRemoteImpl) UpdateRepositoryRemoveTeamAccess

func (m *MutableGoliacRemoteImpl) UpdateRepositoryRemoveTeamAccess(reponame string, teamslug string)

func (*MutableGoliacRemoteImpl) UpdateRepositorySetExternalUser added in v0.2.1

func (m *MutableGoliacRemoteImpl) UpdateRepositorySetExternalUser(reponame string, collaboatorGithubId string, permission string)

func (*MutableGoliacRemoteImpl) UpdateRepositoryUpdateBoolProperty added in v0.5.0

func (m *MutableGoliacRemoteImpl) UpdateRepositoryUpdateBoolProperty(reponame string, propertyName string, propertyValue bool)

UpdateRepositoryUpdateBoolProperty is used for - private - archived - allow_auto_merge - delete_branch_on_merge - allow_update_branch

func (*MutableGoliacRemoteImpl) UpdateRepositoryUpdateTeamAccess

func (m *MutableGoliacRemoteImpl) UpdateRepositoryUpdateTeamAccess(reponame string, teamslug string, permission string)

func (*MutableGoliacRemoteImpl) UpdateRuleset

func (m *MutableGoliacRemoteImpl) UpdateRuleset(ruleset *GithubRuleSet)

func (*MutableGoliacRemoteImpl) UpdateTeamAddMember

func (m *MutableGoliacRemoteImpl) UpdateTeamAddMember(teamslug string, username string, role string)

func (*MutableGoliacRemoteImpl) UpdateTeamRemoveMember

func (m *MutableGoliacRemoteImpl) UpdateTeamRemoveMember(teamslug string, username string)

func (*MutableGoliacRemoteImpl) UpdateTeamSetParent added in v0.8.0

func (m *MutableGoliacRemoteImpl) UpdateTeamSetParent(ctx context.Context, dryrun bool, teamslug string, parentTeam *int)

func (*MutableGoliacRemoteImpl) UpdateTeamUpdateMember added in v0.10.5

func (m *MutableGoliacRemoteImpl) UpdateTeamUpdateMember(teamslug string, username string, role string)

func (*MutableGoliacRemoteImpl) Users

func (m *MutableGoliacRemoteImpl) Users() map[string]string

type OrgInfo added in v0.3.0

type OrgInfo struct {
	TwoFactorRequirementEnabled bool `json:"two_factor_requirement_enabled"`
	Plan                        struct {
		Name string `json:"name"` // enterprise
	} `json:"plan"`
}

type ReconciliatorExecutor

type ReconciliatorExecutor interface {
	AddUserToOrg(ctx context.Context, dryrun bool, ghuserid string)
	RemoveUserFromOrg(ctx context.Context, dryrun bool, ghuserid string)

	CreateTeam(ctx context.Context, dryrun bool, teamname string, description string, parentTeam *int, members []string)
	UpdateTeamAddMember(ctx context.Context, dryrun bool, teamslug string, username string, role string)    // role can be 'member' or 'maintainer'
	UpdateTeamUpdateMember(ctx context.Context, dryrun bool, teamslug string, username string, role string) // role can be 'member' or 'maintainer'
	UpdateTeamRemoveMember(ctx context.Context, dryrun bool, teamslug string, username string)
	UpdateTeamSetParent(ctx context.Context, dryrun bool, teamslug string, parentTeam *int)
	DeleteTeam(ctx context.Context, dryrun bool, teamslug string)

	CreateRepository(ctx context.Context, dryrun bool, reponame string, descrition string, writers []string, readers []string, boolProperties map[string]bool)
	UpdateRepositoryUpdateBoolProperty(ctx context.Context, dryrun bool, reponame string, propertyName string, propertyValue bool)
	UpdateRepositoryAddTeamAccess(ctx context.Context, dryrun bool, reponame string, teamslug string, permission string)    // permission can be "pull", "push", or "admin" which correspond to read, write, and admin access.
	UpdateRepositoryUpdateTeamAccess(ctx context.Context, dryrun bool, reponame string, teamslug string, permission string) // permission can be "pull", "push", or "admin" which correspond to read, write, and admin access.
	UpdateRepositoryRemoveTeamAccess(ctx context.Context, dryrun bool, reponame string, teamslug string)
	AddRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)
	UpdateRuleset(ctx context.Context, dryrun bool, ruleset *GithubRuleSet)
	DeleteRuleset(ctx context.Context, dryrun bool, rulesetid int)
	UpdateRepositorySetExternalUser(ctx context.Context, dryrun bool, reponame string, githubid string, permission string) // permission can be "pull" or "push"
	UpdateRepositoryRemoveExternalUser(ctx context.Context, dryrun bool, reponame string, githubid string)
	UpdateRepositoryRemoveInternalUser(ctx context.Context, dryrun bool, reponame string, githubid string)
	DeleteRepository(ctx context.Context, dryrun bool, reponame string)

	Begin(dryrun bool)
	Rollback(dryrun bool, err error)
	Commit(ctx context.Context, dryrun bool) error
}

type TeamsRepoResponse added in v0.9.0

type TeamsRepoResponse struct {
	Name       string `json:"name"`
	Permission string `json:"permission"`
	Slug       string `json:"slug"`
}

type UnmanagedResources added in v0.7.1

type UnmanagedResources struct {
	Users                  map[string]bool
	ExternallyManagedTeams map[string]bool
	Teams                  map[string]bool
	Repositories           map[string]bool
	RuleSets               map[string]bool
}

type UserSyncPlugin

type UserSyncPlugin interface {
	// Get the current user list directory path, returns the new user list
	UpdateUsers(repoconfig *config.RepositoryConfig, fs billy.Filesystem, orguserdirrectorypath string, feedback observability.RemoteObservability) (map[string]*entity.User, error)
}

func GetUserSyncPlugin

func GetUserSyncPlugin(pluginname string) (UserSyncPlugin, bool)

Jump to

Keyboard shortcuts

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