Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 15 additions & 5 deletions controllers/clusteroperator_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ var _ = Describe("Component sync controller", func() {
},
Entry("Should provision AWS resources", testCase{
status: &configv1.InfrastructureStatus{
Platform: configv1.AWSPlatformType,
InfrastructureTopology: configv1.HighlyAvailableTopologyMode,
ControlPlaneTopology: configv1.HighlyAvailableTopologyMode,
Platform: configv1.AWSPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.AWSPlatformType,
},
Expand All @@ -326,7 +328,9 @@ var _ = Describe("Component sync controller", func() {
}),
Entry("Should provision OpenStack resources", testCase{
status: &configv1.InfrastructureStatus{
Platform: configv1.OpenStackPlatformType,
InfrastructureTopology: configv1.HighlyAvailableTopologyMode,
ControlPlaneTopology: configv1.HighlyAvailableTopologyMode,
Platform: configv1.OpenStackPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.OpenStackPlatformType,
},
Expand All @@ -340,7 +344,9 @@ var _ = Describe("Component sync controller", func() {
}),
Entry("Should not provision resources for currently unsupported platform", testCase{
status: &configv1.InfrastructureStatus{
Platform: configv1.IBMCloudPlatformType,
InfrastructureTopology: configv1.HighlyAvailableTopologyMode,
ControlPlaneTopology: configv1.HighlyAvailableTopologyMode,
Platform: configv1.IBMCloudPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.IBMCloudPlatformType,
},
Expand All @@ -349,15 +355,19 @@ var _ = Describe("Component sync controller", func() {
}),
Entry("Should not provision resources for AWS if external FeatureGate is not present", testCase{
status: &configv1.InfrastructureStatus{
Platform: configv1.AWSPlatformType,
InfrastructureTopology: configv1.HighlyAvailableTopologyMode,
ControlPlaneTopology: configv1.HighlyAvailableTopologyMode,
Platform: configv1.AWSPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.AWSPlatformType,
},
},
}),
Entry("Should not provision resources for OpenStack if external FeatureGate is not present", testCase{
status: &configv1.InfrastructureStatus{
Platform: configv1.OpenStackPlatformType,
InfrastructureTopology: configv1.HighlyAvailableTopologyMode,
ControlPlaneTopology: configv1.HighlyAvailableTopologyMode,
Platform: configv1.OpenStackPlatformType,
PlatformStatus: &configv1.PlatformStatus{
Type: configv1.OpenStackPlatformType,
},
Expand Down
26 changes: 13 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ module github.com/openshift/cluster-cloud-controller-manager-operator
go 1.16

require (
github.com/onsi/ginkgo v1.14.1
github.com/onsi/gomega v1.10.2
github.com/openshift/api v0.0.0-20201216151826-78a19e96f9eb
github.com/openshift/library-go v0.0.0-20210318152630-323ad8a8f7d8
github.com/spf13/cobra v1.1.1
github.com/onsi/ginkgo v1.16.4
github.com/onsi/gomega v1.13.0
github.com/openshift/api v0.0.0-20210521075222-e273a339932a
github.com/openshift/library-go v0.0.0-20210608075825-51ddcf37b1f8
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.7.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/api v0.20.0
k8s.io/apiextensions-apiserver v0.20.0
k8s.io/apimachinery v0.21.0-alpha.0.0.20210106165743-6c16abd71758
k8s.io/client-go v0.20.0
k8s.io/api v0.21.1
k8s.io/apiextensions-apiserver v0.21.1
k8s.io/apimachinery v0.21.1
k8s.io/client-go v0.21.1
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.4.0
k8s.io/utils v0.0.0-20201110183641-67b214c5f920
sigs.k8s.io/controller-runtime v0.7.0
k8s.io/klog/v2 v2.9.0
k8s.io/utils v0.0.0-20210527160623-6fdb442a123b
sigs.k8s.io/controller-runtime v0.9.0
sigs.k8s.io/yaml v1.2.0
)
262 changes: 145 additions & 117 deletions go.sum

Large diffs are not rendered by default.

27 changes: 9 additions & 18 deletions pkg/render/render.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package render

import (
"bytes"
"fmt"
"io/fs"
"io/ioutil"
Expand All @@ -14,11 +13,10 @@ import (
"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/config"
"github.com/openshift/cluster-cloud-controller-manager-operator/pkg/substitution"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer/json"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/klog"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
)

const (
Expand All @@ -28,12 +26,6 @@ const (
bootstrapFileName = "%s/%s-%s.yaml"
)

var scheme *runtime.Scheme

func init() {
scheme = runtime.NewScheme()
}

// Render defines render config for use in bootstrap mode
type Render struct {
// path to rendered configv1.Infrastructure manifest
Expand Down Expand Up @@ -83,8 +75,7 @@ func (r *Render) readAssets() (*configv1.Infrastructure, *corev1.ConfigMap, erro
}

infra := &configv1.Infrastructure{}
dec := k8syaml.NewYAMLOrJSONDecoder(bytes.NewReader(infraData), 1000)
if err := dec.Decode(infra); err != nil {
if err := yaml.UnmarshalStrict(infraData, infra); err != nil {
klog.Errorf("Cannot decode data into configv1.Infrastructure from %q: %v", r.infrastructureFile, err)
return nil, nil, err
}
Expand All @@ -96,8 +87,7 @@ func (r *Render) readAssets() (*configv1.Infrastructure, *corev1.ConfigMap, erro
}

imagesConfigMap := &corev1.ConfigMap{}
dec = k8syaml.NewYAMLOrJSONDecoder(bytes.NewReader(imagesData), 1000)
if err := dec.Decode(imagesConfigMap); err != nil {
if err := yaml.UnmarshalStrict(imagesData, imagesConfigMap); err != nil {
klog.Errorf("Cannot decode data into v1.ConfigMap from %q: %v", r.imagesFile, err)
return nil, nil, err
}
Expand All @@ -119,13 +109,14 @@ func writeAssets(destinationDir string, resources []client.Object) error {
path := filepath.Join(destinationDir, filename)

klog.Infof("Writing file %q on disk", path)
file, err := os.Create(path)
if err != nil {
data, err := yaml.Marshal(resource)
// As we operate with client.Object we never expect this call to fail.
utilruntime.HandleError(err)

if err := os.WriteFile(path, data, 0666); err != nil {
klog.Errorf("Failed to open %q: %v", path, err)
return err
}
defer file.Close()
json.NewYAMLSerializer(json.DefaultMetaFactory, scheme, scheme).Encode(resource, file)
}
return nil
}
24 changes: 11 additions & 13 deletions pkg/render/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,20 @@ func TestWriteAssets(t *testing.T) {
}
for _, res := range tc.objects {
filename := fmt.Sprintf("%s-%s.yaml", res.GetName(), strings.ToLower(res.GetObjectKind().GroupVersionKind().Kind))
found := assert.Contains(t, names, filename)
assert.Contains(t, names, filename)

if found {
// Object copy with some required fields emptied
collectedObject := res.DeepCopyObject().(client.Object)
collectedObject.SetName("")
collectedObject.SetNamespace("")
data, err := os.ReadFile(path.Join(destination, bootstrapPrefix, filename))
assert.NoError(t, err)
// Object copy with some required fields emptied
collectedObject := res.DeepCopyObject().(client.Object)
collectedObject.SetName("")
collectedObject.SetNamespace("")
data, err := os.ReadFile(path.Join(destination, bootstrapPrefix, filename))
assert.NoError(t, err)

// Fill object with data from disc
err = yaml.UnmarshalStrict(data, collectedObject)
assert.NoError(t, err)
// Fill object with data from disc
err = yaml.UnmarshalStrict(data, collectedObject)
assert.NoError(t, err)

assert.Equal(t, collectedObject, res)
}
assert.Equal(t, collectedObject, res)
}
})
}
Expand Down
17 changes: 14 additions & 3 deletions vendor/github.com/Azure/go-autorest/autorest/authorization.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions vendor/github.com/Azure/go-autorest/autorest/azure/async.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/Azure/go-autorest/autorest/azure/azure.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions vendor/github.com/Azure/go-autorest/autorest/azure/environments.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading