pkg

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FsFactory = func() afero.Fs {
	return afero.NewOsFs()
}
View Source
var MaxRetries = 10

MaxRetries is the maximum number of retries before bailing.

Functions

func Do added in v0.3.0

func Do(fn Func) error

Do keeps trying the function until the second argument returns false, or no error is returned.

func FindRepoInvitation added in v0.3.0

func FindRepoInvitation(client *githubclient.Client, ctx context.Context, owner, repo, collaborator string) (*github.RepositoryInvitation, error)

func IsMaxRetries added in v0.3.0

func IsMaxRetries(err error) bool

IsMaxRetries checks whether the error is due to hitting the maximum number of retries or not.

Types

type BaseData

type BaseData struct{}

func (*BaseData) AddressLength added in v0.2.0

func (bd *BaseData) AddressLength() int

func (*BaseData) BlockType

func (bd *BaseData) BlockType() string

func (*BaseData) CanExecutePrePlan added in v0.2.0

func (bd *BaseData) CanExecutePrePlan() bool

func (*BaseData) Data added in v0.2.0

func (bd *BaseData) Data()

type BaseFix

type BaseFix struct {
	RuleIds []string `json:"rule_ids" hcl:"rule_ids"`
}

func (*BaseFix) AddressLength added in v0.2.0

func (bf *BaseFix) AddressLength() int

func (*BaseFix) BaseDecode added in v0.3.0

func (bf *BaseFix) BaseDecode(hb *golden.HclBlock, evalContext *hcl.EvalContext) error

func (*BaseFix) BlockType

func (bf *BaseFix) BlockType() string

func (*BaseFix) CanExecutePrePlan added in v0.2.0

func (bf *BaseFix) CanExecutePrePlan() bool

func (*BaseFix) ExecuteDuringPlan added in v0.3.0

func (bf *BaseFix) ExecuteDuringPlan() error

func (*BaseFix) Fix added in v0.2.0

func (bf *BaseFix) Fix()

func (*BaseFix) GetRuleIds

func (bf *BaseFix) GetRuleIds() []string

func (*BaseFix) Values

func (bf *BaseFix) Values() map[string]cty.Value

type BaseRule

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

func (*BaseRule) AddressLength added in v0.2.0

func (br *BaseRule) AddressLength() int

func (*BaseRule) BlockType

func (br *BaseRule) BlockType() string

func (*BaseRule) CanExecutePrePlan added in v0.2.0

func (br *BaseRule) CanExecutePrePlan() bool

func (*BaseRule) CheckError

func (br *BaseRule) CheckError() error

func (*BaseRule) Rule added in v0.2.0

func (br *BaseRule) Rule()

type CollaboratorForRepositoryCollaboratorsFix added in v0.3.0

type CollaboratorForRepositoryCollaboratorsFix struct {
	Name       string `hcl:"user_name"`
	Permission string `hcl:"permission" default:"pull" validate:"oneof=pull triage push maintain admin"`
}

type CopyFileFix

type CopyFileFix struct {
	*golden.BaseBlock
	*BaseFix
	Src  string `json:"src" hcl:"src"`
	Dest string `json:"dest" hcl:"dest"`
}

func (*CopyFileFix) Apply

func (c *CopyFileFix) Apply() error

func (*CopyFileFix) Type

func (c *CopyFileFix) Type() string

type Data

type Data interface {
	golden.PlanBlock
	// discriminator func
	Data()
}

type DeploymentBranchPolicyForGitHubRepositoryEnvironmentsFix added in v0.3.0

type DeploymentBranchPolicyForGitHubRepositoryEnvironmentsFix struct {
	ProtectedBranches    bool `hcl:"protected_branches"`
	CustomBranchPolicies bool `hcl:"custom_branch_policies"`
}

type DirExistRule

type DirExistRule struct {
	*golden.BaseBlock
	*BaseRule
	Dir         string `hcl:"dir"`
	FailOnExist bool   `hcl:"fail_on_exist,optional"`
}

func (*DirExistRule) ExecuteDuringPlan

func (d *DirExistRule) ExecuteDuringPlan() error

func (*DirExistRule) Type

func (d *DirExistRule) Type() string

