Skip to content

Commit

Permalink
move env package to service internal (#24)
Browse files Browse the repository at this point in the history
* move env package to service internal
  • Loading branch information
grantleehoffman authored Jun 15, 2021
1 parent 6f304a7 commit dd61657
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v0.2.0 (2021-06-15)
### Changed
* Move env to internal service package

## v0.1.3 (2021-06-14)
### Changed
* Using X-B3-TraceId as trace HTTP header
Expand Down
4 changes: 2 additions & 2 deletions service/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"regexp"
"strings"

"github.com/argoproj-labs/argo-cloudops/internal/env"
"github.com/argoproj-labs/argo-cloudops/service/internal/credentials"
"github.com/argoproj-labs/argo-cloudops/service/internal/env"
"github.com/argoproj-labs/argo-cloudops/service/internal/workflow"
vault "github.com/hashicorp/vault/api"

Expand Down Expand Up @@ -78,7 +78,7 @@ type handler struct {
argoCtx context.Context
config *Config
gitClient gitClient
env env.EnvVars
env env.Vars
newCredsProviderSvc func(c credentials.VaultConfig, h http.Header) (*vault.Client, error)
vaultConfig credentials.VaultConfig
}
Expand Down
4 changes: 2 additions & 2 deletions service/handlers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"path/filepath"
"testing"

"github.com/argoproj-labs/argo-cloudops/internal/env"
"github.com/argoproj-labs/argo-cloudops/service/internal/credentials"
"github.com/argoproj-labs/argo-cloudops/service/internal/env"
"github.com/argoproj-labs/argo-cloudops/service/internal/workflow"

"github.com/go-kit/kit/log"
Expand Down Expand Up @@ -586,7 +586,7 @@ func executeRequest(method string, url string, body *bytes.Buffer, asAdmin bool)
config: config,
gitClient: newMockGitClient(),
newCredsProviderSvc: mockCredsProvSvc,
env: env.EnvVars{
env: env.Vars{
AdminSecret: testPassword},
}

Expand Down
8 changes: 4 additions & 4 deletions internal/env/env.go → service/internal/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

const appPrefix = "ARGO_CLOUDOPS"

type EnvVars struct {
type Vars struct {
AdminSecret string `split_words:"true" required:"true"`
VaultRole string `envconfig:"VAULT_ROLE" required:"true"`
VaultSecret string `envconfig:"VAULT_SECRET" required:"true"`
Expand All @@ -23,12 +23,12 @@ type EnvVars struct {
}

var (
instance EnvVars
instance Vars
once sync.Once
err error
)

func GetEnv() (EnvVars, error) {
func GetEnv() (Vars, error) {
once.Do(func() {
err = envconfig.Process(appPrefix, &instance)
if err != nil {
Expand All @@ -39,7 +39,7 @@ func GetEnv() (EnvVars, error) {
return instance, err
}

func (values EnvVars) validate() error {
func (values Vars) validate() error {
if len(values.AdminSecret) < 16 {
return errors.New("admin secret must be at least 16 characers long")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func setup() {
for _, envVar := range allEnvVars {
os.Unsetenv(envVar)
}
instance = EnvVars{}
instance = Vars{}
once = sync.Once{}
}

Expand Down
2 changes: 1 addition & 1 deletion service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"net/http"
"os"

"github.com/argoproj-labs/argo-cloudops/internal/env"
"github.com/argoproj-labs/argo-cloudops/service/internal/credentials"
"github.com/argoproj-labs/argo-cloudops/service/internal/env"
"github.com/argoproj-labs/argo-cloudops/service/internal/workflow"

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

0 comments on commit dd61657

Please sign in to comment.