@@ -88,55 +88,6 @@ manifests:
88
88
EOF
89
89
```
90
90
91
- ### Adding the framework into our types
92
-
93
- We now want to plug the framework into our types, so that our CRs will look like
94
- other addon operators.
95
-
96
- We begin by editing the api type, we add some common fields. The idea is that
97
- CommonSpec and CommonStatus form a common contract that we expect all addons to
98
- support (and we can hopefully evolve the contract with just a recompile!)
99
-
100
- Modify ` api/v1alpha1/guestbook_types.go ` to:
101
-
102
- * add an import for ` addonv1alpha1 "sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1" `
103
- * add a field ` addonv1alpha1.CommonSpec ` to the Spec object
104
- * add a field ` addonv1alpha1.CommonStatus ` to the Status object
105
- * add the accessor functions (ComponentName, CommonSpec, ..)
106
-
107
- Your ` guestbook_types.go ` file should now additionally contain:
108
-
109
- ``` go
110
- import addonv1alpha1 " sigs.k8s.io/kubebuilder-declarative-pattern/pkg/patterns/addon/pkg/apis/v1alpha1"
111
-
112
- type GuestbookSpec struct {
113
- addonv1alpha1.CommonSpec ` json:",inline"`
114
- }
115
-
116
- type GuestbookStatus struct {
117
- addonv1alpha1.CommonStatus ` json:",inline"`
118
- }
119
-
120
- var _ addonv1alpha1.CommonObject = &Guestbook{}
121
-
122
- func (c *Guestbook ) ComponentName () string {
123
- return " guestbook"
124
- }
125
-
126
- func (c *Guestbook ) CommonSpec () addonv1alpha1 .CommonSpec {
127
- return c.Spec .CommonSpec
128
- }
129
-
130
- func (c *Guestbook ) GetCommonStatus () addonv1alpha1 .CommonStatus {
131
- return c.Status .CommonStatus
132
- }
133
-
134
- func (c *Guestbook ) SetCommonStatus (s addonv1alpha1 .CommonStatus ) {
135
- c.Status .CommonStatus = s
136
- }
137
-
138
- ```
139
-
140
91
### Using the framework in the controller
141
92
142
93
We replace the controller code ` controllers/guestbook_controller.go ` :
0 commit comments