This commit is contained in:
ston1th 2020-10-31 17:02:54 +01:00
commit 8bab0f687a

View file

@ -13,10 +13,7 @@ limitations under the License.
package pvecloud package pvecloud
import ( import (
"fmt"
"io" "io"
"os"
"strconv"
pve "git.giftfish.de/ston1th/pve-go" pve "git.giftfish.de/ston1th/pve-go"
cloudprovider "k8s.io/cloud-provider" cloudprovider "k8s.io/cloud-provider"
@ -37,31 +34,17 @@ type cloud struct {
} }
func newCloud(_ io.Reader) (cloudprovider.Interface, error) { func newCloud(_ io.Reader) (cloudprovider.Interface, error) {
api := os.Getenv("PVE_API") opts, err := pve.ClientOptionsFromEnv()
if api == "" { if err != nil {
return nil, fmt.Errorf("missing required env PVE_API") 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(opts...)
client := pve.NewClient(
pve.WithEndpoint(api),
pve.WithCredentials(user, pass),
pve.WithInsecureClient(insecure),
//pvego.WithDebugWriter(os.Stderr),
)
return &cloud{ return &cloud{
client: client, client: client,
instances: newInstances(client), instances: newInstances(client),
instancesV2: newInstancesV2(client),
//zones: newZones(client, nodeName), //zones: newZones(client, nodeName),
//routes: nil, //routes: nil,
//network: network, //network: network,