diff --git a/knative/deployer.go b/knative/deployer.go index 3fa4f9a7..0f4581ee 100644 --- a/knative/deployer.go +++ b/knative/deployer.go @@ -311,6 +311,10 @@ func generateNewService(f fn.Function, decorator DeployDecorator) (*v1.Service, Spec: v1.ServiceSpec{ ConfigurationSpec: v1.ConfigurationSpec{ Template: v1.RevisionTemplateSpec{ + ObjectMeta: metav1.ObjectMeta{ + Labels: labels, + Annotations: annotations, + }, Spec: v1.RevisionSpec{ PodSpec: corev1.PodSpec{ Containers: []corev1.Container{ @@ -346,6 +350,7 @@ func updateService(f fn.Function, newEnv []corev1.EnvVar, newEnvFrom []corev1.En for k, v := range f.Annotations { service.ObjectMeta.Annotations[k] = v + service.Spec.Template.ObjectMeta.Annotations[k] = v } // I hate that we have to do this. Users should not see these values. // It is an implementation detail. These health endpoints should not be @@ -372,6 +377,7 @@ func updateService(f fn.Function, newEnv []corev1.EnvVar, newEnvFrom []corev1.En return service, err } service.ObjectMeta.Labels = labels + service.Spec.Template.ObjectMeta.Labels = labels err = flags.UpdateImage(&service.Spec.Template.Spec.PodSpec, f.ImageWithDigest()) if err != nil { diff --git a/openshift/metadata.go b/openshift/metadata.go index a8aee74b..e5b25037 100644 --- a/openshift/metadata.go +++ b/openshift/metadata.go @@ -5,12 +5,21 @@ import ( ) const ( - AnnotationOpenShiftVcsUri = "app.openshift.io/vcs-uri" - AnnotationOpenShiftVcsRef = "app.openshift.io/vcs-ref" + annotationOpenShiftVcsUri = "app.openshift.io/vcs-uri" + annotationOpenShiftVcsRef = "app.openshift.io/vcs-ref" - LabelAppK8sInstance = "app.kubernetes.io/instance" + labelAppK8sInstance = "app.kubernetes.io/instance" + labelOpenShiftRuntime = "app.openshift.io/runtime" ) +var iconValuesForRuntimes = map[string]string{ + "go": "golang", + "node": "nodejs", + "python": "python", + "quarkus": "quarkus", + "springboot": "spring-boot", +} + type OpenshiftMetadataDecorator struct{} func (o OpenshiftMetadataDecorator) UpdateAnnotations(f fn.Function, annotations map[string]string) map[string]string { @@ -18,10 +27,10 @@ func (o OpenshiftMetadataDecorator) UpdateAnnotations(f fn.Function, annotations annotations = map[string]string{} } if f.Git.URL != nil { - annotations[AnnotationOpenShiftVcsUri] = *f.Git.URL + annotations[annotationOpenShiftVcsUri] = *f.Git.URL } if f.Git.Revision != nil { - annotations[AnnotationOpenShiftVcsRef] = *f.Git.Revision + annotations[annotationOpenShiftVcsRef] = *f.Git.Revision } return annotations @@ -32,7 +41,14 @@ func (o OpenshiftMetadataDecorator) UpdateLabels(f fn.Function, labels map[strin labels = map[string]string{} } - labels[LabelAppK8sInstance] = f.Name + // this label is used for referencing a Tekton Pipeline and deployed KService + labels[labelAppK8sInstance] = f.Name + + // if supported, set the label representing a runtime icon in Developer Console + iconValue, ok := iconValuesForRuntimes[f.Runtime] + if ok { + labels[labelOpenShiftRuntime] = iconValue + } return labels }