digger_config

package
v0.0.0-...-9d61cdf Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 11

Documentation

Index

Constants

View Source
const (
	DependencyConfigurationHard = "hard"
	DependencyConfigurationSoft = "soft"
)

hard - even if dependency project wasn't changed, it will be executed soft - if dependency project wasn't changed, it will be skipped

View Source
const CommentRenderModeBasic = "basic"
View Source
const CommentRenderModeGroupByModule = "group_by_module"

Variables

View Source
var ErrDiggerConfigConflict = errors.New("more than one digger digger_config file detected, please keep either 'digger.yml' or 'digger.yaml'")

Functions

func CollectTerraformEnvConfig

func CollectTerraformEnvConfig(envs *TerraformEnvConfig) (map[string]string, map[string]string)

func CreateProjectDependencyGraph

func CreateProjectDependencyGraph(projects []Project) (graph.Graph[string, Project], error)

func GetFilesWithExtension

func GetFilesWithExtension(workingDir string, ext string) ([]string, error)

func GetPatternsRelativeToRepo

func GetPatternsRelativeToRepo(projectPath string, patterns []string) ([]string, error)

func HandleYamlProjectGeneration

func HandleYamlProjectGeneration(config *DiggerConfigYaml, terraformDir string) error

func LoadDiggerConfig

func LoadDiggerConfig(workingDir string, generateProjects bool) (*DiggerConfig, *DiggerConfigYaml, graph.Graph[string, Project], error)

func LoadDiggerConfigFromString

func LoadDiggerConfigFromString(yamlString string, terraformDir string) (*DiggerConfig, *DiggerConfigYaml, graph.Graph[string, Project], error)

func MatchIncludeExcludePatternsToFile

func MatchIncludeExcludePatternsToFile(fileToMatch string, includePatterns []string, excludePatterns []string) bool

func NormalizeFileName

func NormalizeFileName(fileName string) string

func ValidateDiggerConfig

func ValidateDiggerConfig(config *DiggerConfig) error

func ValidateDiggerConfigYaml

func ValidateDiggerConfigYaml(configYaml *DiggerConfigYaml, fileName string) error

Types

type AssumeRoleForProject

type AssumeRoleForProject struct {
	AwsRoleRegion string
	State         string
	Command       string
}

type AssumeRoleForProjectConfig

type AssumeRoleForProjectConfig struct {
	AwsRoleRegion string `yaml:"aws_role_region"`
	State         string `yaml:"state"`
	Command       string `yaml:"command"`
}

type BlockYaml

type BlockYaml struct {
	Include         string                      `yaml:"include"`
	Exclude         string                      `yaml:"exclude"`
	Workflow        string                      `yaml:"workflow"`
	AwsRoleToAssume *AssumeRoleForProjectConfig `yaml:"aws_role_to_assume,omitempty"`
}

type DependencyConfiguration

type DependencyConfiguration struct {
	Mode string
}

type DependencyConfigurationYaml

type DependencyConfigurationYaml struct {
	Mode string `yaml:"mode"`
}

type DiggerConfig

type DiggerConfig struct {
	ApplyAfterMerge            bool
	AllowDraftPRs              bool
	CommentRenderMode          string
	DependencyConfiguration    DependencyConfiguration
	Projects                   []Project
	AutoMerge                  bool
	Telemetry                  bool
	Workflows                  map[string]Workflow
	MentionDriftedProjectsInPR bool
	TraverseToNestedProjects   bool
}

func ConvertDiggerYamlToConfig

func ConvertDiggerYamlToConfig(diggerYaml *DiggerConfigYaml) (*DiggerConfig, graph.Graph[string, Project], error)

func (*DiggerConfig) GetDirectory

func (c *DiggerConfig) GetDirectory(projectName string) string

func (*DiggerConfig) GetModifiedProjects

func (c *DiggerConfig) GetModifiedProjects(changedFiles []string) ([]Project, map[string]ProjectToSourceMapping)

func (*DiggerConfig) GetProject

func (c *DiggerConfig) GetProject(projectName string) *Project

func (*DiggerConfig) GetProjects

func (c *DiggerConfig) GetProjects(projectName string) []Project

func (*DiggerConfig) GetWorkflow

func (c *DiggerConfig) GetWorkflow(workflowName string) *Workflow

type DiggerConfigYaml

