ovh-apikey-manager/app/app.go

37 lines
918 B
Go
Raw Permalink Normal View History

2023-06-11 19:29:56 +02:00
package app
import (
"github.com/ovh/go-ovh/ovh"
"github.com/spf13/viper"
"log"
)
type ApplicationAllResponse struct {
Applications []int
}
type Application struct {
ApplicationID int `json:"applicationId"`
ApplicationKey string `json:"applicationKey"`
Description string `json:"description"`
Name string `json:"name"`
Status string `json:"status"`
}
func GetOVHClient() *ovh.Client {
if viper.GetString("OVH_APPLICATIONKEY") == "" ||
viper.GetString("OVH_APPLICATIONSECRET") == "" ||
viper.GetString("OVH_CONSUMERKEY") == "" ||
viper.GetString("OVH_REGION") == "" {
log.Fatalln("We're missing a configuration variable in .env. Please recheck the config file.")
}
client, _ := ovh.NewClient(
viper.GetString("OVH_REGION"),
viper.GetString("OVH_APPLICATIONKEY"),
viper.GetString("OVH_APPLICATIONSECRET"),
viper.GetString("OVH_CONSUMERKEY"),
)
return client
}