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
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,