forked from openshift/velero
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Consolidate api clients for e2e tests (vmware-tanzu#3764)
* Consolidate api clients * Adress Nolan reviews * Adding back output warning for consistency * Remove unnecessary documentation * Address Bridget's reviews * Update go.sum files Signed-off-by: Carlisia <carlisia@grokkingtech.io> Co-authored-by: Bridget McErlean <bmcerlean@vmware.com>
- Loading branch information
Showing
14 changed files
with
210 additions
and
148 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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,79 @@ | ||
/* | ||
Copyright the Velero contributors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package e2e | ||
|
||
import ( | ||
"k8s.io/client-go/kubernetes" | ||
kbclient "sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/vmware-tanzu/velero/pkg/client" | ||
) | ||
|
||
// testClient contains different API clients that are in use throughout | ||
// the e2e tests. | ||
|
||
type testClient struct { | ||
kubebuilder kbclient.Client | ||
|
||
// clientGo returns a client-go API client. | ||
// | ||
// Deprecated, TODO(2.0): presuming all controllers and resources are converted to the | ||
// controller runtime framework by v2.0, it is the intent to remove all | ||
// client-go API clients. Please use the controller runtime to make API calls for tests. | ||
clientGo kubernetes.Interface | ||
|
||
// dynamicFactory returns a client-go API client for retrieving dynamic clients | ||
// for GroupVersionResources and GroupVersionKinds. | ||
// | ||
// Deprecated, TODO(2.0): presuming all controllers and resources are converted to the | ||
// controller runtime framework by v2.0, it is the intent to remove all | ||
// client-go API clients. Please use the controller runtime to make API calls for tests. | ||
dynamicFactory client.DynamicFactory | ||
} | ||
|
||
// newTestClient returns a set of ready-to-use API clients. | ||
func newTestClient() (testClient, error) { | ||
config, err := client.LoadConfig() | ||
if err != nil { | ||
return testClient{}, err | ||
} | ||
|
||
f := client.NewFactory("e2e", config) | ||
|
||
clientGo, err := f.KubeClient() | ||
if err != nil { | ||
return testClient{}, err | ||
} | ||
|
||
kb, err := f.KubebuilderClient() | ||
if err != nil { | ||
return testClient{}, err | ||
} | ||
|
||
dynamicClient, err := f.DynamicClient() | ||
if err != nil { | ||
return testClient{}, err | ||
} | ||
|
||
factory := client.NewDynamicFactory(dynamicClient) | ||
|
||
return testClient{ | ||
kubebuilder: kb, | ||
clientGo: clientGo, | ||
dynamicFactory: factory, | ||
}, nil | ||
} |
Oops, something went wrong.