Skip to content

Commit

Permalink
feat: remove environment variables requirement, set values via comman…
Browse files Browse the repository at this point in the history
…d line

Signed-off-by: João Vanzuita <joao@kubeshop.io>
  • Loading branch information
João Vanzuita committed Jul 20, 2022
1 parent 8c09dc9 commit efe9dcf
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 50 deletions.
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ GitOps integration, secrets management, production and development Kubernetes en
- [Destroy](#destroy)
- [Available Commands]()

## Setup

The setup is extremely simple, create a `.env` file in the root folder, and add the following variables:

| Variable | example |
|--------------------|------------------|
| AWS_PROFILE | default |
| CLOUD_PROVIDER=aws | aws |
| HOSTED_ZONE_NAME | example.com |
| ADMIN_EMAIL | john@example.com |

## Start the container

We run everything on isolation with Docker, for that, start the container with:
Expand Down
4 changes: 0 additions & 4 deletions cmd/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ var infoCmd = &cobra.Command{
if err != nil {
log.Panic(err)
}
err = configs.CheckEnvironment()
if err != nil {
log.Panic(err)
}
fmt.Printf("----------- \n")

fmt.Println(reports.StyleMessage(infoSummary.String()))
Expand Down
7 changes: 7 additions & 0 deletions cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,13 @@ func init() {
if err != nil {
log.Panic(err)
}

initCmd.Flags().String("profile", "", "the profile to provision the cloud resources in")
err = initCmd.MarkFlagRequired("profile")
if err != nil {
log.Panic(err)
}

initCmd.Flags().Bool("clean", false, "delete any local kubefirst content ~/.kubefirst, ~/.k1")

log.SetPrefix("LOG: ")
Expand Down
8 changes: 8 additions & 0 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,13 @@ func ReadConfig() *Config {

config.InstallerEmail = "kubefirst-bot@kubefirst.com"

// If the AWS_SDK_LOAD_CONFIG environment variable is set to a truthy value the shared config file (~/.aws/config)
// will also be loaded in addition to the shared credentials file (~/.aws/credentials).
// AWS SDK client will take it in advance
err = os.Setenv("AWS_SDK_LOAD_CONFIG", "1")
if err != nil {
log.Panicf("unable to set AWS_SDK_LOAD_CONFIG enviroment value, error is: %v", err)
}

return &config
}
27 changes: 0 additions & 27 deletions configs/envvars.go

This file was deleted.

2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,4 @@ services:
- "8200:8200" # Vault
volumes:
- ./:/home/developer/kubefirst
env_file:
- .env
command: sh -c "./scripts/kubefirst-dev.sh"
21 changes: 15 additions & 6 deletions internal/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials/stscreds"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/cip8/autoname"
Expand Down Expand Up @@ -311,12 +312,20 @@ func DestroyBucket(bucketName string) {
}

func GetAWSSession() *session.Session {
sess, err := session.NewSession(&aws.Config{
Region: aws.String(viper.GetString("aws.region"))},
)
if err != nil {
log.Panicf("failed to get session ", err.Error())
}
//sess, err := session.NewSession(&aws.Config{
// Region: aws.String(viper.GetString("aws.region"))},
//)
sess := session.Must(session.NewSessionWithOptions(session.Options{
Config: aws.Config{
Region: aws.String(viper.GetString("aws.region")),
},
Profile: viper.GetString("aws.profile"),

AssumeRoleTokenProvider: stscreds.StdinTokenProvider,
}))
//if err != nil {
// log.Panicf("failed to get session ", err.Error())
//}
return sess
}

Expand Down

0 comments on commit efe9dcf

Please sign in to comment.