Skip to content

Commit

Permalink
Fixes in shoot creation: worker field set for gcp, enableStaticKubeco…
Browse files Browse the repository at this point in the history
…nfigSet.
  • Loading branch information
akgalwas committed Aug 13, 2024
1 parent 1b09b24 commit f181bd5
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 33 deletions.
64 changes: 32 additions & 32 deletions hack/shoot-comparator/pkg/shoot/matcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ func getShoot(i interface{}) (shoot v1beta1.Shoot, err error) {

type matcher struct {
types.GomegaMatcher
path string
expected interface{}
path string
actual interface{}
}

func (m *Matcher) Match(actual interface{}) (success bool, err error) {
Expand All @@ -71,147 +71,147 @@ func (m *Matcher) Match(actual interface{}) (success bool, err error) {
// It is simpler to skip it than to make fix in the Provisioner.
//{
// GomegaMatcher: gomega.BeComparableTo(eShoot.TypeMeta),
// expected: aShoot.TypeMeta,
// actual: aShoot.TypeMeta,
//},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Name),
expected: aShoot.Name,
actual: aShoot.Name,
path: "metadata/name",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Namespace),
expected: aShoot.Namespace,
actual: aShoot.Namespace,
path: "metadata/namespace",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Labels),
expected: aShoot.Labels,
actual: aShoot.Labels,
path: "metadata/labels",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Addons),
expected: aShoot.Spec.Addons,
actual: aShoot.Spec.Addons,
path: "spec/Addons",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.CloudProfileName),
expected: aShoot.Spec.CloudProfileName,
actual: aShoot.Spec.CloudProfileName,
path: "spec/CloudProfileName",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.DNS),
expected: aShoot.Spec.DNS,
actual: aShoot.Spec.DNS,
path: "spec/DNS",
},
{
GomegaMatcher: NewExtensionMatcher(eShoot.Spec.Extensions),
expected: aShoot.Spec.Extensions,
actual: aShoot.Spec.Extensions,
path: "spec/Extensions",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Hibernation),
expected: aShoot.Spec.Hibernation,
actual: aShoot.Spec.Hibernation,
path: "spec/Hibernation",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Kubernetes),
expected: aShoot.Spec.Kubernetes,
actual: aShoot.Spec.Kubernetes,
path: "spec/Kubernetes",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Networking),
expected: aShoot.Spec.Networking,
actual: aShoot.Spec.Networking,
path: "spec/Networking",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Maintenance),
expected: aShoot.Spec.Maintenance,
actual: aShoot.Spec.Maintenance,
path: "spec/Maintenance",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Monitoring),
expected: aShoot.Spec.Monitoring,
actual: aShoot.Spec.Monitoring,
path: "spec/Monitoring",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Provider),
expected: aShoot.Spec.Provider,
actual: aShoot.Spec.Provider,
path: "spec/Provider",
},

