Skip to content

Commit

Permalink
Merge pull request #115 from Bharadwajshivam28/main
Browse files Browse the repository at this point in the history
gcp and azure cloud provider integrated
  • Loading branch information
nikitadugar authored Oct 25, 2024
2 parents cfca1d9 + 476167c commit d060a72
Show file tree
Hide file tree
Showing 21 changed files with 1,295 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-multiplatform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
name: Test on all platforms

env:
GO_VERSION: 1.19
GO_VERSION: 1.23

jobs:
test:
Expand Down
56 changes: 42 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,42 +1,70 @@
module github.com/clouddrove/kuconf

go 1.19
go 1.21

toolchain go1.22.5

require (
cloud.google.com/go/container v1.40.0
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.8.0
github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/containerservice/armcontainerservice v1.0.0
github.com/alecthomas/kong v1.2.1
github.com/aws/aws-sdk-go v1.55.5
github.com/mattn/go-colorable v0.1.13
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.33.0
github.com/stretchr/testify v1.9.0
google.golang.org/api v0.203.0
k8s.io/client-go v0.29.1
)

require (
cloud.google.com/go/auth v0.9.9 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.4 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.14.0 // indirect
github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect
github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang-jwt/jwt/v5 v5.2.1 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/s2a-go v0.1.8 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/gax-go/v2 v2.13.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.33.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect
go.opentelemetry.io/otel v1.29.0 // indirect
go.opentelemetry.io/otel/metric v1.29.0 // indirect
go.opentelemetry.io/otel/trace v1.29.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.23.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.7.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/grpc v1.67.1 // indirect
google.golang.org/protobuf v1.35.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apimachinery v0.29.1 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
Expand Down
221 changes: 193 additions & 28 deletions go.sum

Large diffs are not rendered by default.

65 changes: 54 additions & 11 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,68 @@ package main

import (
"fmt"
"github.com/clouddrove/kuconf/program"
"github.com/rs/zerolog/log"
"os"

"github.com/alecthomas/kong"
"github.com/clouddrove/kuconf/program/aws"
"github.com/clouddrove/kuconf/program/azure"
"github.com/clouddrove/kuconf/program/gcp"
"github.com/rs/zerolog/log"
)

func main() {
if len(os.Args) < 2 {
fmt.Println("Please provide (aws, gcp or azure) as the first argument.")
os.Exit(1)
}

var options program.Options
platform := os.Args[1]

context, err := options.Parse(os.Args[1:])
var optionsGCP gcp.Options
var optionsAWS aws.Options
var optionsAZURE azure.Options

if err != nil {
fmt.Println(err)
os.Exit(1)
}
var ctx *kong.Context
var err error

switch platform {
case "gcp":
ctx, err = optionsGCP.Parse(os.Args[2:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}

if err := ctx.Run(&optionsGCP); err != nil {
log.Err(err).Msg("Program failed for GCP")
os.Exit(1)
}

case "aws":
ctx, err = optionsAWS.Parse(os.Args[2:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}

if err := ctx.Run(&optionsAWS); err != nil {
log.Err(err).Msg("Program failed for AWS")
os.Exit(1)
}

case "azure":
ctx, err = optionsAZURE.Parse(os.Args[2:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}

// This ends up calling options.Run()
if err := context.Run(&options); err != nil {
log.Err(err).Msg("Program failed")
if err := ctx.Run(&optionsAZURE); err != nil {
log.Err(err).Msg("Program failed for AZURE")
os.Exit(1)
}
default:
fmt.Println("Invalid cloud provider. Please choose either 'aws', 'gcp' or 'azure")
os.Exit(1)
}
}
4 changes: 2 additions & 2 deletions program/aws.go → program/aws/aws.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package program
package aws

import (
"bufio"
Expand Down Expand Up @@ -202,4 +202,4 @@ func NewSession(profile, region string, log zerolog.Logger) (*sessionInfo, error
} else {
return nil, err
}
}
}
4 changes: 2 additions & 2 deletions program/config.go → program/aws/config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package program
package aws

import (
"encoding/base64"
Expand Down Expand Up @@ -109,4 +109,4 @@ func (program *Options) WriteConfig(config *api.Config) error {
} else {
return err
}
}
}
4 changes: 2 additions & 2 deletions program/program.go → program/aws/program.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package program
package aws

import (
"fmt"
Expand Down Expand Up @@ -142,4 +142,4 @@ func isTerminal(file *os.File) bool {
} else {
return (fileInfo.Mode() & os.ModeCharDevice) != 0
}
}
}
4 changes: 2 additions & 2 deletions program/stats.go → program/aws/stats.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package program
package aws

import (
"github.com/rs/zerolog/log"
Expand All @@ -21,4 +21,4 @@ func (s *Stats) Log() {
Msg("Statistics")
}

var stats Stats
var stats Stats
4 changes: 2 additions & 2 deletions program/version.go → program/aws/version.go
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package program
package aws

import "fmt"

Expand All @@ -14,4 +14,4 @@ func (v *VersionCmd) Run(program *Options) error {
_ = program
_, _ = fmt.Println(Version)
return nil
}
}
Loading

0 comments on commit d060a72

Please sign in to comment.