Move LoginDiscoveryConfig to the crds.placeholder.suzerain-io.github.io group
- Also includes bumping the api and client-go dependencies to the newer version which also moved LoginDiscoveryConfig to the crds.placeholder.suzerain-io.github.io group in the generated code
This commit is contained in:
parent
9fe82ec5f1
commit
cf56c67329
@ -15,9 +15,9 @@
|
|||||||
apiVersion: apiextensions.k8s.io/v1
|
apiVersion: apiextensions.k8s.io/v1
|
||||||
kind: CustomResourceDefinition
|
kind: CustomResourceDefinition
|
||||||
metadata:
|
metadata:
|
||||||
name: logindiscoveryconfigs.placeholder.suzerain-io.github.io
|
name: logindiscoveryconfigs.crds.placeholder.suzerain-io.github.io
|
||||||
spec:
|
spec:
|
||||||
group: placeholder.suzerain-io.github.io
|
group: crds.placeholder.suzerain-io.github.io
|
||||||
versions:
|
versions:
|
||||||
#! Any changes to these schemas should also be reflected in the types.go file(s)
|
#! Any changes to these schemas should also be reflected in the types.go file(s)
|
||||||
#! in https://github.com/suzerain-io/placeholder-name-api/tree/main/pkg/apis/placeholder
|
#! in https://github.com/suzerain-io/placeholder-name-api/tree/main/pkg/apis/placeholder
|
||||||
|
@ -38,7 +38,7 @@ rules:
|
|||||||
- apiGroups: [""]
|
- apiGroups: [""]
|
||||||
resources: [services]
|
resources: [services]
|
||||||
verbs: [create, get, list, patch, update, watch]
|
verbs: [create, get, list, patch, update, watch]
|
||||||
- apiGroups: [placeholder.suzerain-io.github.io]
|
- apiGroups: [crds.placeholder.suzerain-io.github.io]
|
||||||
resources: [logindiscoveryconfigs]
|
resources: [logindiscoveryconfigs]
|
||||||
verbs: [create, get, list, update, watch]
|
verbs: [create, get, list, update, watch]
|
||||||
---
|
---
|
||||||
|
4
go.mod
4
go.mod
@ -11,8 +11,8 @@ require (
|
|||||||
github.com/spf13/cobra v1.0.0
|
github.com/spf13/cobra v1.0.0
|
||||||
github.com/stretchr/testify v1.6.1
|
github.com/stretchr/testify v1.6.1
|
||||||
github.com/suzerain-io/controller-go v0.0.0-20200730212956-7f99b569ca9f
|
github.com/suzerain-io/controller-go v0.0.0-20200730212956-7f99b569ca9f
|
||||||
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731022217-d7e4c306f7fd
|
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731224558-ff85679d3364
|
||||||
github.com/suzerain-io/placeholder-name-client-go v0.0.0-20200731022627-a9c34c8413ac
|
github.com/suzerain-io/placeholder-name-client-go v0.0.0-20200731225637-b994efe19486
|
||||||
github.com/suzerain-io/placeholder-name/pkg/client v0.0.0-00010101000000-000000000000
|
github.com/suzerain-io/placeholder-name/pkg/client v0.0.0-00010101000000-000000000000
|
||||||
k8s.io/api v0.19.0-rc.0
|
k8s.io/api v0.19.0-rc.0
|
||||||
k8s.io/apimachinery v0.19.0-rc.0
|
k8s.io/apimachinery v0.19.0-rc.0
|
||||||
|
8
go.sum
8
go.sum
@ -532,10 +532,10 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
|
|||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
github.com/suzerain-io/controller-go v0.0.0-20200730212956-7f99b569ca9f h1:gZ6rAdl+VE9DT0yE52xY/kJZ/hOJYxwtsgGoPr5vItI=
|
github.com/suzerain-io/controller-go v0.0.0-20200730212956-7f99b569ca9f h1:gZ6rAdl+VE9DT0yE52xY/kJZ/hOJYxwtsgGoPr5vItI=
|
||||||
github.com/suzerain-io/controller-go v0.0.0-20200730212956-7f99b569ca9f/go.mod h1:+v9upryFWBJac6KXKlheGHr7e3kqpk1ldH1iIMFopMs=
|
github.com/suzerain-io/controller-go v0.0.0-20200730212956-7f99b569ca9f/go.mod h1:+v9upryFWBJac6KXKlheGHr7e3kqpk1ldH1iIMFopMs=
|
||||||
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731022217-d7e4c306f7fd h1:rJT8jn+6g1Wy40nGOGULz9hQvuDq0MZSA+3JaTaqVgQ=
|
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731224558-ff85679d3364 h1:5NaQExCSh8+6YP3QNhWsWyMrEd+7zsnrznRlisydlZo=
|
||||||
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731022217-d7e4c306f7fd/go.mod h1:OuYBJDpMMnvMUoBn+XeMWtHghuYk0cq9bNkNa3T8j/g=
|
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731224558-ff85679d3364/go.mod h1:OuYBJDpMMnvMUoBn+XeMWtHghuYk0cq9bNkNa3T8j/g=
|
||||||
github.com/suzerain-io/placeholder-name-client-go v0.0.0-20200731022627-a9c34c8413ac h1:3QfNymuRno/01062Ns/xv70m8TxQjiJQKTYCjIztGJw=
|
github.com/suzerain-io/placeholder-name-client-go v0.0.0-20200731225637-b994efe19486 h1:JOPwCoRjsUu8E/E81BolafPfovnTmxGAgFnEV0R8T3U=
|
||||||
github.com/suzerain-io/placeholder-name-client-go v0.0.0-20200731022627-a9c34c8413ac/go.mod h1:EFFPGm0xrUidCxQkF1g2pGdKifwo4U0Dwi70TTluNGM=
|
github.com/suzerain-io/placeholder-name-client-go v0.0.0-20200731225637-b994efe19486/go.mod h1:0lk6jYt88I1632/5TIwpBPhQAewKuesNK+rKhfoegRk=
|
||||||
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
|
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2 h1:Xr9gkxfOP0KQWXKNqmwe8vEeSUiUj4Rlee9CMVX2ZUQ=
|
||||||
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
|
github.com/tdakkota/asciicheck v0.0.0-20200416190851-d7f85be797a2/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
|
||||||
github.com/tetafro/godot v0.4.2 h1:Dib7un+rYJFUi8vN0Bk6EHheKy6fv6ZzFURHw75g6m8=
|
github.com/tetafro/godot v0.4.2 h1:Dib7un+rYJFUi8vN0Bk6EHheKy6fv6ZzFURHw75g6m8=
|
||||||
|
@ -17,9 +17,9 @@ import (
|
|||||||
"k8s.io/klog/v2"
|
"k8s.io/klog/v2"
|
||||||
|
|
||||||
"github.com/suzerain-io/controller-go"
|
"github.com/suzerain-io/controller-go"
|
||||||
placeholderv1alpha1 "github.com/suzerain-io/placeholder-name-api/pkg/apis/placeholder/v1alpha1"
|
crdsplaceholderv1alpha1 "github.com/suzerain-io/placeholder-name-api/pkg/apis/crdsplaceholder/v1alpha1"
|
||||||
placeholderclientset "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/clientset/versioned"
|
placeholderclientset "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/clientset/versioned"
|
||||||
placeholderv1alpha1informers "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/informers/externalversions/placeholder/v1alpha1"
|
crdsplaceholderv1alpha1informers "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/informers/externalversions/crdsplaceholder/v1alpha1"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -54,14 +54,14 @@ type publisherController struct {
|
|||||||
namespace string
|
namespace string
|
||||||
placeholderClient placeholderclientset.Interface
|
placeholderClient placeholderclientset.Interface
|
||||||
configMapInformer corev1informers.ConfigMapInformer
|
configMapInformer corev1informers.ConfigMapInformer
|
||||||
loginDiscoveryConfigInformer placeholderv1alpha1informers.LoginDiscoveryConfigInformer
|
loginDiscoveryConfigInformer crdsplaceholderv1alpha1informers.LoginDiscoveryConfigInformer
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewPublisherController(
|
func NewPublisherController(
|
||||||
namespace string,
|
namespace string,
|
||||||
placeholderClient placeholderclientset.Interface,
|
placeholderClient placeholderclientset.Interface,
|
||||||
configMapInformer corev1informers.ConfigMapInformer,
|
configMapInformer corev1informers.ConfigMapInformer,
|
||||||
loginDiscoveryConfigInformer placeholderv1alpha1informers.LoginDiscoveryConfigInformer,
|
loginDiscoveryConfigInformer crdsplaceholderv1alpha1informers.LoginDiscoveryConfigInformer,
|
||||||
withInformer withInformerOptionFunc,
|
withInformer withInformerOptionFunc,
|
||||||
) controller.Controller {
|
) controller.Controller {
|
||||||
return controller.New(
|
return controller.New(
|
||||||
@ -120,13 +120,13 @@ func (c *publisherController) Sync(ctx controller.Context) error {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
discoveryConfig := placeholderv1alpha1.LoginDiscoveryConfig{
|
discoveryConfig := crdsplaceholderv1alpha1.LoginDiscoveryConfig{
|
||||||
TypeMeta: metav1.TypeMeta{},
|
TypeMeta: metav1.TypeMeta{},
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: configName,
|
Name: configName,
|
||||||
Namespace: c.namespace,
|
Namespace: c.namespace,
|
||||||
},
|
},
|
||||||
Spec: placeholderv1alpha1.LoginDiscoveryConfigSpec{
|
Spec: crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
|
||||||
Server: server,
|
Server: server,
|
||||||
CertificateAuthorityData: certificateAuthorityData,
|
CertificateAuthorityData: certificateAuthorityData,
|
||||||
},
|
},
|
||||||
@ -140,7 +140,7 @@ func (c *publisherController) Sync(ctx controller.Context) error {
|
|||||||
|
|
||||||
func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
|
func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
discoveryConfig *placeholderv1alpha1.LoginDiscoveryConfig,
|
discoveryConfig *crdsplaceholderv1alpha1.LoginDiscoveryConfig,
|
||||||
) error {
|
) error {
|
||||||
existingDiscoveryConfig, err := c.loginDiscoveryConfigInformer.
|
existingDiscoveryConfig, err := c.loginDiscoveryConfigInformer.
|
||||||
Lister().
|
Lister().
|
||||||
@ -152,7 +152,7 @@ func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
|
|||||||
}
|
}
|
||||||
|
|
||||||
loginDiscoveryConfigs := c.placeholderClient.
|
loginDiscoveryConfigs := c.placeholderClient.
|
||||||
PlaceholderV1alpha1().
|
CrdsV1alpha1().
|
||||||
LoginDiscoveryConfigs(c.namespace)
|
LoginDiscoveryConfigs(c.namespace)
|
||||||
if notFound {
|
if notFound {
|
||||||
if _, err := loginDiscoveryConfigs.Create(
|
if _, err := loginDiscoveryConfigs.Create(
|
||||||
@ -179,7 +179,7 @@ func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func equal(a, b *placeholderv1alpha1.LoginDiscoveryConfig) bool {
|
func equal(a, b *crdsplaceholderv1alpha1.LoginDiscoveryConfig) bool {
|
||||||
return a.Spec.Server == b.Spec.Server &&
|
return a.Spec.Server == b.Spec.Server &&
|
||||||
a.Spec.CertificateAuthorityData == b.Spec.CertificateAuthorityData
|
a.Spec.CertificateAuthorityData == b.Spec.CertificateAuthorityData
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import (
|
|||||||
coretesting "k8s.io/client-go/testing"
|
coretesting "k8s.io/client-go/testing"
|
||||||
|
|
||||||
"github.com/suzerain-io/controller-go"
|
"github.com/suzerain-io/controller-go"
|
||||||
placeholderv1alpha1 "github.com/suzerain-io/placeholder-name-api/pkg/apis/placeholder/v1alpha1"
|
crdsplaceholderv1alpha1 "github.com/suzerain-io/placeholder-name-api/pkg/apis/crdsplaceholder/v1alpha1"
|
||||||
placeholderfake "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/clientset/versioned/fake"
|
placeholderfake "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/clientset/versioned/fake"
|
||||||
placeholderinformers "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/informers/externalversions"
|
placeholderinformers "github.com/suzerain-io/placeholder-name-client-go/pkg/generated/informers/externalversions"
|
||||||
)
|
)
|
||||||
@ -60,7 +60,7 @@ func TestInformerFilters(t *testing.T) {
|
|||||||
r = require.New(t)
|
r = require.New(t)
|
||||||
observableWithInformerOption = NewObservableWithInformerOption()
|
observableWithInformerOption = NewObservableWithInformerOption()
|
||||||
configMapInformer := kubeinformers.NewSharedInformerFactory(nil, 0).Core().V1().ConfigMaps()
|
configMapInformer := kubeinformers.NewSharedInformerFactory(nil, 0).Core().V1().ConfigMaps()
|
||||||
loginDiscoveryConfigInformer := placeholderinformers.NewSharedInformerFactory(nil, 0).Placeholder().V1alpha1().LoginDiscoveryConfigs()
|
loginDiscoveryConfigInformer := placeholderinformers.NewSharedInformerFactory(nil, 0).Crds().V1alpha1().LoginDiscoveryConfigs()
|
||||||
_ = NewPublisherController(
|
_ = NewPublisherController(
|
||||||
installedInNamespace,
|
installedInNamespace,
|
||||||
nil,
|
nil,
|
||||||
@ -122,20 +122,20 @@ func TestInformerFilters(t *testing.T) {
|
|||||||
|
|
||||||
when("watching LoginDiscoveryConfig objects", func() {
|
when("watching LoginDiscoveryConfig objects", func() {
|
||||||
var subject controller.Filter
|
var subject controller.Filter
|
||||||
var target, wrongNamespace, wrongName, unrelated *placeholderv1alpha1.LoginDiscoveryConfig
|
var target, wrongNamespace, wrongName, unrelated *crdsplaceholderv1alpha1.LoginDiscoveryConfig
|
||||||
|
|
||||||
it.Before(func() {
|
it.Before(func() {
|
||||||
subject = loginDiscoveryConfigInformerFilter
|
subject = loginDiscoveryConfigInformerFilter
|
||||||
target = &placeholderv1alpha1.LoginDiscoveryConfig{
|
target = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "placeholder-name-config", Namespace: installedInNamespace},
|
ObjectMeta: metav1.ObjectMeta{Name: "placeholder-name-config", Namespace: installedInNamespace},
|
||||||
}
|
}
|
||||||
wrongNamespace = &placeholderv1alpha1.LoginDiscoveryConfig{
|
wrongNamespace = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "placeholder-name-config", Namespace: "wrong-namespace"},
|
ObjectMeta: metav1.ObjectMeta{Name: "placeholder-name-config", Namespace: "wrong-namespace"},
|
||||||
}
|
}
|
||||||
wrongName = &placeholderv1alpha1.LoginDiscoveryConfig{
|
wrongName = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "wrong-name", Namespace: installedInNamespace},
|
ObjectMeta: metav1.ObjectMeta{Name: "wrong-name", Namespace: installedInNamespace},
|
||||||
}
|
}
|
||||||
unrelated = &placeholderv1alpha1.LoginDiscoveryConfig{
|
unrelated = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
|
||||||
ObjectMeta: metav1.ObjectMeta{Name: "wrong-name", Namespace: "wrong-namespace"},
|
ObjectMeta: metav1.ObjectMeta{Name: "wrong-name", Namespace: "wrong-namespace"},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -194,18 +194,18 @@ func TestSync(t *testing.T) {
|
|||||||
var timeoutContextCancel context.CancelFunc
|
var timeoutContextCancel context.CancelFunc
|
||||||
var syncContext *controller.Context
|
var syncContext *controller.Context
|
||||||
|
|
||||||
var expectedLoginDiscoveryConfig = func(expectedNamespace, expectedServerURL, expectedCAData string) (schema.GroupVersionResource, *placeholderv1alpha1.LoginDiscoveryConfig) {
|
var expectedLoginDiscoveryConfig = func(expectedNamespace, expectedServerURL, expectedCAData string) (schema.GroupVersionResource, *crdsplaceholderv1alpha1.LoginDiscoveryConfig) {
|
||||||
expectedLoginDiscoveryConfigGVR := schema.GroupVersionResource{
|
expectedLoginDiscoveryConfigGVR := schema.GroupVersionResource{
|
||||||
Group: placeholderv1alpha1.GroupName,
|
Group: crdsplaceholderv1alpha1.GroupName,
|
||||||
Version: "v1alpha1",
|
Version: "v1alpha1",
|
||||||
Resource: "logindiscoveryconfigs",
|
Resource: "logindiscoveryconfigs",
|
||||||
}
|
}
|
||||||
expectedLoginDiscoveryConfig := &placeholderv1alpha1.LoginDiscoveryConfig{
|
expectedLoginDiscoveryConfig := &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: "placeholder-name-config",
|
Name: "placeholder-name-config",
|
||||||
Namespace: expectedNamespace,
|
Namespace: expectedNamespace,
|
||||||
},
|
},
|
||||||
Spec: placeholderv1alpha1.LoginDiscoveryConfigSpec{
|
Spec: crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
|
||||||
Server: expectedServerURL,
|
Server: expectedServerURL,
|
||||||
CertificateAuthorityData: expectedCAData,
|
CertificateAuthorityData: expectedCAData,
|
||||||
},
|
},
|
||||||
@ -237,7 +237,7 @@ func TestSync(t *testing.T) {
|
|||||||
installedInNamespace,
|
installedInNamespace,
|
||||||
placeholderAPIClient,
|
placeholderAPIClient,
|
||||||
kubeInformers.Core().V1().ConfigMaps(),
|
kubeInformers.Core().V1().ConfigMaps(),
|
||||||
placeholderInformers.Placeholder().V1alpha1().LoginDiscoveryConfigs(),
|
placeholderInformers.Crds().V1alpha1().LoginDiscoveryConfigs(),
|
||||||
controller.WithInformer,
|
controller.WithInformer,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -346,7 +346,7 @@ func wireControllerManagerRunFunc(
|
|||||||
serverInstallationNamespace,
|
serverInstallationNamespace,
|
||||||
placeholder,
|
placeholder,
|
||||||
k8sInformers.Core().V1().ConfigMaps(),
|
k8sInformers.Core().V1().ConfigMaps(),
|
||||||
placeholderInformers.Placeholder().V1alpha1().LoginDiscoveryConfigs(),
|
placeholderInformers.Crds().V1alpha1().LoginDiscoveryConfigs(),
|
||||||
controller.WithInformer,
|
controller.WithInformer,
|
||||||
),
|
),
|
||||||
singletonWorker,
|
singletonWorker,
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
|
|
||||||
placeholderv1alpha1 "github.com/suzerain-io/placeholder-name-api/pkg/apis/placeholder/v1alpha1"
|
crdsplaceholderv1alpha1 "github.com/suzerain-io/placeholder-name-api/pkg/apis/crdsplaceholder/v1alpha1"
|
||||||
"github.com/suzerain-io/placeholder-name/test/library"
|
"github.com/suzerain-io/placeholder-name/test/library"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
|
|||||||
config := library.NewClientConfig(t)
|
config := library.NewClientConfig(t)
|
||||||
expectedLDCSpec := expectedLDCSpec(config)
|
expectedLDCSpec := expectedLDCSpec(config)
|
||||||
configList, err := client.
|
configList, err := client.
|
||||||
PlaceholderV1alpha1().
|
CrdsV1alpha1().
|
||||||
LoginDiscoveryConfigs(namespaceName).
|
LoginDiscoveryConfigs(namespaceName).
|
||||||
List(ctx, metav1.ListOptions{})
|
List(ctx, metav1.ListOptions{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -50,7 +50,7 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
err := client.
|
err := client.
|
||||||
PlaceholderV1alpha1().
|
CrdsV1alpha1().
|
||||||
LoginDiscoveryConfigs(namespaceName).
|
LoginDiscoveryConfigs(namespaceName).
|
||||||
Delete(ctx, "placeholder-name-config", metav1.DeleteOptions{})
|
Delete(ctx, "placeholder-name-config", metav1.DeleteOptions{})
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -58,9 +58,10 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
|||||||
config := library.NewClientConfig(t)
|
config := library.NewClientConfig(t)
|
||||||
expectedLDCSpec := expectedLDCSpec(config)
|
expectedLDCSpec := expectedLDCSpec(config)
|
||||||
|
|
||||||
var actualLDC *placeholderv1alpha1.LoginDiscoveryConfig
|
var actualLDC *crdsplaceholderv1alpha1.LoginDiscoveryConfig
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
actualLDC, err = client.PlaceholderV1alpha1().
|
actualLDC, err = client.
|
||||||
|
CrdsV1alpha1().
|
||||||
LoginDiscoveryConfigs(namespaceName).
|
LoginDiscoveryConfigs(namespaceName).
|
||||||
Get(ctx, "placeholder-name-config", metav1.GetOptions{})
|
Get(ctx, "placeholder-name-config", metav1.GetOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -72,8 +73,8 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
|
|||||||
require.Equal(t, expectedLDCSpec, &actualLDC.Spec)
|
require.Equal(t, expectedLDCSpec, &actualLDC.Spec)
|
||||||
}
|
}
|
||||||
|
|
||||||
func expectedLDCSpec(config *rest.Config) *placeholderv1alpha1.LoginDiscoveryConfigSpec {
|
func expectedLDCSpec(config *rest.Config) *crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec {
|
||||||
return &placeholderv1alpha1.LoginDiscoveryConfigSpec{
|
return &crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
|
||||||
Server: "https://kind-control-plane:6443", //config.Host, // TODO FIX THIS
|
Server: "https://kind-control-plane:6443", //config.Host, // TODO FIX THIS
|
||||||
CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData),
|
CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData),
|
||||||
}
|
}
|
||||||
|
@ -177,9 +177,10 @@ func TestGetAPIResourceList(t *testing.T) {
|
|||||||
}
|
}
|
||||||
require.Equal(t, expectedGroup, actualGroup)
|
require.Equal(t, expectedGroup, actualGroup)
|
||||||
|
|
||||||
resourceGroupVersion := "placeholder.suzerain-io.github.io/v1alpha1"
|
actualPlaceHolderResources := findResources("placeholder.suzerain-io.github.io/v1alpha1", resources)
|
||||||
actualResources := findResources(resourceGroupVersion, resources)
|
require.NotNil(t, actualPlaceHolderResources)
|
||||||
require.NotNil(t, actualResources)
|
actualCrdsPlaceHolderResources := findResources("crds.placeholder.suzerain-io.github.io/v1alpha1", resources)
|
||||||
|
require.NotNil(t, actualPlaceHolderResources)
|
||||||
|
|
||||||
expectedLoginRequestAPIResource := metav1.APIResource{
|
expectedLoginRequestAPIResource := metav1.APIResource{
|
||||||
Name: "loginrequests",
|
Name: "loginrequests",
|
||||||
@ -203,19 +204,15 @@ func TestGetAPIResourceList(t *testing.T) {
|
|||||||
StorageVersionHash: "unknown: to be filled in automatically below",
|
StorageVersionHash: "unknown: to be filled in automatically below",
|
||||||
}
|
}
|
||||||
|
|
||||||
expectedResourcesMap := map[string]metav1.APIResource{
|
require.Len(t, actualPlaceHolderResources.APIResources, 1)
|
||||||
expectedLoginRequestAPIResource.Name: expectedLoginRequestAPIResource,
|
require.Equal(t, expectedLoginRequestAPIResource, actualPlaceHolderResources.APIResources[0])
|
||||||
expectedLDCAPIResource.Name: expectedLDCAPIResource,
|
|
||||||
}
|
|
||||||
|
|
||||||
require.Len(t, actualResources.APIResources, 2)
|
require.Len(t, actualCrdsPlaceHolderResources.APIResources, 1)
|
||||||
for _, actualAPIResource := range actualResources.APIResources {
|
actualAPIResource := actualCrdsPlaceHolderResources.APIResources[0]
|
||||||
if actualAPIResource.Name == expectedLDCAPIResource.Name {
|
// workaround because its hard to predict the storage version hash (e.g. "t/+v41y+3e4=")
|
||||||
// hard to predict the storage version hash (e.g. "t/+v41y+3e4=") so just don't worry about comparing them
|
// so just don't worry about comparing that field
|
||||||
expectedLDCAPIResource.StorageVersionHash = actualAPIResource.StorageVersionHash
|
expectedLDCAPIResource.StorageVersionHash = actualAPIResource.StorageVersionHash
|
||||||
}
|
require.Equal(t, expectedLDCAPIResource, actualAPIResource)
|
||||||
require.Equal(t, expectedResourcesMap[actualAPIResource.Name], actualAPIResource)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func findGroup(name string, groups []*metav1.APIGroup) *metav1.APIGroup {
|
func findGroup(name string, groups []*metav1.APIGroup) *metav1.APIGroup {
|
||||||
|
Loading…
Reference in New Issue
Block a user