{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Purpose),
expected: aShoot.Spec.Purpose,
actual: aShoot.Spec.Purpose,
path: "spec/Purpose",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Region),
expected: aShoot.Spec.Region,
actual: aShoot.Spec.Region,
path: "spec/Region",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.SecretBindingName),
expected: aShoot.Spec.SecretBindingName,
actual: aShoot.Spec.SecretBindingName,
path: "spec/SecretBindingName",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.SeedName),
expected: aShoot.Spec.SeedName,
actual: aShoot.Spec.SeedName,
path: "spec/SeedName",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.SeedSelector),
expected: aShoot.Spec.SeedSelector,
actual: aShoot.Spec.SeedSelector,
path: "spec/SeedSelector",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Resources),
expected: aShoot.Spec.Resources,
actual: aShoot.Spec.Resources,
path: "spec/Resources",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.Tolerations),
expected: aShoot.Spec.Tolerations,
actual: aShoot.Spec.Tolerations,
path: "spec/Tolerations",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.ExposureClassName),
expected: aShoot.Spec.ExposureClassName,
actual: aShoot.Spec.ExposureClassName,
path: "spec/ExposureClassName",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.SystemComponents),
expected: aShoot.Spec.SystemComponents,
actual: aShoot.Spec.SystemComponents,
path: "spec/SystemComponents",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.ControlPlane),
expected: aShoot.Spec.ControlPlane,
actual: aShoot.Spec.ControlPlane,
path: "spec/ControlPlane",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.SchedulerName),
expected: aShoot.Spec.SchedulerName,
actual: aShoot.Spec.SchedulerName,
path: "spec/SchedulerName",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.CloudProfile),
expected: aShoot.Spec.CloudProfile,
actual: aShoot.Spec.CloudProfile,
path: "spec/CloudProfile",
},
{
GomegaMatcher: gomega.BeComparableTo(eShoot.Spec.CredentialsBindingName),
expected: aShoot.Spec.CredentialsBindingName,
actual: aShoot.Spec.CredentialsBindingName,
path: "spec/CredentialsBindingName",
},
} {
ok, err := matcher.Match(matcher.expected)
ok, err := matcher.Match(matcher.actual)
if err != nil {
return false, err
}

if !ok {
msg := matcher.FailureMessage(matcher.expected)
msg := matcher.FailureMessage(matcher.actual)
if matcher.path != "" {
msg = fmt.Sprintf("%s: %s", matcher.path, msg)
}
Expand All @@ -223,7 +223,7 @@ func (m *Matcher) Match(actual interface{}) (success bool, err error) {
}

func (m *Matcher) NegatedFailureMessage(_ interface{}) string {
return "expected should not equal actual"
return "actual should not equal actual"
}

func (m *Matcher) FailureMessage(_ interface{}) string {
Expand Down
1 change: 1 addition & 0 deletions internal/gardener/shoot/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func NewConverter(config ConverterConfig) Converter {
extender.ExtendWithExposureClassName,
extender.ExtendWithTolerations,
extender.NewMaintenanceExtender(config.Kubernetes.EnableKubernetesVersionAutoUpdate, config.Kubernetes.EnableMachineImageVersionAutoUpdate),
extender.ExtendWithStaticKubeconfig,
}

return Converter{
Expand Down
13 changes: 13 additions & 0 deletions internal/gardener/shoot/extender/static_kubeconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package extender

import (
gardener "github.com/gardener/gardener/pkg/apis/core/v1beta1"
imv1 "github.com/kyma-project/infrastructure-manager/api/v1"
"k8s.io/utils/ptr"
)

func ExtendWithStaticKubeconfig(_ imv1.Runtime, shoot *gardener.Shoot) error {
shoot.Spec.Kubernetes.EnableStaticTokenKubeconfig = ptr.To(false)

return nil
}
21 changes: 21 additions & 0 deletions internal/gardener/shoot/extender/static_kubeconfig_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package extender

import (
imv1 "github.com/kyma-project/infrastructure-manager/api/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"testing"
)

func TestExtendWithStaticKubeconfig(t *testing.T) {
// given
runtime := imv1.Runtime{}
shoot := fixEmptyGardenerShoot("test", "dev")

// when
err := ExtendWithStaticKubeconfig(runtime, &shoot)

// then
require.NoError(t, err)
assert.Equal(t, false, *shoot.Spec.Kubernetes.EnableStaticTokenKubeconfig)
}
3 changes: 2 additions & 1 deletion internal/gardener/shoot/hyperscaler/gcp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ func NewInfrastructureConfig(workerCIDR string) v1alpha1.InfrastructureConfig {
},
Networks: v1alpha1.NetworkConfig{
// Provisioner sets also deprecated Worker field.
// Logic for comparing shoots in integration tests must be adjusted accordingly
// We set it temporarily to make comparison easier.
Worker: workerCIDR,
Workers: workerCIDR,
},
}
Expand Down

0 comments on commit f181bd5

Please sign in to comment.