Skip to content
This repository was archived by the owner on Feb 2, 2021. It is now read-only.

Commit e1b85f0

Browse files
Martin Dekovalexellis
authored andcommitted
Change naming of constants
Changing the naming to the constants as they began to feel confusing. So now GitLabFilter stands for `scm_gitlab` and GitLabSCM stands for 'gitlab' how we configure the SCM field in the yaml file. The same for GitHub Signed-off-by: Martin Dekov <mdekov@vmware.com>
1 parent 68b1ffb commit e1b85f0

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ key.pub
1010
ofc-bootstrap-darwin
1111
ofc-bootstrap.exe
1212
init.yaml
13-
13+
main

main

-3.12 MB
Binary file not shown.

main.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func process(plan types.Plan) error {
157157
}
158158

159159
if plan.Orchestration == OrchestrationK8s {
160+
160161
nsErr := createNamespaces()
161162
if nsErr != nil {
162163
log.Println(nsErr)
@@ -664,10 +665,10 @@ func filterDNSFeature(plan types.Plan) (types.Plan, error) {
664665
}
665666

666667
func filterGitRepositoryManager(plan types.Plan) (types.Plan, error) {
667-
if plan.SCM == types.GitLabManager {
668-
plan.Features = append(plan.Features, types.GitLabSCM)
669-
} else if plan.SCM == types.GitHubManager {
670-
plan.Features = append(plan.Features, types.GitHubSCM)
668+
if plan.SCM == types.GitLabSCM {
669+
plan.Features = append(plan.Features, types.GitLabFeature)
670+
} else if plan.SCM == types.GitHubSCM {
671+
plan.Features = append(plan.Features, types.GitHubFeature)
671672
} else {
672673
return plan, fmt.Errorf("Error unsupported Git repository manager: %s", plan.SCM)
673674
}

main_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,27 +74,27 @@ func Test_filterFeatures(t *testing.T) {
7474
{
7575
title: "Every field which defines populated feature is populated for github",
7676
planConfig: types.Plan{
77-
SCM: types.GitHubManager,
77+
SCM: types.GitHubSCM,
7878
TLS: true,
7979
TLSConfig: types.TLSConfig{
8080
DNSService: types.Route53,
8181
},
8282
EnableOAuth: true,
8383
},
84-
expectedFeatures: []string{types.DefaultFeature, types.GitHubSCM, types.Auth, types.Route53DNS},
84+
expectedFeatures: []string{types.DefaultFeature, types.GitHubFeature, types.Auth, types.Route53DNS},
8585
expectedError: nil,
8686
},
8787
{
8888
title: "Every field which defines populated feature is populated for gitlab",
8989
planConfig: types.Plan{
90-
SCM: types.GitLabManager,
90+
SCM: types.GitLabSCM,
9191
TLS: true,
9292
TLSConfig: types.TLSConfig{
9393
DNSService: types.Route53,
9494
},
9595
EnableOAuth: true,
9696
},
97-
expectedFeatures: []string{types.DefaultFeature, types.GitLabSCM, types.Auth, types.Route53DNS},
97+
expectedFeatures: []string{types.DefaultFeature, types.GitLabFeature, types.Auth, types.Route53DNS},
9898
expectedError: nil,
9999
},
100100
{
@@ -117,7 +117,7 @@ func Test_filterFeatures(t *testing.T) {
117117
DNSService: types.Route53,
118118
},
119119
EnableOAuth: true,
120-
SCM: types.GitHubManager,
120+
SCM: types.GitHubSCM,
121121
},
122122
expectedFeatures: []string{types.DefaultFeature, types.Auth, types.Route53DNS},
123123
expectedError: nil,
@@ -160,17 +160,17 @@ func Test_filterGitRepositoryManager(t *testing.T) {
160160
{
161161
title: "SCM field is populated for gitlab",
162162
planConfig: types.Plan{
163-
SCM: types.GitLabManager,
163+
SCM: types.GitLabSCM,
164164
},
165-
expectedFeature: []string{types.GitLabSCM},
165+
expectedFeature: []string{types.GitLabFeature},
166166
expectedError: nil,
167167
},
168168
{
169169
title: "SCM field is populated for github",
170170
planConfig: types.Plan{
171-
SCM: types.GitHubManager,
171+
SCM: types.GitHubSCM,
172172
},
173-
expectedFeature: []string{types.GitHubSCM},
173+
expectedFeature: []string{types.GitHubFeature},
174174
expectedError: nil,
175175
},
176176
{

pkg/types/types.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import (
88
const (
99
// DefaultFeature filter is for the features which are mandatory
1010
DefaultFeature = "default"
11-
// GitHubSCM filter enables secrets created with the scm_github filter
12-
GitHubSCM = "scm_github"
13-
// GitLabSCM filter is the feature which enables secret creation for GitLab
14-
GitLabSCM = "scm_gitlab"
11+
// GitHubFeature filter enables secrets created with the scm_github filter
12+
GitHubFeature = "scm_github"
13+
// GitLabFeature filter is the feature which enables secret creation for GitLab
14+
GitLabFeature = "scm_gitlab"
1515
// Auth filter enables OAuth secret creation
1616
Auth = "auth"
1717
// GCPDNS filter enables the creation of secrets for Google Cloud Platform DNS when TLS is enabled
@@ -28,9 +28,9 @@ const (
2828
// Route53 is the dns_service field in yaml file for Amazon
2929
Route53 = "route53"
3030
// GitLabManager repository manager name as displayed in the init.yaml file
31-
GitLabManager = "gitlab"
31+
GitLabSCM = "gitlab"
3232
// GitHubManager repository manager name as displayed in the init.yaml file
33-
GitHubManager = "github"
33+
GitHubSCM = "github"
3434
)
3535

3636
type Plan struct {

0 commit comments

Comments
 (0)