-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Xudong Liu <[email protected]>
- Loading branch information
1 parent
d0ef60c
commit 58e7427
Showing
3 changed files
with
174 additions
and
0 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
pkg/cloudprovider/vsphereparavirtual/vmoperator/client/client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package client | ||
|
||
import ( | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/client-go/dynamic" | ||
"k8s.io/client-go/rest" | ||
|
||
vmopv1alpha1 "github.com/vmware-tanzu/vm-operator-api/api/v1alpha1" | ||
) | ||
|
||
var ( | ||
VirtualMachineServiceGVR = schema.GroupVersionResource{ | ||
Group: "vmoperator.vmware.com", | ||
Version: "v1alpha1", | ||
Resource: "virtualmachineservices", | ||
} | ||
|
||
VirtualMachineGVR = schema.GroupVersionResource{ | ||
Group: "vmoperator.vmware.com", | ||
Version: "v1alpha1", | ||
Resource: "virtualmachines", | ||
} | ||
) | ||
|
||
type VmoperatorV1alpha1Interface interface { | ||
Client() *dynamic.DynamicClient | ||
VirtualMachines(namespace string) VirtualMachineInterface | ||
VirtualMachineServices(namespace string) VirtualMachineServiceInterface | ||
} | ||
|
||
type VmoperatorV1alpha1Client struct { | ||
dynamicClient *dynamic.DynamicClient | ||
} | ||
|
||
func (c *VmoperatorV1alpha1Client) VirtualMachines(namespace string) VirtualMachineInterface { | ||
return newVirtualMachines(c, namespace) | ||
} | ||
|
||
func (c *VmoperatorV1alpha1Client) VirtualMachineServices(namespace string) VirtualMachineServiceInterface { | ||
return newVirtualMachineServices(c, namespace) | ||
} | ||
|
||
func (c *VmoperatorV1alpha1Client) Client() *dynamic.DynamicClient { | ||
if c == nil { | ||
return nil | ||
} | ||
return c.dynamicClient | ||
} | ||
|
||
func NewForConfig(c *rest.Config) (*VmoperatorV1alpha1Client, error) { | ||
scheme := runtime.NewScheme() | ||
_ = vmopv1alpha1.AddToScheme(scheme) | ||
|
||
dynamicClient, err := dynamic.NewForConfig(c) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
client := &VmoperatorV1alpha1Client{ | ||
dynamicClient: dynamicClient, | ||
} | ||
return client, nil | ||
} |
58 changes: 58 additions & 0 deletions
58
pkg/cloudprovider/vsphereparavirtual/vmoperator/client/virtualmachine_client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
vmopv1alpha1 "github.com/vmware-tanzu/vm-operator-api/api/v1alpha1" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
// VirtualMachineInterface has methods to work with VirtualMachineService resources. | ||
type VirtualMachineInterface interface { | ||
Create(ctx context.Context, virtualMachine *vmopv1alpha1.VirtualMachine, opts v1.CreateOptions) (*vmopv1alpha1.VirtualMachine, error) | ||
Update(ctx context.Context, virtualMachine *vmopv1alpha1.VirtualMachine, opts v1.UpdateOptions) (*vmopv1alpha1.VirtualMachine, error) | ||
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error | ||
Get(ctx context.Context, name string, opts v1.GetOptions) (*vmopv1alpha1.VirtualMachine, error) | ||
List(ctx context.Context, opts v1.ListOptions) (*vmopv1alpha1.VirtualMachineList, error) | ||
} | ||
|
||
// virtualMachines implements VirtualMachineInterface | ||
type virtualMachines struct { | ||
client *dynamic.DynamicClient | ||
ns string | ||
} | ||
|
||
func newVirtualMachines(c *VmoperatorV1alpha1Client, namespace string) *virtualMachines { | ||
return &virtualMachines{ | ||
client: c.Client(), | ||
ns: namespace, | ||
} | ||
} | ||
|
||
func (v *virtualMachines) Create(ctx context.Context, virtualMachine *vmopv1alpha1.VirtualMachine, opts v1.CreateOptions) (*vmopv1alpha1.VirtualMachine, error) { | ||
return nil, nil | ||
} | ||
|
||
func (v *virtualMachines) Update(ctx context.Context, virtualMachine *vmopv1alpha1.VirtualMachine, opts v1.UpdateOptions) (*vmopv1alpha1.VirtualMachine, error) { | ||
return nil, nil | ||
} | ||
|
||
func (v *virtualMachines) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { | ||
return nil | ||
} | ||
|
||
func (v *virtualMachines) Get(ctx context.Context, name string, opts v1.GetOptions) (*vmopv1alpha1.VirtualMachine, error) { | ||
virtualMachine := &vmopv1alpha1.VirtualMachine{} | ||
if obj, err := v.client.Resource(VirtualMachineGVR).Namespace(v.ns).Get(ctx, name, opts); err != nil { | ||
return nil, err | ||
} else if err = runtime.DefaultUnstructuredConverter.FromUnstructured(obj.UnstructuredContent(), virtualMachine); err != nil { | ||
return nil, err | ||
} | ||
return virtualMachine, nil | ||
} | ||
|
||
func (v *virtualMachines) List(ctx context.Context, opts v1.ListOptions) (*vmopv1alpha1.VirtualMachineList, error) { | ||
return nil, nil | ||
} |
52 changes: 52 additions & 0 deletions
52
pkg/cloudprovider/vsphereparavirtual/vmoperator/client/virtualmachineservice_client.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
vmopv1alpha1 "github.com/vmware-tanzu/vm-operator-api/api/v1alpha1" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/client-go/dynamic" | ||
) | ||
|
||
// VirtualMachineServiceInterface has methods to work with VirtualMachineService resources. | ||
type VirtualMachineServiceInterface interface { | ||
Create(ctx context.Context, virtualMachineService *vmopv1alpha1.VirtualMachineService, opts v1.CreateOptions) (*vmopv1alpha1.VirtualMachineService, error) | ||
Update(ctx context.Context, virtualMachineService *vmopv1alpha1.VirtualMachineService, opts v1.UpdateOptions) (*vmopv1alpha1.VirtualMachineService, error) | ||
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error | ||
Get(ctx context.Context, name string, opts v1.GetOptions) (*vmopv1alpha1.VirtualMachineService, error) | ||
List(ctx context.Context, opts v1.ListOptions) (*vmopv1alpha1.VirtualMachineServiceList, error) | ||
} | ||
|
||
// virtualMachineServices implements VirtualMachineServiceInterface | ||
type virtualMachineServices struct { | ||
client *dynamic.DynamicClient | ||
ns string | ||
} | ||
|
||
// newVirtualMachineServices returns a VirtualMachineServices | ||
func newVirtualMachineServices(c *VmoperatorV1alpha1Client, namespace string) *virtualMachineServices { | ||
return &virtualMachineServices{ | ||
client: c.Client(), | ||
ns: namespace, | ||
} | ||
} | ||
|
||
func (v *virtualMachineServices) Create(ctx context.Context, virtualMachineService *vmopv1alpha1.VirtualMachineService, opts v1.CreateOptions) (*vmopv1alpha1.VirtualMachineService, error) { | ||
return nil, nil | ||
} | ||
|
||
func (v *virtualMachineServices) Update(ctx context.Context, virtualMachineService *vmopv1alpha1.VirtualMachineService, opts v1.UpdateOptions) (*vmopv1alpha1.VirtualMachineService, error) { | ||
return nil, nil | ||
} | ||
|
||
func (v *virtualMachineServices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { | ||
return nil | ||
} | ||
|
||
func (v *virtualMachineServices) Get(ctx context.Context, name string, opts v1.GetOptions) (*vmopv1alpha1.VirtualMachineService, error) { | ||
return nil, nil | ||
} | ||
|
||
func (v *virtualMachineServices) List(ctx context.Context, opts v1.ListOptions) (*vmopv1alpha1.VirtualMachineServiceList, error) { | ||
return nil, nil | ||
} |