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 5 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