type EnvironmentForGitHubRepositoryEnvironmentsDatasource added in v0.3.0

type EnvironmentForGitHubRepositoryEnvironmentsDatasource struct {
	Name   string `attribute:"name"`
	NodeId string `attribute:"node_id"`
}

type EnvironmentForGitHubRepositoryEnvironmentsFix added in v0.3.0

type EnvironmentForGitHubRepositoryEnvironmentsFix struct {
	Name                   string                                                    `hcl:"name"`
	CanAdminsBypass        bool                                                      `hcl:"can_admins_bypass,optional" default:"true"`
	PreventSelfReview      bool                                                      `hcl:"prevent_self_review,optional" default:"false"`
	WaitTimer              *int                                                      `hcl:"wait_timer,optional" validate:"gte=0,lte=43200"`
	Reviewers              []ReviewerForGitHubRepositoryEnvironmentsFix              `hcl:"reviewer,block" validate:"max=6"`
	DeploymentBranchPolicy *DeploymentBranchPolicyForGitHubRepositoryEnvironmentsFix `hcl:"deployment_branch_policy,block"`
}

type FailedRule

type FailedRule struct {
	Rule
	CheckError error
}

func (*FailedRule) String

func (fr *FailedRule) String() string

type FileExistRule

type FileExistRule struct {
	*golden.BaseBlock
	*BaseRule
	Glob       string `hcl:"glob"`
	MatchFiles []string
}

func (*FileExistRule) ExecuteDuringPlan

func (f *FileExistRule) ExecuteDuringPlan() error

func (*FileExistRule) Type

func (f *FileExistRule) Type() string

type FileHashRule

type FileHashRule struct {
	*golden.BaseBlock
	*BaseRule
	Glob               string   `hcl:"glob"`
	Hash               string   `hcl:"hash"`
	Algorithm          string   `hcl:"algorithm,optional" default:"sha1"`
	FailOnHashMismatch bool     `hcl:"fail_on_hash_mismatch,optional"`
	HashMismatchFiles  []string `attribute:"hash_mismatch_files"`
}

func (*FileHashRule) ExecuteDuringPlan

func (fhr *FileHashRule) ExecuteDuringPlan() error

func (*FileHashRule) Type

func (fhr *FileHashRule) Type() string

func (*FileHashRule) Validate

func (fhr *FileHashRule) Validate() error

type Fix

type Fix interface {
	golden.ApplyBlock
	GetRuleIds() []string
	// discriminator func
	Fix()
	// contains filtered or unexported methods
}

type Func added in v0.3.0

type Func func(attempt int) (retry bool, err error)

Func represents functions that can be retried.

type GitHubRepositoryCollaboratorsDatasource added in v0.3.0

type GitHubRepositoryCollaboratorsDatasource struct {
	*golden.BaseBlock
	*BaseData
	Owner         string `hcl:"owner" json:"owner"`
	RepoName      string `hcl:"repo_name" json:"repo_name"`
	Collaborators []User `attribute:"users"`
}

func (*GitHubRepositoryCollaboratorsDatasource) ExecuteDuringPlan added in v0.3.0

func (g *GitHubRepositoryCollaboratorsDatasource) ExecuteDuringPlan() error

func (*GitHubRepositoryCollaboratorsDatasource) Type added in v0.3.0

type GitHubRepositoryCollaboratorsFix added in v0.3.0

type GitHubRepositoryCollaboratorsFix struct {
	*golden.BaseBlock
	*BaseFix
	Owner         string                                      `hcl:"owner"`
	RepoName      string                                      `hcl:"repo_name"`
	Collaborators []CollaboratorForRepositoryCollaboratorsFix `hcl:"collaborator,block"`
}

func (*GitHubRepositoryCollaboratorsFix) Apply added in v0.3.0

func (*GitHubRepositoryCollaboratorsFix) Type added in v0.3.0

type GitHubRepositoryEnvironmentsDatasource added in v0.3.0

type GitHubRepositoryEnvironmentsDatasource struct {
	*golden.BaseBlock
	*BaseData
	Owner        string                                                 `hcl:"owner"`
	RepoName     string                                                 `hcl:"repo_name"`
	Environments []EnvironmentForGitHubRepositoryEnvironmentsDatasource `attribute:"environments"`
}

