Propagate plugin registry URL to plugin registry configmap (#1118)
Signed-off-by: Mykola Morhun <mmorhun@redhat.com>pull/1120/head
parent
89055c99b7
commit
3952a53188
|
|
@ -231,6 +231,7 @@ func TestNativeUserModeEnabled(t *testing.T) {
|
|||
orgv1.SchemeBuilder.AddToScheme(scheme)
|
||||
scheme.AddKnownTypes(routev1.GroupVersion, route)
|
||||
scheme.AddKnownTypes(oauth.SchemeGroupVersion, oAuthClient)
|
||||
scheme.AddKnownTypes(configv1.SchemeGroupVersion, &configv1.Proxy{})
|
||||
initCR := InitCheWithSimpleCR().DeepCopy()
|
||||
testCase.initObjects = append(testCase.initObjects, initCR)
|
||||
|
||||
|
|
@ -1095,6 +1096,8 @@ func TestImagePullerConfiguration(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCheController(t *testing.T) {
|
||||
var err error
|
||||
|
||||
util.IsOpenShift = true
|
||||
util.IsOpenShift4 = false
|
||||
|
||||
|
|
@ -1124,21 +1127,12 @@ func TestCheController(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
_, err := r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
reconcileLoops := 4
|
||||
for i := 0; i < reconcileLoops; i++ {
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
}
|
||||
|
||||
// get devfile-registry configmap
|
||||
|
|
@ -1147,6 +1141,12 @@ func TestCheController(t *testing.T) {
|
|||
t.Errorf("ConfigMap %s not found: %s", devfilecm.Name, err)
|
||||
}
|
||||
|
||||
// get plugin-registry configmap
|
||||
pluginRegistrycm := &corev1.ConfigMap{}
|
||||
if err := cl.Get(context.TODO(), types.NamespacedName{Name: deploy.DevfileRegistryName, Namespace: cheCR.Namespace}, pluginRegistrycm); err != nil {
|
||||
t.Errorf("ConfigMap %s not found: %s", pluginRegistrycm.Name, err)
|
||||
}
|
||||
|
||||
// get CR
|
||||
if err := cl.Get(context.TODO(), types.NamespacedName{Name: os.Getenv("CHE_FLAVOR"), Namespace: namespace}, cheCR); err != nil {
|
||||
t.Errorf("CR not found")
|
||||
|
|
@ -1159,17 +1159,11 @@ func TestCheController(t *testing.T) {
|
|||
}
|
||||
|
||||
// reconcile again
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
for i := 0; i < reconcileLoops; i++ {
|
||||
_, err = r.Reconcile(context.TODO(), req)
|
||||
if err != nil {
|
||||
t.Fatalf("reconcile: (%v)", err)
|
||||
}
|
||||
}
|
||||
|
||||
// get configmap
|
||||
|
|
@ -1194,7 +1188,9 @@ func TestCheController(t *testing.T) {
|
|||
|
||||
// run a few checks to make sure the operator reconciled tls routes and updated configmap
|
||||
if cm.Data["CHE_INFRA_OPENSHIFT_TLS__ENABLED"] != "true" {
|
||||
t.Errorf("ConfigMap wasn't updated. Extecting true, got: %s", cm.Data["CHE_INFRA_OPENSHIFT_TLS__ENABLED"])
|
||||
// If the test fails here without obvious reason, it could mean that there was not enought reconcile loops before.
|
||||
// To fix the above problem, just increase reconcileLoops variable above.
|
||||
t.Errorf("ConfigMap wasn't updated. Expecting true, but got: %s", cm.Data["CHE_INFRA_OPENSHIFT_TLS__ENABLED"])
|
||||
}
|
||||
route := &routev1.Route{}
|
||||
if err := cl.Get(context.TODO(), types.NamespacedName{Name: deploy.DefaultCheFlavor(cheCR), Namespace: cheCR.Namespace}, route); err != nil {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ import (
|
|||
|
||||
"github.com/eclipse-che/che-operator/pkg/deploy"
|
||||
"github.com/eclipse-che/che-operator/pkg/deploy/expose"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
type PluginRegistry struct {
|
||||
|
|
@ -48,16 +47,9 @@ func (p *PluginRegistry) SyncAll() (bool, error) {
|
|||
return false, err
|
||||
}
|
||||
|
||||
if p.deployContext.CheCluster.IsAirGapMode() {
|
||||
done, err := p.SyncConfigMap()
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
} else {
|
||||
done, err := deploy.DeleteNamespacedObject(p.deployContext, deploy.PluginRegistryName, &corev1.ConfigMap{})
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
done, err = p.SyncConfigMap()
|
||||
if !done {
|
||||
return false, err
|
||||
}
|
||||
|
||||
done, err = p.SyncDeployment()
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import (
|
|||
type PluginRegistryConfigMap struct {
|
||||
CheSidecarContainersRegistryURL string `json:"CHE_SIDECAR_CONTAINERS_REGISTRY_URL"`
|
||||
CheSidecarContainersRegistryOrganization string `json:"CHE_SIDECAR_CONTAINERS_REGISTRY_ORGANIZATION"`
|
||||
ChePluginRegistryURL string `json:"CHE_PLUGIN_REGISTRY_URL"`
|
||||
}
|
||||
|
||||
func (p *PluginRegistry) GetConfigMapData() (map[string]string, error) {
|
||||
|
|
@ -25,6 +26,7 @@ func (p *PluginRegistry) GetConfigMapData() (map[string]string, error) {
|
|||
data := &PluginRegistryConfigMap{
|
||||
CheSidecarContainersRegistryURL: p.deployContext.CheCluster.Spec.Server.AirGapContainerRegistryHostname,
|
||||
CheSidecarContainersRegistryOrganization: p.deployContext.CheCluster.Spec.Server.AirGapContainerRegistryOrganization,
|
||||
ChePluginRegistryURL: p.deployContext.CheCluster.Status.PluginRegistryURL,
|
||||
}
|
||||
|
||||
out, err := json.Marshal(data)
|
||||
|
|
|
|||
|
|
@ -72,6 +72,13 @@ func TestPluginRegistrySyncAll(t *testing.T) {
|
|||
t.Fatalf("Route not found: %v", err)
|
||||
}
|
||||
|
||||
// check configmap
|
||||
cm := &corev1.ConfigMap{}
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: "plugin-registry", Namespace: "eclipse-che"}, cm)
|
||||
if err != nil {
|
||||
t.Fatalf("Config Map not found: %v", err)
|
||||
}
|
||||
|
||||
// check deployment
|
||||
deployment := &appsv1.Deployment{}
|
||||
err = cli.Get(context.TODO(), types.NamespacedName{Name: "plugin-registry", Namespace: "eclipse-che"}, deployment)
|
||||
|
|
|
|||
Loading…
Reference in New Issue