From 8bab0f687af868f7537db6f38e82ae7b4ef023ae Mon Sep 17 00:00:00 2001 From: ston1th Date: Sat, 31 Oct 2020 17:02:54 +0100 Subject: [PATCH] bugfix --- pkg/pvecloud/cloud.go | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/pkg/pvecloud/cloud.go b/pkg/pvecloud/cloud.go index 144066e..1557eb7 100644 --- a/pkg/pvecloud/cloud.go +++ b/pkg/pvecloud/cloud.go @@ -13,10 +13,7 @@ limitations under the License. package pvecloud import ( - "fmt" "io" - "os" - "strconv" pve "git.giftfish.de/ston1th/pve-go" cloudprovider "k8s.io/cloud-provider" @@ -37,31 +34,17 @@ type cloud struct { } func newCloud(_ io.Reader) (cloudprovider.Interface, error) { - api := os.Getenv("PVE_API") - if api == "" { - return nil, fmt.Errorf("missing required env PVE_API") + opts, err := pve.ClientOptionsFromEnv() + if err != nil { + return nil, err } - user := os.Getenv("PVE_USER") - if user == "" { - return nil, fmt.Errorf("missing required env PVE_USER") - } - pass := os.Getenv("PVE_PASSWORD") - if pass == "" { - return nil, fmt.Errorf("missing required env PVE_PASSWORD") - } - //node := os.Getenv("NODE_NAME") - insecure, _ := strconv.ParseBool(os.Getenv("PVE_INSECURE")) - client := pve.NewClient( - pve.WithEndpoint(api), - pve.WithCredentials(user, pass), - pve.WithInsecureClient(insecure), - //pvego.WithDebugWriter(os.Stderr), - ) + client := pve.NewClient(opts...) return &cloud{ - client: client, - instances: newInstances(client), + client: client, + instances: newInstances(client), + instancesV2: newInstancesV2(client), //zones: newZones(client, nodeName), //routes: nil, //network: network,