|
| 1 | +/* |
| 2 | +Copyright 2025. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package support |
| 18 | + |
| 19 | +import ( |
| 20 | + . "github.com/onsi/gomega" |
| 21 | + |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" |
| 24 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 25 | +) |
| 26 | + |
| 27 | +const ( |
| 28 | + jobsetGroup = "jobset.x-k8s.io" |
| 29 | + jobsetVersion = "v1alpha2" |
| 30 | +) |
| 31 | + |
| 32 | +var jobsetOperatorGVR = schema.GroupVersionResource{ |
| 33 | + Group: jobsetGroup, |
| 34 | + Version: jobsetVersion, |
| 35 | + Resource: "jobsets", |
| 36 | +} |
| 37 | + |
| 38 | +func GetSingleJobSet(test Test, namespace string) (*unstructured.Unstructured, error) { |
| 39 | + test.T().Helper() |
| 40 | + |
| 41 | + jobsets, err := test.Client().Dynamic().Resource(jobsetOperatorGVR).Namespace(namespace).List( |
| 42 | + test.Ctx(), metav1.ListOptions{}) |
| 43 | + if err != nil { |
| 44 | + return nil, err |
| 45 | + } |
| 46 | + |
| 47 | + test.Expect(jobsets.Items).To(HaveLen(1), "Expected exactly one JobSet in namespace") |
| 48 | + return &jobsets.Items[0], nil |
| 49 | +} |
0 commit comments