Skip to content

Commit

Permalink
remove populator code
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaysomani07 committed Feb 27, 2023
1 parent 5fb5401 commit 0dfc0c7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 803 deletions.
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,10 @@ else
DATE ?= $(shell date -u -d @${SOURCE_DATE_EPOCH} +"%Y-%m-%dT%H:%M:%SZ")
endif

setup:
docker-compose up -d

setup-down:
docker ps -a --format "{{.ID}} {{.Names}}" | grep cloudlens| awk '{print $$1}'| xargs docker stop | xargs docker rm -v

build:
go build ${GO_FLAGS} \
-ldflags "-w -s -X ${PACKAGE}/cmd.version=${VERSION} -X ${PACKAGE}/cmd.commit=${GIT_REV} -X ${PACKAGE}/cmd.date=${DATE}" \
-a -tags netgo -o ${OUTPUT_BIN} main.go

run: build
./execs/cloudlens

populate: build
./execs/cloudlens lspop
103 changes: 0 additions & 103 deletions cmd/localstackpopulator.go

This file was deleted.

16 changes: 13 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"fmt"
"os"

cfg "github.com/aws/aws-sdk-go-v2/config"
"github.com/mattn/go-colorable"
"github.com/one2nc/cloudlens/internal"
"github.com/one2nc/cloudlens/internal/aws"
"github.com/one2nc/cloudlens/internal/color"
"github.com/one2nc/cloudlens/internal/config"
"github.com/one2nc/cloudlens/internal/view"
pop "github.com/one2nc/cloudlens/populator"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -60,14 +60,14 @@ func run(cmd *cobra.Command, args []string) {
//TODO profiles and regions should under aws
profiles := readAndValidateProfile()
if profiles[0] == "default" && len(region) == 0 {
region = pop.GetDefaultAWSRegion()
region = getDefaultAWSRegion()
} else {
region = "ap-south-1"
}

regions := readAndValidateRegion()
//TODO Move this in the AWS folder
sess, err := config.GetSession(profiles[0], pop.GetDefaultAWSRegion())
sess, err := config.GetSession(profiles[0], getDefaultAWSRegion())
if err != nil {
panic(fmt.Sprintf("aws session init failed -- %v", err))
}
Expand Down Expand Up @@ -127,3 +127,13 @@ func readAndValidateRegion() []string {
}
return regions
}

func getDefaultAWSRegion() string {
cfg, err := cfg.LoadDefaultConfig(context.TODO())
if err != nil {
fmt.Fprintf(os.Stderr, "failed to load AWS SDK config: %v\n", err)
os.Exit(1)
}
region := cfg.Region
return region
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ require (
github.com/mattn/go-colorable v0.1.13
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/one2nc/cloud-lens v0.1.11
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sahilm/fuzzy v0.1.0
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRC
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/one2nc/cloud-lens v0.1.11 h1:6dQjjBprS5VIoEd4SE0htXQYZfZ3R3fr2yesYrh9FsU=
github.com/one2nc/cloud-lens v0.1.11/go.mod h1:2HvhXDd/kApqayeiqVCGq3tcgCl5Q/tFcjw0dXEu3GE=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
Loading

0 comments on commit 0dfc0c7

Please sign in to comment.