Skip to content

Commit

Permalink
feat: ovh load config
Browse files Browse the repository at this point in the history
Signed-off-by: Azanul <azanulhaque@gmail.com>
  • Loading branch information
Azanul committed Oct 30, 2023
1 parent 32c03ca commit 33da40a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
32 changes: 32 additions & 0 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/linode/linodego"
"github.com/mongodb-forks/digest"
"github.com/oracle/oci-go-sdk/common"
"github.com/ovh/go-ovh/ovh"
"github.com/scaleway/scaleway-sdk-go/scw"
"github.com/tailwarden/komiser/models"
. "github.com/tailwarden/komiser/models"
Expand Down Expand Up @@ -455,5 +456,36 @@ func Load(configPath string, telemetry bool, analytics utils.Analytics, db *bun.
}
}

if len(config.OVH) > 0 {
for _, account := range config.OVH {
cloudAccount := models.Account{
Provider: "OVH",
Name: account.Name,
Credentials: map[string]string{
"endpoint": account.Endpoint,
"applicationKey": account.ApplicationKey,
"applicationSecret": account.ApplicationSecret,
"consumerKey": account.ConsumerKey,
},
}
accounts = append(accounts, cloudAccount)

client, err := ovh.NewClient(
account.Endpoint,
account.ApplicationKey,
account.ApplicationSecret,
account.ConsumerKey,
)
if err != nil {
log.Fatal(err)
}

clients = append(clients, providers.ProviderClient{
OVHClient: client,
Name: account.Name,
})
}
}

return config, clients, accounts, nil
}
9 changes: 9 additions & 0 deletions models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Config struct {
Scaleway []ScalewayConfig `toml:"scaleway"`
MongoDBAtlas []MongoDBAtlasConfig `toml:"mongodbatlas"`
GCP []GCPConfig `toml:"gcp"`
OVH []OVHConfig `toml:"ovh"`
Postgres PostgresConfig `toml:"postgres,omitempty"`
SQLite SQLiteConfig `toml:"sqlite"`
Slack SlackConfig `toml:"slack"`
Expand Down Expand Up @@ -94,6 +95,14 @@ type GCPConfig struct {
ServiceAccountKeyPath string `toml:"serviceAccountKeyPath"`
}

type OVHConfig struct {
Name string `toml:"name"`
Endpoint string `toml:"endpoint"`
ApplicationKey string `toml:"application_key"`
ApplicationSecret string `toml:"application_secret"`
ConsumerKey string `toml:"consumer_key"`
}

type SlackConfig struct {
Webhook string `toml:"webhook"`
Reporting bool `toml:"reporting"`
Expand Down

0 comments on commit 33da40a

Please sign in to comment.