func (*GitHubRepositoryEnvironmentsDatasource) ExecuteDuringPlan added in v0.3.0

func (g *GitHubRepositoryEnvironmentsDatasource) ExecuteDuringPlan() error

func (*GitHubRepositoryEnvironmentsDatasource) Type added in v0.3.0

type GitHubRepositoryEnvironmentsFix added in v0.3.0

type GitHubRepositoryEnvironmentsFix struct {
	*golden.BaseBlock
	*BaseFix
	Owner        string                                          `hcl:"owner"`
	RepoName     string                                          `hcl:"repo_name"`
	Environments []EnvironmentForGitHubRepositoryEnvironmentsFix `hcl:"environment,block"`
}

func (*GitHubRepositoryEnvironmentsFix) Apply added in v0.3.0

func (*GitHubRepositoryEnvironmentsFix) Type added in v0.3.0

type GitHubRepositoryTeamsDatasource added in v0.3.0

type GitHubRepositoryTeamsDatasource struct {
	*golden.BaseBlock
	*BaseData
	Owner    string `hcl:"owner"`
	RepoName string `hcl:"repo_name"`
	Teams    []Team `attribute:"teams"`
}

func (*GitHubRepositoryTeamsDatasource) ExecuteDuringPlan added in v0.3.0

func (g *GitHubRepositoryTeamsDatasource) ExecuteDuringPlan() error

func (*GitHubRepositoryTeamsDatasource) Type added in v0.3.0

type GitHubTeamDatasource added in v0.3.0

type GitHubTeamDatasource struct {
	*golden.BaseBlock
	*BaseData
	Owner          string   `hcl:"owner"`
	Slug           string   `hcl:"slug"`
	MembershipType string   `hcl:"membership_type,optional" default:"all" validate:"oneof=all immediate"`
	TeamName       string   `attribute:"team_name"`
	Description    string   `attribute:"description"`
	Privacy        string   `attribute:"privacy"`
	Permission     string   `attribute:"permission"`
	NodeId         string   `attribute:"node_id"`
	TeamId         int64    `attribute:"team_id"`
	Members        []string `attribute:"members"`
}

func (*GitHubTeamDatasource) ExecuteDuringPlan added in v0.3.0

func (g *GitHubTeamDatasource) ExecuteDuringPlan() error

func (*GitHubTeamDatasource) Type added in v0.3.0

func (g *GitHubTeamDatasource) Type() string

type GitHubTeamFix added in v0.3.0

type GitHubTeamFix struct {
	*golden.BaseBlock
	*BaseFix
	Owner                   string `hcl:"owner"`
	TeamName                string `hcl:"team_name"`
	Description             string `hcl:"description,optional"`
	Privacy                 string `hcl:"privacy,optional" default:"secret" validate:"oneof=secret closed"`
	ParentTeamId            int64  `hcl:"parent_team_id,optional" default:"-1"`
	LdapDistinguishedName   string `hcl:"ldap_dn,optional"`
	CreateDefaultMaintainer bool   `hcl:"create_default_maintainer,optional" default:"false"`
}

func (*GitHubTeamFix) Apply added in v0.3.0

func (g *GitHubTeamFix) Apply() error

func (*GitHubTeamFix) Type added in v0.3.0

func (g *GitHubTeamFix) Type() string

type GitHubTeamMembersFix added in v0.3.0

type GitHubTeamMembersFix struct {
	*golden.BaseBlock
	*BaseFix
	Owner             string       `hcl:"owner"`
	TeamSlug          string       `hcl:"team_slug"`
	PruneExtraMembers bool         `hcl:"prune_extra_members,optional" default:"false"`
	Members           []TeamMember `hcl:"member,block"`
}

func (GitHubTeamMembersFix) Apply added in v0.3.0

func (g GitHubTeamMembersFix) Apply() error

func (GitHubTeamMembersFix) Type added in v0.3.0

func (g GitHubTeamMembersFix) Type() string

type GitHubTeamRepositoryFix added in v0.3.0

