csr rewrite
This commit is contained in:
parent
211b89236e
commit
954b5c0d61
8 changed files with 430 additions and 280 deletions
|
|
@ -13,7 +13,10 @@ limitations under the License.
|
|||
package pvecloud
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
pve "git.giftfish.de/ston1th/pve-go"
|
||||
cloudprovider "k8s.io/cloud-provider"
|
||||
|
|
@ -21,34 +24,49 @@ import (
|
|||
|
||||
const (
|
||||
providerName = pve.PVEScheme
|
||||
scheme = providerName + "://"
|
||||
scheme = pve.PVESchemeURL
|
||||
)
|
||||
|
||||
type cloud struct {
|
||||
client *pve.Client
|
||||
instances cloudprovider.Instances
|
||||
instancesV2 cloudprovider.InstancesV2
|
||||
//zones cloudprovider.Zones
|
||||
//routes cloudprovider.Routes
|
||||
//network string
|
||||
}
|
||||
|
||||
func newCloud(_ io.Reader) (cloudprovider.Interface, error) {
|
||||
opts, err := pve.ClientOptionsFromEnv()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func newCloud(config io.Reader) (c cloudprovider.Interface, err error) {
|
||||
var opts []pve.ClientOption
|
||||
buf, _ := ioutil.ReadAll(config)
|
||||
if len(buf) != 0 {
|
||||
var cfg pve.Config
|
||||
err = json.Unmarshal(buf, &cfg)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
opts, err = pve.ClientOptionsFromConfig(cfg)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
opts, err = pve.ClientOptionsFromEnv()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
if len(opts) == 0 {
|
||||
err = errors.New("missing pve config")
|
||||
return
|
||||
}
|
||||
|
||||
client := pve.NewClient(opts...)
|
||||
|
||||
return &cloud{
|
||||
c = &cloud{
|
||||
client: client,
|
||||
instances: newInstances(client),
|
||||
instancesV2: newInstancesV2(client),
|
||||
//zones: newZones(client, nodeName),
|
||||
//routes: nil,
|
||||
//network: network,
|
||||
}, nil
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, stop <-chan struct{}) {
|
||||
|
|
@ -63,7 +81,6 @@ func (c *cloud) InstancesV2() (cloudprovider.InstancesV2, bool) {
|
|||
}
|
||||
|
||||
func (c *cloud) Zones() (cloudprovider.Zones, bool) {
|
||||
//return c.zones, true
|
||||
return nil, false
|
||||
}
|
||||
|
||||
|
|
@ -77,17 +94,6 @@ func (c *cloud) Clusters() (cloudprovider.Clusters, bool) {
|
|||
|
||||
func (c *cloud) Routes() (cloudprovider.Routes, bool) {
|
||||
return nil, false
|
||||
/*
|
||||
if len(c.network) > 0 {
|
||||
r, err := newRoutes(c.client, c.network)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
}
|
||||
return r, true
|
||||
}
|
||||
return nil, false // If no network is configured, disable the routes part
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
func (c *cloud) ProviderName() string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue