Skip to content

Commit dd61657

Browse files
move env package to service internal (#24)
* move env package to service internal
1 parent 6f304a7 commit dd61657

File tree

6 files changed

+14
-10
lines changed

6 files changed

+14
-10
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.2.0 (2021-06-15)
4+
### Changed
5+
* Move env to internal service package
6+
37
## v0.1.3 (2021-06-14)
48
### Changed
59
* Using X-B3-TraceId as trace HTTP header

service/handlers.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import (
1111
"regexp"
1212
"strings"
1313

14-
"github.com/argoproj-labs/argo-cloudops/internal/env"
1514
"github.com/argoproj-labs/argo-cloudops/service/internal/credentials"
15+
"github.com/argoproj-labs/argo-cloudops/service/internal/env"
1616
"github.com/argoproj-labs/argo-cloudops/service/internal/workflow"
1717
vault "github.com/hashicorp/vault/api"
1818

@@ -78,7 +78,7 @@ type handler struct {
7878
argoCtx context.Context
7979
config *Config
8080
gitClient gitClient
81-
env env.EnvVars
81+
env env.Vars
8282
newCredsProviderSvc func(c credentials.VaultConfig, h http.Header) (*vault.Client, error)
8383
vaultConfig credentials.VaultConfig
8484
}

service/handlers_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212
"path/filepath"
1313
"testing"
1414

15-
"github.com/argoproj-labs/argo-cloudops/internal/env"
1615
"github.com/argoproj-labs/argo-cloudops/service/internal/credentials"
16+
"github.com/argoproj-labs/argo-cloudops/service/internal/env"
1717
"github.com/argoproj-labs/argo-cloudops/service/internal/workflow"
1818

1919
"github.com/go-kit/kit/log"
@@ -586,7 +586,7 @@ func executeRequest(method string, url string, body *bytes.Buffer, asAdmin bool)
586586
config: config,
587587
gitClient: newMockGitClient(),
588588
newCredsProviderSvc: mockCredsProvSvc,
589-
env: env.EnvVars{
589+
env: env.Vars{
590590
AdminSecret: testPassword},
591591
}
592592

internal/env/env.go service/internal/env/env.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
const appPrefix = "ARGO_CLOUDOPS"
1111

12-
type EnvVars struct {
12+
type Vars struct {
1313
AdminSecret string `split_words:"true" required:"true"`
1414
VaultRole string `envconfig:"VAULT_ROLE" required:"true"`
1515
VaultSecret string `envconfig:"VAULT_SECRET" required:"true"`
@@ -23,12 +23,12 @@ type EnvVars struct {
2323
}
2424

2525
var (
26-
instance EnvVars
26+
instance Vars
2727
once sync.Once
2828
err error
2929
)
3030

31-
func GetEnv() (EnvVars, error) {
31+
func GetEnv() (Vars, error) {
3232
once.Do(func() {
3333
err = envconfig.Process(appPrefix, &instance)
3434
if err != nil {
@@ -39,7 +39,7 @@ func GetEnv() (EnvVars, error) {
3939
return instance, err
4040
}
4141

42-
func (values EnvVars) validate() error {
42+
func (values Vars) validate() error {
4343
if len(values.AdminSecret) < 16 {
4444
return errors.New("admin secret must be at least 16 characers long")
4545
}

internal/env/env_test.go service/internal/env/env_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func setup() {
2727
for _, envVar := range allEnvVars {
2828
os.Unsetenv(envVar)
2929
}
30-
instance = EnvVars{}
30+
instance = Vars{}
3131
once = sync.Once{}
3232
}
3333

service/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"net/http"
88
"os"
99

10-
"github.com/argoproj-labs/argo-cloudops/internal/env"
1110
"github.com/argoproj-labs/argo-cloudops/service/internal/credentials"
11+
"github.com/argoproj-labs/argo-cloudops/service/internal/env"
1212
"github.com/argoproj-labs/argo-cloudops/service/internal/workflow"
1313

1414
"github.com/argoproj/argo-workflows/v3/cmd/argo/commands/client"

0 commit comments

Comments
 (0)