Skip to content

Commit

Permalink
Remove unused code related to Che
Browse files Browse the repository at this point in the history
Signed-off-by: Baiju Muthukadan <baiju.m.mail@gmail.com>
  • Loading branch information
baijum committed Oct 16, 2023
1 parent 95add19 commit 0755386
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 102 deletions.
42 changes: 21 additions & 21 deletions pkg/configuration/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,59 +218,59 @@ func TestNoWatchNamespaceSetWhenLoadingConfigMap(t *testing.T) {

func TestLoadSecrets(t *testing.T) {
secretData := map[string][]byte{
"che-admin-username": []byte("cheadmin"),
"che-admin-password": []byte("password"),
"admin-username": []byte("cheadmin"),
"admin-password": []byte("password"),
}
secretData2 := map[string][]byte{
"che-admin-username2": []byte("cheadmin2"),
"che-admin-password2": []byte("password2"),
"admin-username2": []byte("cheadmin2"),
"admin-password2": []byte("password2"),
}

t.Run("one secret found", func(t *testing.T) {
// given
secret := test.CreateSecret("che-secret", test.MemberOperatorNs, secretData)
secret := test.CreateSecret("secret", test.MemberOperatorNs, secretData)
cl := test.NewFakeClient(t, secret)

// when
secrets, err := LoadSecrets(cl, test.MemberOperatorNs)

// then
expected := map[string]string{
"che-admin-username": "cheadmin",
"che-admin-password": "password",
"admin-username": "cheadmin",
"admin-password": "password",
}
require.NoError(t, err)
require.Equal(t, expected, secrets["che-secret"])
require.Equal(t, expected, secrets["secret"])
})

t.Run("two secrets found", func(t *testing.T) {
// given
secret := test.CreateSecret("che-secret", test.MemberOperatorNs, secretData)
secret2 := test.CreateSecret("che-secret2", test.MemberOperatorNs, secretData2)
secret := test.CreateSecret("secret", test.MemberOperatorNs, secretData)
secret2 := test.CreateSecret("secret2", test.MemberOperatorNs, secretData2)
cl := test.NewFakeClient(t, secret, secret2)

// when
secrets, err := LoadSecrets(cl, test.MemberOperatorNs)

// then
expected := map[string]string{
"che-admin-username": "cheadmin",
"che-admin-password": "password",
"admin-username": "cheadmin",
"admin-password": "password",
}
expected2 := map[string]string{
"che-admin-username2": "cheadmin2",
"che-admin-password2": "password2",
"admin-username2": "cheadmin2",
"admin-password2": "password2",
}
require.NoError(t, err)
require.Equal(t, expected, secrets["che-secret"])
require.Equal(t, expected2, secrets["che-secret2"])
require.Equal(t, expected, secrets["secret"])
require.Equal(t, expected2, secrets["secret2"])
})

t.Run("secrets from another namespace not listed", func(t *testing.T) {
// given
secret := test.CreateSecret("che-secret", test.MemberOperatorNs, secretData)
secret := test.CreateSecret("secret", test.MemberOperatorNs, secretData)
secret.Namespace = "default"
secret2 := test.CreateSecret("che-secret2", test.MemberOperatorNs, secretData2)
secret2 := test.CreateSecret("secret2", test.MemberOperatorNs, secretData2)
secret2.Namespace = "default"
cl := test.NewFakeClient(t, secret, secret2)

Expand All @@ -284,15 +284,15 @@ func TestLoadSecrets(t *testing.T) {

t.Run("service account secrets are not listed", func(t *testing.T) {
// given
secret := test.CreateSecret("che-secret", test.MemberOperatorNs, secretData)
secret := test.CreateSecret("secret", test.MemberOperatorNs, secretData)
secret.Annotations = map[string]string{
"kubernetes.io/service-account.name": "default-something",
}
secret2 := test.CreateSecret("che-secret2", test.MemberOperatorNs, secretData2)
secret2 := test.CreateSecret("secret2", test.MemberOperatorNs, secretData2)
secret2.Annotations = map[string]string{
"kubernetes.io/service-account.name": "builder-something",
}
secret3 := test.CreateSecret("che-secret3", test.MemberOperatorNs, secretData2)
secret3 := test.CreateSecret("secret3", test.MemberOperatorNs, secretData2)
secret3.Annotations = map[string]string{
"kubernetes.io/service-account.name": "deployer-something",
}
Expand Down
81 changes: 0 additions & 81 deletions pkg/test/config/memberoperatorconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,87 +82,6 @@ func (o AutoscalerOption) BufferReplicas(value int) AutoscalerOption {
return o
}

type CheOption struct {
*MemberOperatorConfigOptionImpl
}

func Che() *CheOption {
o := &CheOption{
MemberOperatorConfigOptionImpl: &MemberOperatorConfigOptionImpl{},
}
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che = toolchainv1alpha1.CheConfig{}
})
return o
}

func (o CheOption) Required(value bool) CheOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.Required = &value
})
return o
}

func (o CheOption) UserDeletionEnabled(value bool) CheOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.UserDeletionEnabled = &value
})
return o
}

func (o CheOption) KeycloakRouteName(value string) CheOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.KeycloakRouteName = &value
})
return o
}

func (o CheOption) Namespace(value string) CheOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.Namespace = &value
})
return o
}

func (o CheOption) RouteName(value string) CheOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.RouteName = &value
})
return o
}

type CheSecretOption struct {
*MemberOperatorConfigOptionImpl
}

func (o CheOption) Secret() *CheSecretOption {
c := &CheSecretOption{
MemberOperatorConfigOptionImpl: o.MemberOperatorConfigOptionImpl,
}
return c
}

func (o CheSecretOption) Ref(value string) CheSecretOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.Secret.Ref = &value
})
return o
}

func (o CheSecretOption) CheAdminUsernameKey(value string) CheSecretOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.Secret.CheAdminUsernameKey = &value
})
return o
}

func (o CheSecretOption) CheAdminPasswordKey(value string) CheSecretOption {
o.addFunction(func(config *toolchainv1alpha1.MemberOperatorConfig) {
config.Spec.Che.Secret.CheAdminPasswordKey = &value
})
return o
}

type ConsoleOption struct {
*MemberOperatorConfigOptionImpl
}
Expand Down

0 comments on commit 0755386

Please sign in to comment.