Skip to content

Commit 8284688

Browse files
author
Per Goncalves da Silva
committed
Update test-operator v2.0.0
Signed-off-by: Per Goncalves da Silva <pegoncal@redhat.com>
1 parent f5723f2 commit 8284688

19 files changed

+1539
-185
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 v1 contains API Schema definitions for the testolm v1 API group.
18+
// +kubebuilder:object:generate=false
19+
// +groupName=testolm.operatorframework.io
20+
package v1
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "testolm.operatorframework.io", Version: "v1"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 v1
18+
19+
import (
20+
"log"
21+
22+
"sigs.k8s.io/controller-runtime/pkg/conversion"
23+
24+
testolmv2 "github.com/operator-framework/operator-controller/testdata/images/bundles/test-operator/v2.0.0/api/v2"
25+
)
26+
27+
// ConvertTo converts this TestOperator (v1) to the Hub version (v2).
28+
func (src *TestOperator) ConvertTo(dstRaw conversion.Hub) error {
29+
dst := dstRaw.(*testolmv2.TestOperator)
30+
log.Printf("ConvertTo: Converting TestOperator from Spoke version v1 to Hub version v2;"+
31+
"source: %s/%s, target: %s/%s", src.Namespace, src.Name, dst.Namespace, dst.Name)
32+
dst.ObjectMeta = src.ObjectMeta
33+
dst.Spec.EchoMessage = src.Spec.Message
34+
log.Printf("ConvertedTo: %s/%s", dst.Namespace, dst.Name)
35+
return nil
36+
}
37+
38+
// ConvertFrom converts the Hub version (v2) to this TestOperator (v1).
39+
func (dst *TestOperator) ConvertFrom(srcRaw conversion.Hub) error {
40+
src := srcRaw.(*testolmv2.TestOperator)
41+
log.Printf("ConvertFrom: Converting TestOperator from Hub version v2 to Spoke version v1;"+
42+
"source: %s/%s, target: %s/%s", src.Namespace, src.Name, dst.Namespace, dst.Name)
43+
dst.ObjectMeta = src.ObjectMeta
44+
dst.Spec.Message = src.Spec.EchoMessage
45+
log.Printf("ConvertedTo: %s/%s", dst.Namespace, dst.Name)
46+
return nil
47+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 v1
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// TestOperatorSpec defines the desired state of TestOperator.
24+
type TestOperatorSpec struct {
25+
// +optional
26+
Message string `json:"message,omitempty"`
27+
}
28+
29+
// TestOperatorStatus defines the observed state of TestOperator.
30+
type TestOperatorStatus struct {
31+
Echo string `json:"echo,omitempty"`
32+
}
33+
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:subresource:status
36+
37+
// TestOperator is the Schema for the testoperators API.
38+
type TestOperator struct {
39+
metav1.TypeMeta `json:",inline"`
40+
metav1.ObjectMeta `json:"metadata,omitempty"`
41+
42+
Spec TestOperatorSpec `json:"spec,omitempty"`
43+
Status TestOperatorStatus `json:"status,omitempty"`
44+
}
45+
46+
// +kubebuilder:object:root=true
47+
48+
// TestOperatorList contains a list of TestOperator.
49+
type TestOperatorList struct {
50+
metav1.TypeMeta `json:",inline"`
51+
metav1.ListMeta `json:"metadata,omitempty"`
52+
Items []TestOperator `json:"items"`
53+
}
54+
55+
func init() {
56+
SchemeBuilder.Register(&TestOperator{}, &TestOperatorList{})
57+
}

testdata/images/bundles/test-operator/v2.0.0/api/v1/zz_generated.deepcopy.go

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 v2 contains API Schema definitions for the testolm v2 API group.
18+
// +kubebuilder:object:generate=false
19+
// +groupName=testolm.operatorframework.io
20+
package v2
21+
22+
import (
23+
"k8s.io/apimachinery/pkg/runtime/schema"
24+
"sigs.k8s.io/controller-runtime/pkg/scheme"
25+
)
26+
27+
var (
28+
// GroupVersion is group version used to register these objects.
29+
GroupVersion = schema.GroupVersion{Group: "testolm.operatorframework.io", Version: "v2"}
30+
31+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
32+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
33+
34+
// AddToScheme adds the types in this group-version to the given scheme.
35+
AddToScheme = SchemeBuilder.AddToScheme
36+
)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 v2
18+
19+
// Hub marks this type as a conversion hub.
20+
func (*TestOperator) Hub() {}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 v2
18+
19+
import (
20+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21+
)
22+
23+
// TestOperatorSpec defines the desired state of TestOperator.
24+
type TestOperatorSpec struct {
25+
// +optional
26+
EchoMessage string `json:"echoMessage,omitempty"`
27+
}
28+
29+
// TestOperatorStatus defines the observed state of TestOperator.
30+
type TestOperatorStatus struct {
31+
Echo string `json:"echo,omitempty"`
32+
}
33+
34+
// +kubebuilder:object:root=true
35+
// +kubebuilder:storageversion
36+
// +kubebuilder:conversion:hub
37+
// +kubebuilder:subresource:status
38+
39+
// TestOperator is the Schema for the testoperators API.
40+
type TestOperator struct {
41+
metav1.TypeMeta `json:",inline"`
42+
metav1.ObjectMeta `json:"metadata,omitempty"`
43+
44+
Spec TestOperatorSpec `json:"spec,omitempty"`
45+
Status TestOperatorStatus `json:"status,omitempty"`
46+
}
47+
48+
// +kubebuilder:object:root=true
49+
50+
// TestOperatorList contains a list of TestOperator.
51+
type TestOperatorList struct {
52+
metav1.TypeMeta `json:",inline"`
53+
metav1.ListMeta `json:"metadata,omitempty"`
54+
Items []TestOperator `json:"items"`
55+
}
56+
57+
func init() {
58+
SchemeBuilder.Register(&TestOperator{}, &TestOperatorList{})
59+
}

0 commit comments

Comments
 (0)