Skip to content

Update the operator to support the registry viewer #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion controllers/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (r *DevfileRegistryReconciler) generateResourceObject(cr *registryv1alpha1.
case *appsv1.Deployment:
return registry.GenerateDeployment(cr, r.Scheme, labels)
case *corev1.ConfigMap:
return registry.GenerateOCIRegistryConfigMap(cr, r.Scheme, labels)
return registry.GenerateRegistryConfigMap(cr, r.Scheme, labels)
case *corev1.PersistentVolumeClaim:
return registry.GeneratePVC(cr, r.Scheme, labels)
case *corev1.Service:
Expand Down
13 changes: 11 additions & 2 deletions pkg/registry/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
registryv1alpha1 "github.com/devfile/registry-operator/api/v1alpha1"
)

// GenerateOCIRegistryConfigMap returns a configmap that is used to configure the OCI registry container
func GenerateOCIRegistryConfigMap(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Scheme, labels map[string]string) *corev1.ConfigMap {
// GenerateRegistryConfigMap returns a configmap that is used to configure the devfile registry
func GenerateRegistryConfigMap(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Scheme, labels map[string]string) *corev1.ConfigMap {
configMapData := make(map[string]string, 0)

registryConfig := `
Expand All @@ -45,6 +45,15 @@ http:

configMapData["registry-config.yml"] = registryConfig

viewerConfig := `
{
"Community": {
"url": "http://localhost:8080"
}
}`

configMapData["devfile-registry-hosts.json"] = viewerConfig

cm := &corev1.ConfigMap{
ObjectMeta: generateObjectMeta(ConfigMapName(cr.Name), cr.Namespace, labels),
Data: configMapData,
Expand Down
37 changes: 37 additions & 0 deletions pkg/registry/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,28 @@ func GenerateDeployment(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Sc
},
},
},
StartupProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/viewer",
Port: intstr.FromInt(DevfileIndexPort),
},
},
InitialDelaySeconds: 30,
PeriodSeconds: 10,
},
VolumeMounts: []corev1.VolumeMount{
{
Name: "viewer-config",
MountPath: "/app/config",
ReadOnly: false,
},
},
Env: []corev1.EnvVar{
{
Name: "DEVFILE_VIEWER_ROOT",
Value: "/viewer",
},
{
Name: "ENABLE_TELEMETRY",
Value: strconv.FormatBool(IsTelemetryEnabled(cr)),
Expand Down Expand Up @@ -131,6 +152,22 @@ func GenerateDeployment(cr *registryv1alpha1.DevfileRegistry, scheme *runtime.Sc
},
},
},
{
Name: "viewer-config",
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: ConfigMapName(cr.Name),
},
Items: []corev1.KeyToPath{
{
Key: "devfile-registry-hosts.json",
Path: "devfile-registry-hosts.json",
},
},
},
},
},
},
},
},
Expand Down
1 change: 0 additions & 1 deletion pkg/registry/naming.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func ServiceName(devfileRegistryName string) string {
}

// ConfigMapName returns the name of the service object associated with the DevfileRegistry CR
// Just returns the CR name right now, but extracting to a function to avoid relying on that assumption in the future
func ConfigMapName(devfileRegistryName string) string {
return devfileRegistryName + "-registry-config"
}
Expand Down
16 changes: 8 additions & 8 deletions tests/integration/pkg/tests/devfileregistry_tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ var _ = ginkgo.Describe("[Create Devfile Registry resource]", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Wait for the registry instance to become ready
err = K8sClient.WaitForRegistryInstance(crName, 30*time.Second)
err = K8sClient.WaitForRegistryInstance(crName, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Retrieve the registry URL and verify the server is up and running
registry, err := K8sClient.GetRegistryInstance(crName)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
err = util.WaitForServer(registry.Status.URL, 30*time.Second)
err = util.WaitForServer(registry.Status.URL, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Verify that the index metrics endpoint is running
Expand Down Expand Up @@ -94,7 +94,7 @@ var _ = ginkgo.Describe("[Create Devfile Registry resource with TLS enabled]", f
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Wait for the registry instance to become ready
err = K8sClient.WaitForRegistryInstance(crName, 30*time.Second)
err = K8sClient.WaitForRegistryInstance(crName, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Retrieve the registry URL and verify that its protocol is https
Expand All @@ -103,7 +103,7 @@ var _ = ginkgo.Describe("[Create Devfile Registry resource with TLS enabled]", f
gomega.Expect(registry.Status.URL).To(gomega.ContainSubstring("https://"))

// Verify that the server is accessible.
err = util.WaitForServer(registry.Status.URL, 30*time.Second)
err = util.WaitForServer(registry.Status.URL, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
})

Expand All @@ -130,13 +130,13 @@ var _ = ginkgo.Describe("[Update Devfile Registry resource]", func() {
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Wait for the registry instance to become ready
err = K8sClient.WaitForRegistryInstance(crName, 30*time.Second)
err = K8sClient.WaitForRegistryInstance(crName, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Retrieve the registry URL and verify the server is up and running
registry, err := K8sClient.GetRegistryInstance(crName)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
err = util.WaitForServer(registry.Status.URL, 30*time.Second)
err = util.WaitForServer(registry.Status.URL, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

// Update the devfileregistry resource for this test case
Expand All @@ -147,12 +147,12 @@ var _ = ginkgo.Describe("[Update Devfile Registry resource]", func() {
}

// Retrieve the registry URL and verify that its protocol is https
url, err := K8sClient.WaitForURLChange(crName, registry.Status.URL, 30*time.Second)
url, err := K8sClient.WaitForURLChange(crName, registry.Status.URL, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
gomega.Expect(url).To(gomega.ContainSubstring("https://"))

// Verify that the server is accessible.
err = util.WaitForServer(url, 30*time.Second)
err = util.WaitForServer(url, 5*time.Minute)
gomega.Expect(err).NotTo(gomega.HaveOccurred())
})

Expand Down