type DiggerConfigYaml struct {
	ApplyAfterMerge            *bool                        `yaml:"apply_after_merge"`
	AllowDraftPRs              *bool                        `yaml:"allow_draft_prs"`
	DependencyConfiguration    *DependencyConfigurationYaml `yaml:"dependency_configuration"`
	Projects                   []*ProjectYaml               `yaml:"projects"`
	AutoMerge                  *bool                        `yaml:"auto_merge"`
	CommentRenderMode          *string                      `yaml:"comment_render_mode"`
	Workflows                  map[string]*WorkflowYaml     `yaml:"workflows"`
	Telemetry                  *bool                        `yaml:"telemetry,omitempty"`
	GenerateProjectsConfig     *GenerateProjectsConfigYaml  `yaml:"generate_projects"`
	TraverseToNestedProjects   *bool                        `yaml:"traverse_to_nested_projects"`
	MentionDriftedProjectsInPR *bool                        `yaml:"mention_drifted_projects_in_pr"`
}

func AutoDetectDiggerConfig

func AutoDetectDiggerConfig(workingDir string) (*DiggerConfigYaml, error)

func LoadDiggerConfigYaml

func LoadDiggerConfigYaml(workingDir string, generateProjects bool) (*DiggerConfigYaml, error)

func LoadDiggerConfigYamlFromString

func LoadDiggerConfigYamlFromString(yamlString string) (*DiggerConfigYaml, error)

type DirWalker

type DirWalker interface {
	GetDirs(workingDir string, config DiggerConfigYaml) ([]string, error)
}

type EnvVar

type EnvVar struct {
	Name      string
	ValueFrom string
	Value     string
}

type EnvVarYaml

type EnvVarYaml struct {
	Name      string `yaml:"name"`
	ValueFrom string `yaml:"value_from"`
	Value     string `yaml:"value"`
}

type File

type File struct {
	Filename string
}

type FileSystemModuleDirWalker

type FileSystemModuleDirWalker struct {
}

func (*FileSystemModuleDirWalker) GetDirs

func (walker *FileSystemModuleDirWalker) GetDirs(workingDir string, configYaml *DiggerConfigYaml) ([]string, error)

type FileSystemTerragruntDirWalker

type FileSystemTerragruntDirWalker struct {
}

func (*FileSystemTerragruntDirWalker) GetDirs

func (walker *FileSystemTerragruntDirWalker) GetDirs(workingDir string, configYaml *DiggerConfigYaml) ([]string, error)

type FileSystemTopLevelTerraformDirWalker

type FileSystemTopLevelTerraformDirWalker struct {
}

func (*FileSystemTopLevelTerraformDirWalker) GetDirs

func (walker *FileSystemTopLevelTerraformDirWalker) GetDirs(workingDir string, configYaml *DiggerConfigYaml) ([]string, error)

type GenerateProjectsConfigYaml

type GenerateProjectsConfigYaml struct {
	Include                 string                      `yaml:"include"`
	Exclude                 string                      `yaml:"exclude"`
	Terragrunt              bool                        `yaml:"terragrunt"`
	Blocks                  []BlockYaml                 `yaml:"blocks"`
	TerragruntParsingConfig *TerragruntParsingConfig    `yaml:"terragrunt_parsing,omitempty"`
	AwsRoleToAssume         *AssumeRoleForProjectConfig `yaml:"aws_role_to_assume,omitempty"`
}

type Project

type Project struct {
	Name               string
	Dir                string
	Workspace          string
	Terragrunt         bool
	OpenTofu           bool
	Workflow           string
	WorkflowFile       string
	IncludePatterns    []string
	ExcludePatterns    []string
	DependencyProjects []string
	DriftDetection     bool
	AwsRoleToAssume    *AssumeRoleForProject
}

type ProjectToSourceMapping

type ProjectToSourceMapping struct {
	ImpactingLocations []string          `json:"impacting_locations"`
	CommentIds         map[string]string `json:"comment_ids"` // impactingLocation => PR commentId
}

type ProjectYaml

type ProjectYaml struct {
	Name               string                      `yaml:"name"`
	Dir                string                      `yaml:"dir"`
	Workspace          string                      `yaml:"workspace"`
	Terragrunt         bool                        `yaml:"terragrunt"`
	OpenTofu           bool                        `yaml:"opentofu"`
	Workflow           string                      `yaml:"workflow"`
	WorkflowFile       *string                     `yaml:"workflow_file""`
	IncludePatterns    []string                    `yaml:"include_patterns,omitempty"`
	ExcludePatterns    []string                    `yaml:"exclude_patterns,omitempty"`
	DependencyProjects []string                    `yaml:"depends_on,omitempty"`
	DriftDetection     *bool                       `yaml:"drift_detection,omitempty"`
	AwsRoleToAssume    *AssumeRoleForProjectConfig `yaml:"aws_role_to_assume,omitempty"`
}

