diff --git a/cmd/server.go b/cmd/server.go index 4c1f35628f..39ee0229df 100644 --- a/cmd/server.go +++ b/cmd/server.go @@ -450,7 +450,7 @@ func (s *ServerCmd) validate(userConfig server.UserConfig) error { return fmt.Errorf("--%s and --%s are both required for ssl", SSLKeyFileFlag, SSLCertFileFlag) } if userConfig.AllowRepoConfig && userConfig.RepoConfig != "" { - return fmt.Errorf("You cannot use both --%s and --%s together. --%s is deprecated and will be removed in a later version, you should use --%s instead.", AllowRepoConfigFlag, RepoConfigFlag, AllowRepoConfigFlag, RepoConfigFlag) + return fmt.Errorf("You cannot use both --%s and --%s together. --%s is deprecated and will be removed in a later version, you should use --%s instead", AllowRepoConfigFlag, RepoConfigFlag, AllowRepoConfigFlag, RepoConfigFlag) } // The following combinations are valid. diff --git a/cmd/server_test.go b/cmd/server_test.go index 655a98b9b8..ef949b356f 100644 --- a/cmd/server_test.go +++ b/cmd/server_test.go @@ -903,11 +903,11 @@ func TestExecute_BitbucketServerBaseURLPort(t *testing.T) { // Cannot use both --allow-repo-config and --repo-config func TestExecute_AllowRepoConfigWithAllowRestrictedRepoConfig(t *testing.T) { c := setup(map[string]interface{}{ - cmd.AllowRepoConfigFlag: true, + cmd.AllowRepoConfigFlag: true, cmd.RepoConfigFlag: "somefile", }) err := c.Execute() - ErrEquals(t, "You cannot use both --allow-repo-config and --repo-config together. --allow-repo-config is deprecated and will be removed in a later version, you should use --repo-config instead.", err) + ErrEquals(t, "You cannot use both --allow-repo-config and --repo-config together. --allow-repo-config is deprecated and will be removed in a later version, you should use --repo-config instead", err) } func setup(flags map[string]interface{}) *cobra.Command { diff --git a/server/events/project_command_builder_test.go b/server/events/project_command_builder_test.go index a12e15b7ca..8753b9ca7c 100644 --- a/server/events/project_command_builder_test.go +++ b/server/events/project_command_builder_test.go @@ -37,12 +37,12 @@ func TestDefaultProjectCommandBuilder_BuildAutoplanCommands(t *testing.T) { exp: []exp{ { projectConfig: &valid.Project{ - Dir: ".", + Dir: ".", Workspace: "default", - Autoplan: getDefaultAutoPlan(), + Autoplan: getDefaultAutoPlan(), }, - dir: ".", - workspace: "default", + dir: ".", + workspace: "default", }, }, }, @@ -272,16 +272,16 @@ func TestDefaultProjectCommandBuilder_RepoRestrictionsBuildPlanCommands(t *testi When(vcsClient.GetModifiedFiles(baseRepo, pull)).ThenReturn([]string{"main.tf"}, nil) builder := &events.DefaultProjectCommandBuilder{ - WorkingDirLocker: events.NewDefaultWorkingDirLocker(), - WorkingDir: workingDir, - ParserValidator: &yaml.ParserValidator{}, - VCSClient: vcsClient, - ProjectFinder: &events.DefaultProjectFinder{}, - AllowRepoConfig: false, - RepoConfig: repoConfig, - PendingPlanFinder: &events.DefaultPendingPlanFinder{}, - AllowRepoConfigFlag: "allow-repo-config", - CommentBuilder: &events.CommentParser{}, + WorkingDirLocker: events.NewDefaultWorkingDirLocker(), + WorkingDir: workingDir, + ParserValidator: &yaml.ParserValidator{}, + VCSClient: vcsClient, + ProjectFinder: &events.DefaultProjectFinder{}, + AllowRepoConfig: false, + RepoConfig: repoConfig, + PendingPlanFinder: &events.DefaultPendingPlanFinder{}, + AllowRepoConfigFlag: "allow-repo-config", + CommentBuilder: &events.CommentParser{}, } ctxs, err := builder.BuildAutoplanCommands(&events.CommandContext{ @@ -358,15 +358,15 @@ func TestDefaultProjectCommandBuilder_BuildSingleApplyCommandRepoRestrictions(t When(vcsClient.GetModifiedFiles(baseRepo, pull)).ThenReturn([]string{"main.tf"}, nil) builder := &events.DefaultProjectCommandBuilder{ - WorkingDirLocker: events.NewDefaultWorkingDirLocker(), - WorkingDir: workingDir, - ParserValidator: &yaml.ParserValidator{}, - VCSClient: vcsClient, - ProjectFinder: &events.DefaultProjectFinder{}, - AllowRepoConfig: false, - RepoConfig: repoConfig, - AllowRepoConfigFlag: "allow-repo-config", - CommentBuilder: &events.CommentParser{}, + WorkingDirLocker: events.NewDefaultWorkingDirLocker(), + WorkingDir: workingDir, + ParserValidator: &yaml.ParserValidator{}, + VCSClient: vcsClient, + ProjectFinder: &events.DefaultProjectFinder{}, + AllowRepoConfig: false, + RepoConfig: repoConfig, + AllowRepoConfigFlag: "allow-repo-config", + CommentBuilder: &events.CommentParser{}, } cmdCtx := &events.CommandContext{ @@ -423,15 +423,15 @@ func TestDefaultProjectCommandBuilder_BuildSinglePlanApplyCommand(t *testing.T) Name: models.PlanCommand, Workspace: "myworkspace", }, - AtlantisYAML: "", + AtlantisYAML: "", ExpProjectConfig: &valid.Project{ - Dir: ".", + Dir: ".", Workspace: "myworkspace", - Autoplan: getDefaultAutoPlan(), + Autoplan: getDefaultAutoPlan(), }, - ExpCommentArgs: []string{"commentarg"}, - ExpWorkspace: "myworkspace", - ExpDir: ".", + ExpCommentArgs: []string{"commentarg"}, + ExpWorkspace: "myworkspace", + ExpDir: ".", }, { Description: "no atlantis.yaml with project flag", @@ -750,15 +750,15 @@ func TestDefaultProjectCommandBuilder_BuildMultiPlanNoAtlantisYAML(t *testing.T) Equals(t, "project1", ctxs[0].RepoRelDir) Equals(t, "default", ctxs[0].Workspace) project1Config := valid.Project{ - Dir: "project1", + Dir: "project1", Workspace: events.DefaultWorkspace, - Autoplan: getDefaultAutoPlan(), + Autoplan: getDefaultAutoPlan(), } project2Config := valid.Project{ - Dir: "project2", + Dir: "project2", Workspace: events.DefaultWorkspace, - Autoplan: getDefaultAutoPlan(), + Autoplan: getDefaultAutoPlan(), } Equals(t, project1Config, *ctxs[0].ProjectConfig) Equals(t, "project2", ctxs[1].RepoRelDir) @@ -1096,6 +1096,6 @@ func String(v string) *string { return &v } func getDefaultAutoPlan() valid.Autoplan { return valid.Autoplan{ WhenModified: []string{"**/*.tf*"}, - Enabled: true, + Enabled: true, } } diff --git a/server/events/yaml/parser_validator.go b/server/events/yaml/parser_validator.go index 7b6a8c3cd9..b13eda728a 100644 --- a/server/events/yaml/parser_validator.go +++ b/server/events/yaml/parser_validator.go @@ -131,7 +131,7 @@ func (p *ParserValidator) parseAndValidate(configData []byte, repoConfig raw.Rep } func (p *ParserValidator) getOverrideErrorMessage(key string) error { - return fmt.Errorf("%q cannot be specified in %q by default. To enable this, add %q to %q in the server side repo config.", key, AtlantisYAMLFilename, key, raw.AllowedOverridesKey) + return fmt.Errorf("%q cannot be specified in %q by default. To enable this, add %q to %q in the server side repo config", key, AtlantisYAMLFilename, key, raw.AllowedOverridesKey) } // Checks any sensitive fields present in atlantis.yaml against the list of allowed overrides and merge the configuration @@ -172,7 +172,7 @@ func (p *ParserValidator) ValidateOverridesAndMergeConfig(config raw.Config, rep config.Projects = finalProjects if len(config.Workflows) > 0 && !(allowAllRepoConfig || lastMatchingRepo.AllowCustomWorkflows) { - return config, fmt.Errorf("%q cannot be specified in %q by default. To enable this, set %q to true in the server side repo config.", raw.CustomWorkflowsKey, AtlantisYAMLFilename, raw.CustomWorkflowsKey) + return config, fmt.Errorf("%q cannot be specified in %q by default. To enable this, set %q to true in the server side repo config", raw.CustomWorkflowsKey, AtlantisYAMLFilename, raw.CustomWorkflowsKey) } else if len(config.Workflows) == 0 { if len(repoConfig.Workflows) > 0 { config.Workflows = repoConfig.Workflows diff --git a/server/events/yaml/parser_validator_test.go b/server/events/yaml/parser_validator_test.go index 45cbf66ac5..4117f01e91 100644 --- a/server/events/yaml/parser_validator_test.go +++ b/server/events/yaml/parser_validator_test.go @@ -745,7 +745,7 @@ projects: repos: - id: /.*/ `, - expErr: `"workflow" cannot be specified in "atlantis.yaml" by default. To enable this, add "workflow" to "allowed_overrides" in the server side repo config.`, + expErr: `"workflow" cannot be specified in "atlantis.yaml" by default. To enable this, add "workflow" to "allowed_overrides" in the server side repo config`, }, { description: "atlantis config with custom workflows denied by repo config", @@ -763,7 +763,7 @@ repos: - id: /.*/ allowed_overrides: ["workflow"] `, - expErr: `"workflows" cannot be specified in "atlantis.yaml" by default. To enable this, set "workflows" to true in the server side repo config.`, + expErr: `"workflows" cannot be specified in "atlantis.yaml" by default. To enable this, set "workflows" to true in the server side repo config`, }, { description: "atlantis config with workflow override allowed by repo config", @@ -851,11 +851,11 @@ projects: repos: - id: /.*/ `, - expErr: `"apply_requirements" cannot be specified in "atlantis.yaml" by default. To enable this, add "apply_requirements" to "allowed_overrides" in the server side repo config.`, + expErr: `"apply_requirements" cannot be specified in "atlantis.yaml" by default. To enable this, add "apply_requirements" to "allowed_overrides" in the server side repo config`, }, { description: "last matching repo should be used", - repoName: "thisproject", + repoName: "thisproject", atlantisYaml: ` version: 2 projects: @@ -871,25 +871,25 @@ workflows: workflow1: ~ workflow2: ~ `, - exp: valid.Config{ - Version: 2, - Projects: []valid.Project{ - { - Dir: ".", - Workspace: "default", - Workflow: String("workflow2"), - Autoplan: valid.Autoplan{ - WhenModified: []string{"**/*.tf*"}, - Enabled: true, + exp: valid.Config{ + Version: 2, + Projects: []valid.Project{ + { + Dir: ".", + Workspace: "default", + Workflow: String("workflow2"), + Autoplan: valid.Autoplan{ + WhenModified: []string{"**/*.tf*"}, + Enabled: true, + }, + }, + }, + Workflows: map[string]valid.Workflow{ + "workflow1": {}, + "workflow2": {}, }, }, }, - Workflows: map[string]valid.Workflow{ - "workflow1": {}, - "workflow2": {}, - }, - }, - }, { description: "atlantis config uses a workflow that doesn't exist in atlantis.yaml or repo config", repoName: "anything", diff --git a/server/events/yaml/raw/repo_config.go b/server/events/yaml/raw/repo_config.go index a0a7cdba0a..f87e1ae811 100644 --- a/server/events/yaml/raw/repo_config.go +++ b/server/events/yaml/raw/repo_config.go @@ -55,7 +55,6 @@ func checkOverrideValues(values interface{}) error { func (r *Repo) IsOverrideAllowed(override string) bool { for _, allowed := range r.AllowedOverrides { - fmt.Printf("checking %s against %s\n", allowed, override); if allowed == override { return true } diff --git a/server/server_test.go b/server/server_test.go index 139c29fb6b..6558cb4894 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -67,12 +67,10 @@ repos: Ok(t, err) s, err := server.NewServer(server.UserConfig{ - DataDir: tmpDir, - RepoConfig: repoFileLocation, + DataDir: tmpDir, + RepoConfig: repoFileLocation, AtlantisURL: "http://example.com", - }, server.Config { - - }) + }, server.Config{}) Ok(t, err) Equals(t, s.CommandRunner.ProjectCommandBuilder.(*events.DefaultProjectCommandBuilder).RepoConfig, expConfig) }