type GitHubTeamRepositoryFix struct {
	*golden.BaseBlock
	*BaseFix
	Owner    string                  `hcl:"owner"`
	RepoName string                  `hcl:"repo_name"`
	Teams    []TeamRepositoryBinding `hcl:"team,block"`
}

func (*GitHubTeamRepositoryFix) Apply added in v0.3.0

func (g *GitHubTeamRepositoryFix) Apply() error

func (*GitHubTeamRepositoryFix) Type added in v0.3.0

func (g *GitHubTeamRepositoryFix) Type() string

type GitIgnoreDatasource

type GitIgnoreDatasource struct {
	*golden.BaseBlock
	*BaseData
	Records []string `attribute:"records"`
}

func (*GitIgnoreDatasource) ExecuteDuringPlan

func (g *GitIgnoreDatasource) ExecuteDuringPlan() error

func (*GitIgnoreDatasource) Type

func (g *GitIgnoreDatasource) Type() string

type GitIgnoreFix

type GitIgnoreFix struct {
	*golden.BaseBlock
	*BaseFix
	Exist    []string `hcl:"exist,optional" validate:"at_least_one_of=Exist NotExist"`
	NotExist []string `hcl:"not_exist,optional" validate:"at_least_one_of=Exist NotExist"`
}

func (*GitIgnoreFix) Apply

func (g *GitIgnoreFix) Apply() error

func (*GitIgnoreFix) Type

func (g *GitIgnoreFix) Type() string

type GreptConfig added in v0.2.0

type GreptConfig struct {
	*golden.BaseConfig
}

func BuildGreptConfig added in v0.2.0

func BuildGreptConfig(baseDir, cfgDir string, ctx context.Context, cliFlagAssignedVariables []golden.CliFlagAssignedVariables) (*GreptConfig, error)

func NewGreptConfig added in v0.2.0

func NewGreptConfig(baseDir string, cliFlagAssignedVariables []golden.CliFlagAssignedVariables, ctx context.Context, hclBlocks []*golden.HclBlock) (*GreptConfig, error)

type GreptPlan added in v0.2.0

type GreptPlan struct {
	FailedRules []*FailedRule
	Fixes       map[string]Fix
	// contains filtered or unexported fields
}

func RunGreptPlan added in v0.2.0

func RunGreptPlan(c *GreptConfig) (*GreptPlan, error)

func (*GreptPlan) Apply added in v0.2.0

func (p *GreptPlan) Apply() error

func (*GreptPlan) String added in v0.2.0

func (p *GreptPlan) String() string

type HttpDatasource

type HttpDatasource struct {
	*golden.BaseBlock
	*BaseData
	Url             string            `hcl:"url"`
	Method          string            `hcl:"method,optional" default:"GET" validate:"oneof=GET HEAD POST PUT DELETE CONNECT OPTIONS TRACE PATCH"`
	RequestBody     string            `hcl:"request_body,optional"`
	RequestHeaders  map[string]string `hcl:"request_headers,optional"`
	RetryMax        int               `hcl:"retry_max,optional" default:"4"`
	ResponseBody    string            `attribute:"response_body"`
	ResponseHeaders map[string]string `attribute:"response_headers"`
	StatusCode      int               `attribute:"status_code"`
}

func (*HttpDatasource) ExecuteDuringPlan

func (h *HttpDatasource) ExecuteDuringPlan() error

func (*HttpDatasource) Type

func (h *HttpDatasource) Type() string

type LocalFileFix

type LocalFileFix struct {
	*golden.BaseBlock
	*BaseFix
	Paths   []string     `json:"paths" hcl:"paths"`
	Content string       `json:"content" hcl:"content"`
	Mode    *fs.FileMode `json:"mode" hcl:"mode,optional" default:"0644" validate:"file_mode"`
}

func (*LocalFileFix) Apply

func (lf *LocalFileFix) Apply() error

func (*LocalFileFix) Type

func (lf *LocalFileFix) Type() string

type LocalShellFix