func (*ProjectYaml) UnmarshalYAML

func (p *ProjectYaml) UnmarshalYAML(unmarshal func(interface{}) error) error

type Stage

type Stage struct {
	Steps []Step
}

type StageYaml

type StageYaml struct {
	Steps []StepYaml `yaml:"steps"`
}

func (*StageYaml) ToCoreStage

func (s *StageYaml) ToCoreStage() Stage

type Step

type Step struct {
	Action    string
	Value     string
	ExtraArgs []string
	Shell     string
}

type StepYaml

type StepYaml struct {
	Action    string
	Value     string
	ExtraArgs []string `yaml:"extra_args,omitempty"`
	Shell     string
}

func (*StepYaml) ToCoreStep

func (s *StepYaml) ToCoreStep() Step

func (*StepYaml) UnmarshalYAML

func (s *StepYaml) UnmarshalYAML(value *yaml.Node) error

type TerraformEnvConfig

type TerraformEnvConfig struct {
	State    []EnvVar
	Commands []EnvVar
}

type TerraformEnvConfigYaml

type TerraformEnvConfigYaml struct {
	State    []EnvVarYaml `yaml:"state"`
	Commands []EnvVarYaml `yaml:"commands"`
}

type TerragruntParsingConfig

type TerragruntParsingConfig struct {
	GitRoot                  *string  `yaml:"gitRoot,omitempty"`
	AutoPlan                 bool     `yaml:"autoPlan"`
	AutoMerge                bool     `yaml:"autoMerge"`
	IgnoreParentTerragrunt   *bool    `yaml:"ignoreParentTerragrunt,omitempty"`
	CreateParentProject      bool     `yaml:"createParentProject"`
	IgnoreDependencyBlocks   bool     `yaml:"ignoreDependencyBlocks"`
	Parallel                 *bool    `yaml:"parallel,omitempty"`
	CreateWorkspace          bool     `yaml:"createWorkspace"`
	CreateProjectName        bool     `yaml:"createProjectName"`
	DefaultTerraformVersion  string   `yaml:"defaultTerraformVersion"`
	DefaultWorkflow          string   `yaml:"defaultWorkflow"`
	FilterPath               string   `yaml:"filterPath"`
	OutputPath               string   `yaml:"outputPath"`
	PreserveWorkflows        *bool    `yaml:"preserveWorkflows,omitempty"`
	PreserveProjects         bool     `yaml:"preserveProjects"`
	CascadeDependencies      *bool    `yaml:"cascadeDependencies,omitempty"`
	DefaultApplyRequirements []string `yaml:"defaultApplyRequirements"`
	//NumExecutors                   int64	`yaml:"numExecutors"`
	ProjectHclFiles                []string `yaml:"projectHclFiles"`
	CreateHclProjectChilds         bool     `yaml:"createHclProjectChilds"`
	CreateHclProjectExternalChilds *bool    `yaml:"createHclProjectExternalChilds,omitempty"`
	UseProjectMarkers              bool     `yaml:"useProjectMarkers"`
	ExecutionOrderGroups           *bool    `yaml:"executionOrderGroups"`
}

type Workflow

type Workflow struct {
	EnvVars       *TerraformEnvConfig
	Plan          *Stage
	Apply         *Stage
	Configuration *WorkflowConfiguration
}

type WorkflowConfiguration

type WorkflowConfiguration struct {
	OnPullRequestPushed           []string
	OnPullRequestClosed           []string
	OnPullRequestConvertedToDraft []string
	OnCommitToDefault             []string
}

type WorkflowConfigurationYaml

type WorkflowConfigurationYaml struct {
	OnPullRequestPushed []string `yaml:"on_pull_request_pushed"`
	OnPullRequestClosed []string `yaml:"on_pull_request_closed"`
	// pull request converted to draft
	OnPullRequestConvertedToDraft []string `yaml:"on_pull_request_to_draft"`
	OnCommitToDefault             []string `yaml:"on_commit_to_default"`
}

type WorkflowYaml

type WorkflowYaml struct {
	EnvVars       *TerraformEnvConfigYaml    `yaml:"env_vars"`
	Plan          *StageYaml                 `yaml:"plan,omitempty"`
	Apply         *StageYaml                 `yaml:"apply,omitempty"`
	Configuration *WorkflowConfigurationYaml `yaml:"workflow_configuration"`
}

func (*WorkflowYaml) UnmarshalYAML

func (w *WorkflowYaml) UnmarshalYAML(unmarshal func(interface{}) error) error

Directories

Path Synopsis
terragrunt

Jump to

Keyboard shortcuts

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