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:
Ryan Richard 2020-07-31 17:22:12 -07:00
parent 9fe82ec5f1
commit cf56c67329
9 changed files with 51 additions and 53 deletions

View File

@ -15,9 +15,9 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: logindiscoveryconfigs.placeholder.suzerain-io.github.io
name: logindiscoveryconfigs.crds.placeholder.suzerain-io.github.io
spec:
group: placeholder.suzerain-io.github.io
group: crds.placeholder.suzerain-io.github.io
versions:
#! 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

View File

@ -38,7 +38,7 @@ rules:
- apiGroups: [""]
resources: [services]
verbs: [create, get, list, patch, update, watch]
- apiGroups: [placeholder.suzerain-io.github.io]
- apiGroups: [crds.placeholder.suzerain-io.github.io]
resources: [logindiscoveryconfigs]
verbs: [create, get, list, update, watch]
---

4
go.mod
View File

@ -11,8 +11,8 @@ require (
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
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-client-go v0.0.0-20200731022627-a9c34c8413ac
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731224558-ff85679d3364
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
k8s.io/api v0.19.0-rc.0
k8s.io/apimachinery v0.19.0-rc.0

8
go.sum
View File

@ -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/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/placeholder-name-api v0.0.0-20200731022217-d7e4c306f7fd h1:rJT8jn+6g1Wy40nGOGULz9hQvuDq0MZSA+3JaTaqVgQ=
github.com/suzerain-io/placeholder-name-api v0.0.0-20200731022217-d7e4c306f7fd/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-20200731022627-a9c34c8413ac/go.mod h1:EFFPGm0xrUidCxQkF1g2pGdKifwo4U0Dwi70TTluNGM=
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-20200731224558-ff85679d3364/go.mod h1:OuYBJDpMMnvMUoBn+XeMWtHghuYk0cq9bNkNa3T8j/g=
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-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/go.mod h1:yHp0ai0Z9gUljN3o0xMhYJnH/IcvkdTBOX2fmJ93JEM=
github.com/tetafro/godot v0.4.2 h1:Dib7un+rYJFUi8vN0Bk6EHheKy6fv6ZzFURHw75g6m8=

View File

@ -17,9 +17,9 @@ import (
"k8s.io/klog/v2"
"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"
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 (
@ -54,14 +54,14 @@ type publisherController struct {
namespace string
placeholderClient placeholderclientset.Interface
configMapInformer corev1informers.ConfigMapInformer
loginDiscoveryConfigInformer placeholderv1alpha1informers.LoginDiscoveryConfigInformer
loginDiscoveryConfigInformer crdsplaceholderv1alpha1informers.LoginDiscoveryConfigInformer
}
func NewPublisherController(
namespace string,
placeholderClient placeholderclientset.Interface,
configMapInformer corev1informers.ConfigMapInformer,
loginDiscoveryConfigInformer placeholderv1alpha1informers.LoginDiscoveryConfigInformer,
loginDiscoveryConfigInformer crdsplaceholderv1alpha1informers.LoginDiscoveryConfigInformer,
withInformer withInformerOptionFunc,
) controller.Controller {
return controller.New(
@ -120,13 +120,13 @@ func (c *publisherController) Sync(ctx controller.Context) error {
break
}
discoveryConfig := placeholderv1alpha1.LoginDiscoveryConfig{
discoveryConfig := crdsplaceholderv1alpha1.LoginDiscoveryConfig{
TypeMeta: metav1.TypeMeta{},
ObjectMeta: metav1.ObjectMeta{
Name: configName,
Namespace: c.namespace,
},
Spec: placeholderv1alpha1.LoginDiscoveryConfigSpec{
Spec: crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
Server: server,
CertificateAuthorityData: certificateAuthorityData,
},
@ -140,7 +140,7 @@ func (c *publisherController) Sync(ctx controller.Context) error {
func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
ctx context.Context,
discoveryConfig *placeholderv1alpha1.LoginDiscoveryConfig,
discoveryConfig *crdsplaceholderv1alpha1.LoginDiscoveryConfig,
) error {
existingDiscoveryConfig, err := c.loginDiscoveryConfigInformer.
Lister().
@ -152,7 +152,7 @@ func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
}
loginDiscoveryConfigs := c.placeholderClient.
PlaceholderV1alpha1().
CrdsV1alpha1().
LoginDiscoveryConfigs(c.namespace)
if notFound {
if _, err := loginDiscoveryConfigs.Create(
@ -179,7 +179,7 @@ func (c *publisherController) createOrUpdateLoginDiscoveryConfig(
return nil
}
func equal(a, b *placeholderv1alpha1.LoginDiscoveryConfig) bool {
func equal(a, b *crdsplaceholderv1alpha1.LoginDiscoveryConfig) bool {
return a.Spec.Server == b.Spec.Server &&
a.Spec.CertificateAuthorityData == b.Spec.CertificateAuthorityData
}

View File

@ -24,7 +24,7 @@ import (
coretesting "k8s.io/client-go/testing"
"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"
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)
observableWithInformerOption = NewObservableWithInformerOption()
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(
installedInNamespace,
nil,
@ -122,20 +122,20 @@ func TestInformerFilters(t *testing.T) {
when("watching LoginDiscoveryConfig objects", func() {
var subject controller.Filter
var target, wrongNamespace, wrongName, unrelated *placeholderv1alpha1.LoginDiscoveryConfig
var target, wrongNamespace, wrongName, unrelated *crdsplaceholderv1alpha1.LoginDiscoveryConfig
it.Before(func() {
subject = loginDiscoveryConfigInformerFilter
target = &placeholderv1alpha1.LoginDiscoveryConfig{
target = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
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"},
}
wrongName = &placeholderv1alpha1.LoginDiscoveryConfig{
wrongName = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
ObjectMeta: metav1.ObjectMeta{Name: "wrong-name", Namespace: installedInNamespace},
}
unrelated = &placeholderv1alpha1.LoginDiscoveryConfig{
unrelated = &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
ObjectMeta: metav1.ObjectMeta{Name: "wrong-name", Namespace: "wrong-namespace"},
}
})
@ -194,18 +194,18 @@ func TestSync(t *testing.T) {
var timeoutContextCancel context.CancelFunc
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{
Group: placeholderv1alpha1.GroupName,
Group: crdsplaceholderv1alpha1.GroupName,
Version: "v1alpha1",
Resource: "logindiscoveryconfigs",
}
expectedLoginDiscoveryConfig := &placeholderv1alpha1.LoginDiscoveryConfig{
expectedLoginDiscoveryConfig := &crdsplaceholderv1alpha1.LoginDiscoveryConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "placeholder-name-config",
Namespace: expectedNamespace,
},
Spec: placeholderv1alpha1.LoginDiscoveryConfigSpec{
Spec: crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
Server: expectedServerURL,
CertificateAuthorityData: expectedCAData,
},
@ -237,7 +237,7 @@ func TestSync(t *testing.T) {
installedInNamespace,
placeholderAPIClient,
kubeInformers.Core().V1().ConfigMaps(),
placeholderInformers.Placeholder().V1alpha1().LoginDiscoveryConfigs(),
placeholderInformers.Crds().V1alpha1().LoginDiscoveryConfigs(),
controller.WithInformer,
)

View File

@ -346,7 +346,7 @@ func wireControllerManagerRunFunc(
serverInstallationNamespace,
placeholder,
k8sInformers.Core().V1().ConfigMaps(),
placeholderInformers.Placeholder().V1alpha1().LoginDiscoveryConfigs(),
placeholderInformers.Crds().V1alpha1().LoginDiscoveryConfigs(),
controller.WithInformer,
),
singletonWorker,

View File

@ -16,7 +16,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"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"
)
@ -32,7 +32,7 @@ func TestSuccessfulLoginDiscoveryConfig(t *testing.T) {
config := library.NewClientConfig(t)
expectedLDCSpec := expectedLDCSpec(config)
configList, err := client.
PlaceholderV1alpha1().
CrdsV1alpha1().
LoginDiscoveryConfigs(namespaceName).
List(ctx, metav1.ListOptions{})
require.NoError(t, err)
@ -50,7 +50,7 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
defer cancel()
err := client.
PlaceholderV1alpha1().
CrdsV1alpha1().
LoginDiscoveryConfigs(namespaceName).
Delete(ctx, "placeholder-name-config", metav1.DeleteOptions{})
require.NoError(t, err)
@ -58,9 +58,10 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
config := library.NewClientConfig(t)
expectedLDCSpec := expectedLDCSpec(config)
var actualLDC *placeholderv1alpha1.LoginDiscoveryConfig
var actualLDC *crdsplaceholderv1alpha1.LoginDiscoveryConfig
for i := 0; i < 10; i++ {
actualLDC, err = client.PlaceholderV1alpha1().
actualLDC, err = client.
CrdsV1alpha1().
LoginDiscoveryConfigs(namespaceName).
Get(ctx, "placeholder-name-config", metav1.GetOptions{})
if err == nil {
@ -72,8 +73,8 @@ func TestReconcilingLoginDiscoveryConfig(t *testing.T) {
require.Equal(t, expectedLDCSpec, &actualLDC.Spec)
}
func expectedLDCSpec(config *rest.Config) *placeholderv1alpha1.LoginDiscoveryConfigSpec {
return &placeholderv1alpha1.LoginDiscoveryConfigSpec{
func expectedLDCSpec(config *rest.Config) *crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec {
return &crdsplaceholderv1alpha1.LoginDiscoveryConfigSpec{
Server: "https://kind-control-plane:6443", //config.Host, // TODO FIX THIS
CertificateAuthorityData: base64.StdEncoding.EncodeToString(config.TLSClientConfig.CAData),
}

View File

@ -177,9 +177,10 @@ func TestGetAPIResourceList(t *testing.T) {
}
require.Equal(t, expectedGroup, actualGroup)
resourceGroupVersion := "placeholder.suzerain-io.github.io/v1alpha1"
actualResources := findResources(resourceGroupVersion, resources)
require.NotNil(t, actualResources)
actualPlaceHolderResources := findResources("placeholder.suzerain-io.github.io/v1alpha1", resources)
require.NotNil(t, actualPlaceHolderResources)
actualCrdsPlaceHolderResources := findResources("crds.placeholder.suzerain-io.github.io/v1alpha1", resources)
require.NotNil(t, actualPlaceHolderResources)
expectedLoginRequestAPIResource := metav1.APIResource{
Name: "loginrequests",
@ -203,19 +204,15 @@ func TestGetAPIResourceList(t *testing.T) {
StorageVersionHash: "unknown: to be filled in automatically below",
}
expectedResourcesMap := map[string]metav1.APIResource{
expectedLoginRequestAPIResource.Name: expectedLoginRequestAPIResource,
expectedLDCAPIResource.Name: expectedLDCAPIResource,
}
require.Len(t, actualPlaceHolderResources.APIResources, 1)
require.Equal(t, expectedLoginRequestAPIResource, actualPlaceHolderResources.APIResources[0])
require.Len(t, actualResources.APIResources, 2)
for _, actualAPIResource := range actualResources.APIResources {
if actualAPIResource.Name == expectedLDCAPIResource.Name {
// hard to predict the storage version hash (e.g. "t/+v41y+3e4=") so just don't worry about comparing them
expectedLDCAPIResource.StorageVersionHash = actualAPIResource.StorageVersionHash
}
require.Equal(t, expectedResourcesMap[actualAPIResource.Name], actualAPIResource)
}
require.Len(t, actualCrdsPlaceHolderResources.APIResources, 1)
actualAPIResource := actualCrdsPlaceHolderResources.APIResources[0]
// workaround because its hard to predict the storage version hash (e.g. "t/+v41y+3e4=")
// so just don't worry about comparing that field
expectedLDCAPIResource.StorageVersionHash = actualAPIResource.StorageVersionHash
require.Equal(t, expectedLDCAPIResource, actualAPIResource)
}
func findGroup(name string, groups []*metav1.APIGroup) *metav1.APIGroup {