Skip to content

Commit 6064540

Browse files
committed
reconcile OCL API from v1alpha1 -> v1
1 parent 5f8f38a commit 6064540

43 files changed

Lines changed: 599 additions & 711 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎cmd/machine-config-controller/start.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
236236
ctx.InformerFactory.Machineconfiguration().V1().MachineConfigPools(),
237237
ctx.KubeInformerFactory.Core().V1().Nodes(),
238238
ctx.KubeInformerFactory.Core().V1().Pods(),
239-
ctx.TechPreviewInformerFactory.Machineconfiguration().V1alpha1().MachineOSConfigs(),
239+
ctx.InformerFactory.Machineconfiguration().V1().MachineOSConfigs(),
240240
ctx.ConfigInformerFactory.Config().V1().Schedulers(),
241241
ctx.ClientBuilder.KubeClientOrDie("node-update-controller"),
242242
ctx.ClientBuilder.MachineConfigClientOrDie("node-update-controller"),

‎pkg/apihelpers/machineosbuild.go‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package apihelpers
22

33
import (
4-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
4+
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
55

66
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
77
)
@@ -17,13 +17,13 @@ func NewMachineOSBuildCondition(condType string, status metav1.ConditionStatus,
1717
}
1818
}
1919

20-
func GetMachineOSBuildCondition(status mcfgv1alpha1.MachineOSBuildStatus, condType mcfgv1alpha1.BuildProgress) *metav1.Condition {
20+
func GetMachineOSBuildCondition(status mcfgv1.MachineOSBuildStatus, condType mcfgv1.BuildProgress) *metav1.Condition {
2121
// in case of sync errors, return the last condition that matches, not the first
2222
// this exists for redundancy and potential race conditions.
2323
var LatestState *metav1.Condition
2424
for i := range status.Conditions {
2525
c := status.Conditions[i]
26-
if mcfgv1alpha1.BuildProgress(c.Type) == condType {
26+
if mcfgv1.BuildProgress(c.Type) == condType {
2727
LatestState = &c
2828
}
2929
}
@@ -32,8 +32,8 @@ func GetMachineOSBuildCondition(status mcfgv1alpha1.MachineOSBuildStatus, condTy
3232

3333
// SetMachineOSBuildCondition updates the MachineOSBuild to include the provided condition. If the condition that
3434
// we are about to add already exists and has the same status and reason then we are not going to update.
35-
func SetMachineOSBuildCondition(status *mcfgv1alpha1.MachineOSBuildStatus, condition metav1.Condition) {
36-
currentCond := GetMachineOSBuildCondition(*status, mcfgv1alpha1.BuildProgress(condition.Type))
35+
func SetMachineOSBuildCondition(status *mcfgv1.MachineOSBuildStatus, condition metav1.Condition) {
36+
currentCond := GetMachineOSBuildCondition(*status, mcfgv1.BuildProgress(condition.Type))
3737
if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason && currentCond.Message == condition.Message {
3838
return
3939
}
@@ -43,36 +43,36 @@ func SetMachineOSBuildCondition(status *mcfgv1alpha1.MachineOSBuildStatus, condi
4343
}
4444

4545
// this may not be necessary
46-
newConditions := filterOutMachineOSBuildCondition(status.Conditions, mcfgv1alpha1.BuildProgress(condition.Type))
46+
newConditions := filterOutMachineOSBuildCondition(status.Conditions, mcfgv1.BuildProgress(condition.Type))
4747
newConditions = append(newConditions, condition)
4848
status.Conditions = newConditions
4949
}
5050

5151
// RemoveMachineOSBuildCondition removes the MachineOSBuild condition with the provided type.
52-
func RemoveMachineOSBuildCondition(status *mcfgv1alpha1.MachineOSBuildStatus, condType mcfgv1alpha1.BuildProgress) {
52+
func RemoveMachineOSBuildCondition(status *mcfgv1.MachineOSBuildStatus, condType mcfgv1.BuildProgress) {
5353
status.Conditions = filterOutMachineOSBuildCondition(status.Conditions, condType)
5454
}
5555

5656
// filterOutMachineOSBuildCondition returns a new slice of MachineOSBuild conditions without conditions with the provided type.
57-
func filterOutMachineOSBuildCondition(conditions []metav1.Condition, condType mcfgv1alpha1.BuildProgress) []metav1.Condition {
57+
func filterOutMachineOSBuildCondition(conditions []metav1.Condition, condType mcfgv1.BuildProgress) []metav1.Condition {
5858
var newConditions []metav1.Condition
5959
for _, c := range conditions {
60-
if mcfgv1alpha1.BuildProgress(c.Type) == condType {
60+
if mcfgv1.BuildProgress(c.Type) == condType {
6161
continue
6262
}
6363
newConditions = append(newConditions, c)
6464
}
6565
return newConditions
6666
}
6767

68-
func IsMachineOSBuildConditionTrue(conditions []metav1.Condition, conditionType mcfgv1alpha1.BuildProgress) bool {
68+
func IsMachineOSBuildConditionTrue(conditions []metav1.Condition, conditionType mcfgv1.BuildProgress) bool {
6969
return IsMachineOSBuildConditionPresentAndEqual(conditions, conditionType, metav1.ConditionTrue)
7070
}
7171

7272
// IsMachineOSBuildConditionPresentAndEqual returns true when conditionType is present and equal to status.
73-
func IsMachineOSBuildConditionPresentAndEqual(conditions []metav1.Condition, conditionType mcfgv1alpha1.BuildProgress, status metav1.ConditionStatus) bool {
73+
func IsMachineOSBuildConditionPresentAndEqual(conditions []metav1.Condition, conditionType mcfgv1.BuildProgress, status metav1.ConditionStatus) bool {
7474
for _, condition := range conditions {
75-
if mcfgv1alpha1.BuildProgress(condition.Type) == conditionType {
75+
if mcfgv1.BuildProgress(condition.Type) == conditionType {
7676
return condition.Status == status
7777
}
7878
}

‎pkg/apihelpers/machineosconfig.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package apihelpers
22

33
import (
4-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
4+
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
55

66
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
77
)
@@ -17,7 +17,7 @@ func NewMachineOSConfigCondition(condType string, status metav1.ConditionStatus,
1717
}
1818
}
1919

20-
func GetMachineOSConfigCondition(status mcfgv1alpha1.MachineOSConfigStatus, condType string) *metav1.Condition {
20+
func GetMachineOSConfigCondition(status mcfgv1.MachineOSConfigStatus, condType string) *metav1.Condition {
2121
// in case of sync errors, return the last condition that matches, not the first
2222
// this exists for redundancy and potential race conditions.
2323
var LatestState *metav1.Condition
@@ -32,7 +32,7 @@ func GetMachineOSConfigCondition(status mcfgv1alpha1.MachineOSConfigStatus, cond
3232

3333
// SetMachineOSConfigCondition updates the MachineOSConfig to include the provided condition. If the condition that
3434
// we are about to add already exists and has the same status and reason then we are not going to update.
35-
func SetMachineOSConfigCondition(status *mcfgv1alpha1.MachineOSConfigStatus, condition metav1.Condition) {
35+
func SetMachineOSConfigCondition(status *mcfgv1.MachineOSConfigStatus, condition metav1.Condition) {
3636
currentCond := GetMachineOSConfigCondition(*status, condition.Type)
3737
if currentCond != nil && currentCond.Status == condition.Status && currentCond.Reason == condition.Reason && currentCond.Message == condition.Message {
3838
return
@@ -49,7 +49,7 @@ func SetMachineOSConfigCondition(status *mcfgv1alpha1.MachineOSConfigStatus, con
4949
}
5050

5151
// RemoveMachineOSConfigCondition removes the MachineOSConfig condition with the provided type.
52-
func RemoveMachineOSConfigCondition(status *mcfgv1alpha1.MachineOSConfigStatus, condType string) {
52+
func RemoveMachineOSConfigCondition(status *mcfgv1.MachineOSConfigStatus, condType string) {
5353
status.Conditions = filterOutMachineOSConfigCondition(status.Conditions, condType)
5454
}
5555

‎pkg/controller/build/buildrequest/buildrequest.go‎

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"text/template"
1010

1111
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
12-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
1312
mcfgclientset "github.com/openshift/client-go/machineconfiguration/clientset/versioned"
1413
"github.com/openshift/machine-config-operator/pkg/controller/build/constants"
1514
"github.com/openshift/machine-config-operator/pkg/controller/build/utils"
@@ -45,7 +44,7 @@ type buildRequestImpl struct {
4544
}
4645

4746
// Constructs an imageBuildRequest from the Kube API server.
48-
func NewBuildRequestFromAPI(ctx context.Context, kubeclient clientset.Interface, mcfgclient mcfgclientset.Interface, mosb *mcfgv1alpha1.MachineOSBuild, mosc *mcfgv1alpha1.MachineOSConfig) (BuildRequest, error) {
47+
func NewBuildRequestFromAPI(ctx context.Context, kubeclient clientset.Interface, mcfgclient mcfgclientset.Interface, mosb *mcfgv1.MachineOSBuild, mosc *mcfgv1.MachineOSConfig) (BuildRequest, error) {
4948
opts, err := newBuildRequestOptsFromAPI(ctx, kubeclient, mcfgclient, mosb, mosc)
5049
if err != nil {
5150
return nil, err
@@ -61,8 +60,8 @@ func newBuildRequest(opts BuildRequestOpts) BuildRequest {
6160
}
6261

6362
// only support noArch for now
64-
for _, file := range opts.MachineOSConfig.Spec.BuildInputs.Containerfile {
65-
if file.ContainerfileArch == mcfgv1alpha1.NoArch {
63+
for _, file := range opts.MachineOSConfig.Spec.Containerfile {
64+
if file.ContainerfileArch == mcfgv1.NoArch {
6665
br.userContainerfile = file.Content
6766
break
6867
}
@@ -226,20 +225,14 @@ func (br buildRequestImpl) renderContainerfile() (string, error) {
226225
// default to a value from a different location, it makes more sense for us
227226
// to implement that logic in Go as opposed to the Go template language.
228227
items := struct {
229-
MachineOSBuild *mcfgv1alpha1.MachineOSBuild
230-
MachineOSConfig *mcfgv1alpha1.MachineOSConfig
228+
MachineOSBuild *mcfgv1.MachineOSBuild
229+
MachineOSConfig *mcfgv1.MachineOSConfig
231230
UserContainerfile string
232-
ReleaseVersion string
233-
BaseOSImage string
234-
ExtensionsImage string
235231
ExtensionsPackages []string
236232
}{
237233
MachineOSBuild: br.opts.MachineOSBuild,
238234
MachineOSConfig: br.opts.MachineOSConfig,
239235
UserContainerfile: br.userContainerfile,
240-
ReleaseVersion: br.opts.getReleaseVersion(),
241-
BaseOSImage: br.opts.getBaseOSImagePullspec(),
242-
ExtensionsImage: br.opts.getExtensionsImagePullspec(),
243236
ExtensionsPackages: extPkgs,
244237
}
245238

@@ -315,7 +308,7 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
315308
},
316309
{
317310
Name: "TAG",
318-
Value: br.opts.MachineOSBuild.Spec.RenderedImagePushspec,
311+
Value: string(br.opts.MachineOSBuild.Spec.RenderedImagePushSpec),
319312
},
320313
{
321314
Name: "BASE_IMAGE_PULL_CREDS",
@@ -525,7 +518,7 @@ func (br buildRequestImpl) toBuildahPod() *corev1.Pod {
525518
// us to avoid parsing log files.
526519
Name: "wait-for-done",
527520
Command: append(command, waitScript),
528-
Image: br.opts.getBaseOSImagePullspec(),
521+
Image: br.opts.getBaseOSImagePullspec(), // QOCL: What do we replace this with?
529522
Env: env,
530523
ImagePullPolicy: corev1.PullAlways,
531524
SecurityContext: securityContext,
@@ -543,7 +536,7 @@ func (br buildRequestImpl) getLabelsForObjectMeta() map[string]string {
543536
return map[string]string{
544537
constants.EphemeralBuildObjectLabelKey: "",
545538
constants.OnClusterLayeringLabelKey: "",
546-
constants.RenderedMachineConfigLabelKey: br.opts.MachineOSBuild.Spec.DesiredConfig.Name,
539+
constants.RenderedMachineConfigLabelKey: br.opts.MachineOSBuild.Spec.MachineConfig.Name,
547540
constants.TargetMachineConfigPoolLabelKey: br.opts.MachineOSConfig.Spec.MachineConfigPool.Name,
548541
constants.MachineOSConfigNameLabelKey: br.opts.MachineOSConfig.Name,
549542
constants.MachineOSBuildNameLabelKey: br.opts.MachineOSBuild.Name,

‎pkg/controller/build/buildrequest/buildrequest_test.go‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"testing"
66

77
mcfgv1 "github.com/openshift/api/machineconfiguration/v1"
8-
mcfgv1alpha1 "github.com/openshift/api/machineconfiguration/v1alpha1"
98
"github.com/openshift/machine-config-operator/pkg/controller/build/constants"
109
"github.com/openshift/machine-config-operator/pkg/controller/build/fixtures"
1110
"github.com/openshift/machine-config-operator/pkg/controller/build/utils"
@@ -134,9 +133,6 @@ func TestBuildRequest(t *testing.T) {
134133
name: "MachineOSConfig-provided options override OSImageURLConfig defaults",
135134
optsFunc: func() BuildRequestOpts {
136135
opts := getBuildRequestOpts()
137-
opts.MachineOSConfig.Spec.BuildInputs.BaseOSImagePullspec = "base-os-image-from-machineosconfig"
138-
opts.MachineOSConfig.Spec.BuildInputs.BaseOSExtensionsImagePullspec = "base-ext-image-from-machineosconfig"
139-
opts.MachineOSConfig.Spec.BuildInputs.ReleaseVersion = "release-version-from-machineosconfig"
140136
opts.MachineConfig.Spec.Extensions = []string{"usbguard"}
141137
return opts
142138
},
@@ -169,7 +165,7 @@ func TestBuildRequest(t *testing.T) {
169165
if len(testCase.expectedContainerfileContents) == 0 {
170166
testCase.expectedContainerfileContents = append(expectedContents(), []string{
171167
machineConfigJSONFilename,
172-
opts.MachineOSConfig.Spec.BuildInputs.Containerfile[0].Content,
168+
opts.MachineOSConfig.Spec.Containerfile[0].Content,
173169
}...)
174170
}
175171

@@ -321,7 +317,7 @@ RUN rpm-ostree install && \
321317

322318
layeredObjects := fixtures.NewObjectBuildersForTest("worker")
323319
layeredObjects.MachineOSConfigBuilder.
324-
WithContainerfile(mcfgv1alpha1.NoArch, containerfileContents)
320+
WithContainerfile(mcfgv1.NoArch, containerfileContents)
325321

326322
layeredObjects.MachineOSBuildBuilder.
327323
// Note: This is set statically so that the test suite is less brittle.

0 commit comments

Comments
 (0)