Skip to content

Commit

Permalink
chore: remove castai provider (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
saumas authored Mar 31, 2023
1 parent 70c895f commit 4300fda
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 86 deletions.
15 changes: 0 additions & 15 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ type Config struct {
Kubeconfig string `mapstructure:"kubeconfig"`

Provider string `mapstructure:"provider"`
CASTAI *CASTAI `mapstructure:"castai"`
EKS *EKS `mapstructure:"eks"`
GKE *GKE `mapstructure:"gke"`
KOPS *KOPS `mapstructure:"kops"`
Expand All @@ -40,11 +39,6 @@ type API struct {
URL string `mapstructure:"url"`
}

type CASTAI struct {
ClusterID string `mapstructure:"cluster_id"`
OrganizationID string `mapstructure:"organization_id"`
}

type EKS struct {
AccountID string `mapstructure:"account_id"`
Region string `mapstructure:"region"`
Expand Down Expand Up @@ -147,15 +141,6 @@ func Get() Config {
cfg.API.URL = fmt.Sprintf("https://%s", cfg.API.URL)
}

if cfg.CASTAI != nil {
if cfg.CASTAI.ClusterID == "" {
requiredWhenDiscoveryDisabled("CASTAI_CLUSTER_ID")
}
if cfg.CASTAI.OrganizationID == "" {
requiredWhenDiscoveryDisabled("CASTAI_ORGANIZATION_ID")
}
}

if cfg.EKS != nil {
if cfg.EKS.AccountID == "" {
requiredWhenDiscoveryDisabled("EKS_ACCOUNT_ID")
Expand Down
49 changes: 0 additions & 49 deletions internal/services/providers/castai/castai.go

This file was deleted.

5 changes: 0 additions & 5 deletions internal/services/providers/providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/sirupsen/logrus"

"castai-agent/internal/config"
"castai-agent/internal/services/providers/castai"
"castai-agent/internal/services/providers/eks"
"castai-agent/internal/services/providers/gke"
"castai-agent/internal/services/providers/kops"
Expand All @@ -23,10 +22,6 @@ import (
func GetProvider(ctx context.Context, log logrus.FieldLogger, discoveryService discovery.Service, dyno dynamic.Interface) (types.Provider, error) {
cfg := config.Get()

if cfg.Provider == castai.Name || cfg.CASTAI != nil {
return castai.New(ctx, log.WithField("provider", castai.Name))
}

if cfg.Provider == eks.Name || cfg.EKS != nil {
return eks.New(ctx, log.WithField("provider", eks.Name))
}
Expand Down
17 changes: 0 additions & 17 deletions internal/services/providers/providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,13 @@ import (
"github.com/stretchr/testify/require"

"castai-agent/internal/config"
"castai-agent/internal/services/providers/castai"
"castai-agent/internal/services/providers/eks"
"castai-agent/internal/services/providers/gke"
"castai-agent/internal/services/providers/kops"
"castai-agent/internal/services/providers/openshift"
)

func TestGetProvider(t *testing.T) {
t.Run("should return castai", func(t *testing.T) {
r := require.New(t)

t.Cleanup(config.Reset)
t.Cleanup(os.Clearenv)

r.NoError(os.Setenv("API_KEY", "api-key"))
r.NoError(os.Setenv("API_URL", "test"))
r.NoError(os.Setenv("PROVIDER", "castai"))

got, err := GetProvider(context.Background(), logrus.New(), nil, nil)

r.NoError(err)
r.IsType(&castai.Provider{}, got)
})

t.Run("should return eks", func(t *testing.T) {
r := require.New(t)

Expand Down

0 comments on commit 4300fda

Please sign in to comment.