Skip to content

Commit

Permalink
Rename library. Update Readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
itsdalmo committed Jul 19, 2018
1 parent e688cad commit 5359a2f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
20 changes: 8 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,24 @@ Import the library and invoke it prior to parsing flags or reading environment v
package main

import (
"github.com/sirupsen/logrus"
awsenv "github.com/telia-oss/aws-env"
"github.com/aws/aws-sdk-go/aws/session"
environment "github.com/telia-oss/aws-env"
)

func main() {
// New logger
logger := logrus.New()
logger.Formatter = &logrus.JSONFormatter{}

// New AWS Session
sess, err := session.NewSession()
if err != nil {
logger.Fatalf("failed to create a new session: %s", err)
panic(fmt.Errorf("failed to create new aws session: %s", err))
}

// Populate secrets using awsenv
env, err := awsenv.New(sess, logger)
// Populate secrets using aws-env
env, err := environment.New(sess)
if err != nil {
logger.Fatalf("failed to initialize awsenv: %s", err)
panic(fmt.Errorf("failed to initialize aws-env: %s", err))
}
if err := env.Replace(); err != nil {
logger.Fatalf("failed to populate environment variables: %s", err)
if err := env.Populate(); err != nil {
panic(fmt.Errorf("failed to populate environment: %s", err))
}
}
```
10 changes: 5 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/aws/aws-sdk-go/aws/session"
flags "github.com/jessevdk/go-flags"
awsenv "github.com/telia-oss/aws-env"
environment "github.com/telia-oss/aws-env"
)

const (
Expand All @@ -36,15 +36,15 @@ func (c *execCommand) Execute(args []string) error {

sess, err := session.NewSession()
if err != nil {
return fmt.Errorf("failed to create new session: %s", err)
return fmt.Errorf("failed to create new aws session: %s", err)
}

env, err := awsenv.New(sess)
env, err := environment.New(sess)
if err != nil {
return fmt.Errorf("failed to create new manager: %s", err)
return fmt.Errorf("failed to initialize aws-env: %s", err)
}
if err := env.Populate(); err != nil {
return fmt.Errorf("failed to set up environment: %s", err)
return fmt.Errorf("failed to populate environment: %s", err)
}

if err := syscall.Exec(path, args, os.Environ()); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion mod.go → environment.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package awsenv
package environment

import (
"encoding/base64"
Expand Down
6 changes: 3 additions & 3 deletions mod_test.go → environment_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package awsenv_test
package environment_test

import (
"encoding/base64"
Expand All @@ -10,7 +10,7 @@ import (
"github.com/aws/aws-sdk-go/service/secretsmanager"
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/golang/mock/gomock"
awsenv "github.com/telia-oss/aws-env"
environment "github.com/telia-oss/aws-env"
"github.com/telia-oss/aws-env/mocks"
)

Expand Down Expand Up @@ -88,7 +88,7 @@ func TestMain(t *testing.T) {
}()

// Run tests
env := awsenv.NewTestManager(sm, ssm, kms)
env := environment.NewTestManager(sm, ssm, kms)
if err := env.Populate(); err != nil {
t.Fatalf("unexpected error: %s", err)
}
Expand Down

0 comments on commit 5359a2f

Please sign in to comment.