Skip to content

Commit

Permalink
Add velero pkg and backup resource (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
trewest authored Mar 26, 2024
1 parent 8e01f04 commit 8f863fc
Show file tree
Hide file tree
Showing 133 changed files with 14,819 additions and 1,143 deletions.
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ linters-settings:
- "github.com/stretchr/testify"
- $gostd
- "github.com/stretchr/testify"
- "github.com/vmware-tanzu/velero"
revive:
rules:
- name: indent-error-flow
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ require (
github.com/openshift/assisted-service/api v0.0.0
github.com/openshift/assisted-service/models v0.0.0
github.com/stretchr/testify v1.9.0
github.com/vmware-tanzu/velero v1.12.1
)

require (
Expand Down Expand Up @@ -178,7 +179,7 @@ require (
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
google.golang.org/grpc v1.60.1 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -204,6 +205,7 @@ replace (
github.com/openshift/assisted-service/api => github.com/openshift/assisted-service/api v0.0.0-20240222220008-d60e80f8658c // release-4.15
github.com/openshift/assisted-service/models => github.com/openshift/assisted-service/models v0.0.0-20240222220008-d60e80f8658c // release-4.15
github.com/openshift/client-go => github.com/openshift/client-go v0.0.1
github.com/vmware-tanzu/velero => github.com/openshift/velero v0.10.2-0.20240320163538-8c404681b283
k8s.io/api => k8s.io/api v0.28.7
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.28.7
k8s.io/apimachinery => k8s.io/apimachinery v0.28.7
Expand Down
5 changes: 4 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,8 @@ github.com/openshift/ptp-operator v0.0.0-20231220185604-29113b41981b h1:cLxjnAH6
github.com/openshift/ptp-operator v0.0.0-20231220185604-29113b41981b/go.mod h1:JGaq44/mJ1zdu/MQXsdK9pKiNYHjuf0sK9MNOO/Mi+Y=
github.com/openshift/sriov-network-operator v0.0.0-20240228013256-b13485442721 h1:spumDS0UNcS0WuVohCrUnt3AeKTU9Z4+4s79HfIqGyU=
github.com/openshift/sriov-network-operator v0.0.0-20240228013256-b13485442721/go.mod h1:xptXDhHKkyKybUAfZlGwkjTBWCd/XUAlWMUARO8KQ48=
github.com/openshift/velero v0.10.2-0.20240320163538-8c404681b283 h1:5uzkYcNDT3MHrwRjM95KKqs8595vaofgT9onuadw6BQ=
github.com/openshift/velero v0.10.2-0.20240320163538-8c404681b283/go.mod h1:vCUH2JUZplVra0y2sBH456Q1Qq+bWT8jdcjgLX3Pg70=
github.com/operator-framework/api v0.22.0 h1:UZSn+iaQih4rCReezOnWTTJkMyawwV5iLnIItaOzytY=
github.com/operator-framework/api v0.22.0/go.mod h1:p/7YDbr+n4fmESfZ47yLAV1SvkfE6NU2aX8KhcfI0GA=
github.com/operator-framework/operator-lifecycle-manager v0.27.1-0.20240301195430-1d12f8f4de16 h1:XMoc0FpwjVNoKIKNRDyqsOiWClAI5QUuHAJ5BI7pSy0=
Expand Down Expand Up @@ -864,8 +866,9 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
19 changes: 19 additions & 0 deletions pkg/clients/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ import (
nfdv1 "github.com/openshift/cluster-nfd-operator/api/v1"
lsoV1alpha1 "github.com/openshift/local-storage-operator/api/v1alpha1"
mcmV1Beta1 "github.com/rh-ecosystem-edge/kernel-module-management/api-hub/v1beta1"
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
veleroClient "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
veleroFakeClient "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/fake"
veleroV1Client "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned/typed/velero/v1"
policiesv1beta1 "open-cluster-management.io/governance-policy-propagator/api/v1beta1"
placementrulev1 "open-cluster-management.io/multicloud-operators-subscription/pkg/apis/apps/placementrule/v1"
)
Expand Down Expand Up @@ -106,9 +110,13 @@ type Settings struct {
LocalVolumeInterface lsoV1alpha1.LocalVolumeSet
machinev1beta1client.MachineV1beta1Interface
storageV1Client.StorageV1Interface
VeleroClient veleroClient.Interface
veleroV1Client.VeleroV1Interface
}

// New returns a *Settings with the given kubeconfig.
//
//nolint:funlen
func New(kubeconfig string) *Settings {
var (
config *rest.Config
Expand Down Expand Up @@ -153,6 +161,8 @@ func New(kubeconfig string) *Settings {
clientSet.K8sCniCncfIoV1beta1Interface = multinetpolicyclientv1.NewForConfigOrDie(config)
clientSet.StorageV1Interface = storageV1Client.NewForConfigOrDie(config)
clientSet.K8sClient = kubernetes.NewForConfigOrDie(config)
clientSet.VeleroClient = veleroClient.NewForConfigOrDie(config)
clientSet.VeleroV1Interface = veleroV1Client.NewForConfigOrDie(config)
clientSet.Config = config

crScheme := runtime.NewScheme()
Expand Down Expand Up @@ -323,6 +333,8 @@ func GetTestClients(k8sMockObjects []runtime.Object) *Settings {

var genericClientObjects []runtime.Object

var veleroClientObjects []runtime.Object

//nolint:varnamelen
for _, v := range k8sMockObjects {
// Based on what type of object is, populate certain object slices
Expand Down Expand Up @@ -365,6 +377,9 @@ func GetTestClients(k8sMockObjects []runtime.Object) *Settings {
// Generic Client Objects
case *routev1.Route:
genericClientObjects = append(genericClientObjects, v)
// Velero Client Objects
case *velerov1.Backup:
veleroClientObjects = append(veleroClientObjects, v)
}
}

Expand All @@ -375,6 +390,10 @@ func GetTestClients(k8sMockObjects []runtime.Object) *Settings {
clientSet.NetworkingV1Interface = clientSet.K8sClient.NetworkingV1()
clientSet.RbacV1Interface = clientSet.K8sClient.RbacV1()

// Assign the fake velero clientset to the clientSet
clientSet.VeleroClient = veleroFakeClient.NewSimpleClientset(veleroClientObjects...)
clientSet.VeleroV1Interface = clientSet.VeleroClient.VeleroV1()

// Update the generic client with schemes of generic resources
fakeClientScheme := runtime.NewScheme()

Expand Down
Loading

0 comments on commit 8f863fc

Please sign in to comment.