some updated

This commit is contained in:
ston1th 2020-10-25 21:54:37 +01:00
commit b0e048ba9d
7 changed files with 105 additions and 34 deletions

View file

@ -19,16 +19,24 @@ import (
cloudprovider "k8s.io/cloud-provider"
)
func getServerByName(ctx context.Context, c *pve.Client, name string) (server *pve.Server, err error) {
server, err = c.Pool.FindServerByName(ctx, "", name)
func getServerRefByName(ctx context.Context, c *pve.Client, name string) (ref *pve.ServerRef, err error) {
ref, err = c.Pool.FindServerByName(ctx, "", name)
if err == pve.ErrServerNotFound {
return nil, cloudprovider.InstanceNotFound
}
return
}
func getServerByProviderID(ctx context.Context, c *pve.Client, providerID string) (server *pve.Server, err error) {
server, err = c.Server.GetByURL(ctx, providerID)
func getServerByName(ctx context.Context, c *pve.Client, name string) (srv *pve.Server, err error) {
ref, err := getServerRefByName(ctx, c, name)
if err == pve.ErrServerNotFound {
return nil, cloudprovider.InstanceNotFound
}
return c.Server.GetByRef(ctx, ref)
}
func getServerByProviderID(ctx context.Context, c *pve.Client, providerID string) (srv *pve.Server, err error) {
srv, err = c.Server.GetByURL(ctx, providerID)
if err == pve.ErrServerNotFound {
return nil, cloudprovider.InstanceNotFound
}