type LocalShellFix struct {
	*golden.BaseBlock
	*BaseFix
	ExecuteCommand []string          `hcl:"execute_command,optional" default:"[/bin/sh,-c]"` // The command used to execute the script.
	InlineShebang  string            `hcl:"inline_shebang,optional" validate:"required_with=Inlines"`
	Inlines        []string          `hcl:"inlines,optional" validate:"conflict_with=Script RemoteScript,at_least_one_of=Inlines Script RemoteScript"`
	Script         string            `hcl:"script,optional" validate:"conflict_with=Inlines RemoteScript,at_least_one_of=Inlines Script RemoteScript"`
	RemoteScript   string            `hcl:"remote_script,optional" validate:"conflict_with=Inlines Script,at_least_one_of=Inlines Script RemoteScript,eq=|http_url"`
	OnlyOn         []string          `` /* 129-byte string literal not displayed */
	Env            map[string]string `hcl:"env,optional"`
}

func (*LocalShellFix) Apply

func (l *LocalShellFix) Apply() (err error)

func (*LocalShellFix) Type

func (l *LocalShellFix) Type() string

type MustBeTrueRule

type MustBeTrueRule struct {
	*golden.BaseBlock
	*BaseRule
	Condition    bool   `hcl:"condition"`
	ErrorMessage string `hcl:"error_message,optional"`
}

func (*MustBeTrueRule) ExecuteDuringPlan

func (m *MustBeTrueRule) ExecuteDuringPlan() error

func (*MustBeTrueRule) Type

func (m *MustBeTrueRule) Type() string

type RenameFileFix

type RenameFileFix struct {
	*golden.BaseBlock
	*BaseFix
	OldName string `json:"old_name" hcl:"old_name"`
	NewName string `json:"new_name" hcl:"new_name"`
}

func (*RenameFileFix) Apply

func (rf *RenameFileFix) Apply() error

func (*RenameFileFix) Type

func (rf *RenameFileFix) Type() string

type ReviewerForGitHubRepositoryEnvironmentsFix added in v0.3.0

type ReviewerForGitHubRepositoryEnvironmentsFix struct {
	TeamId *int64 `hcl:"team_id,optional"`
	UserId *int64 `hcl:"user_id,optional"`
}

type RmLocalFileFix

type RmLocalFileFix struct {
	*golden.BaseBlock
	*BaseFix
	Paths []string `hcl:"paths" json:"paths"`
}

func (*RmLocalFileFix) Apply

func (r *RmLocalFileFix) Apply() error

func (*RmLocalFileFix) Type

func (r *RmLocalFileFix) Type() string

type Rule

type Rule interface {
	golden.PlanBlock
	CheckError() error
	// discriminator func
	Rule()
	// contains filtered or unexported methods
}

type Team added in v0.3.0

type Team struct {
	Name       string `hcl:"name"`
	Slug       string `hcl:"slug"`
	Permission string `hcl:"permission"`
}

type TeamMember added in v0.3.0

type TeamMember struct {
	UserName string `hcl:"username"`
	Role     string `hcl:"role,optional" validate:"oneof=member maintainer" default:"member"`
}

type TeamRepositoryBinding added in v0.3.0

type TeamRepositoryBinding struct {
	TeamSlug   string `hcl:"team_slug"`
	Permission string `hcl:"permission,optional" default:"pull" validate:"oneof=pull triage push maintain admin"`
}

type User added in v0.3.0

type User struct {
	Name        string   `attribute:"name"`
	Company     string   `attribute:"company"`
	Id          int64    `attribute:"id"`
	Login       string   `attribute:"login"`
	Email       string   `attribute:"email"`
	Type        string   `attribute:"type"`
	URL         string   `attribute:"url"`
	Permissions []string `attribute:"permissions"`
}

type YamlTransform

type YamlTransform struct {
	YamlPath    string `hcl:"yaml_path" json:"yaml_path"`
	StringValue string `hcl:"string_value" json:"string_value"`
}

type YamlTransformFix

type YamlTransformFix struct {
	*golden.BaseBlock
	*BaseFix
	FilePath  string          `hcl:"file_path" json:"file_path" validate:"endswith=.yaml|endswith=.yml"`
	Transform []YamlTransform `hcl:"transform,block"`
}

func (*YamlTransformFix) Apply

func (y *YamlTransformFix) Apply() error

func (*YamlTransformFix) Type

func (y *YamlTransformFix) Type() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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