mirror of
https://github.com/redhat-developer/odo.git
synced 2025-10-19 03:06:19 +03:00
* Add Dev and Project labeling / refactoring labeling and annotations <!-- Thank you for opening a PR! Here are some things you need to know before submitting: 1. Please read our developer guideline: https://github.com/redhat-developer/odo/wiki/Dev:-odo-Dev-Guidelines 2. Label this PR accordingly with the '/kind' line 3. Ensure you have written and ran the appropriate tests: https://github.com/redhat-developer/odo/wiki/Dev:-Writing-and-running-tests 4. Read how we approve and LGTM each PR: https://github.com/redhat-developer/odo/wiki/Pull-Requests:-Review-guideline Documentation: If you are pushing a change to documentation, please read: https://github.com/redhat-developer/odo/wiki/Documentation:-Contributing --> **What type of PR is this:** <!-- Add one of the following kinds: /kind bug /kind tests /kind documentation Feel free to use other [labels](https://github.com/redhat-developer/odo/labels) as needed. However one of the above labels must be present or the PR will not be reviewed. This instruction is for reviewers as well. --> /kind feature /kind cleanup **What does this PR do / why we need it:** In this PR we: * Correctly name all the labels in a more concise manner (ex. Project Type is an annotation) * Add Dev and Deploy mode labels to both `odo dev` and `odo deploy` commands so that we can intuitively retrieve what components are in deploy or dev mode * Somewhat refactors how we do labeling **Which issue(s) this PR fixes:** <!-- Specifying the issue will automatically close it when this PR is merged --> 1/2 of PR's for https://github.com/redhat-developer/odo/issues/5405 **PR acceptance criteria:** - [X] Unit test - [X] Integration test - [X] Documentation **How to test changes / Special notes to the reviewer:** N/A Signed-off-by: Charlie Drage <charlie@charliedrage.com> * Review update / renaming Signed-off-by: Charlie Drage <charlie@charliedrage.com> * Review changes. Adds tests for generateDeploymentObjectMeta. Changes labels Signed-off-by: Charlie Drage <charlie@charliedrage.com>
75 lines
2.5 KiB
Go
75 lines
2.5 KiB
Go
package testingutil
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
v1 "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
|
|
"github.com/devfile/library/pkg/devfile/generator"
|
|
routev1 "github.com/openshift/api/route/v1"
|
|
applabels "github.com/redhat-developer/odo/pkg/application/labels"
|
|
componentlabels "github.com/redhat-developer/odo/pkg/component/labels"
|
|
"github.com/redhat-developer/odo/pkg/url/labels"
|
|
"github.com/redhat-developer/odo/pkg/version"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/util/intstr"
|
|
)
|
|
|
|
func GetRouteListWithMultiple(componentName, applicationName string) *routev1.RouteList {
|
|
return &routev1.RouteList{
|
|
Items: []routev1.Route{
|
|
GetSingleRoute("example", 8080, componentName, applicationName),
|
|
GetSingleRoute("example-1", 9100, componentName, applicationName),
|
|
},
|
|
}
|
|
}
|
|
|
|
func GetSingleRoute(urlName string, port int, componentName, applicationName string) routev1.Route {
|
|
return routev1.Route{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: urlName,
|
|
Labels: map[string]string{
|
|
applabels.ApplicationLabel: applicationName,
|
|
componentlabels.KubernetesInstanceLabel: componentName,
|
|
applabels.ManagedBy: "odo",
|
|
applabels.ManagerVersion: version.VERSION,
|
|
labels.URLLabel: urlName,
|
|
},
|
|
},
|
|
Spec: routev1.RouteSpec{
|
|
Host: "example.com",
|
|
To: routev1.RouteTargetReference{
|
|
Kind: "Service",
|
|
Name: fmt.Sprintf("%s-%s", componentName, applicationName),
|
|
},
|
|
Port: &routev1.RoutePort{
|
|
TargetPort: intstr.FromInt(port),
|
|
},
|
|
Path: "/",
|
|
},
|
|
}
|
|
}
|
|
|
|
// GetSingleSecureRoute returns a secure route generated with the given parameters
|
|
func GetSingleSecureRoute(urlName string, port int, componentName, applicationName string) routev1.Route {
|
|
generatedRoute := *generator.GetRoute(v1.Endpoint{}, generator.RouteParams{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: urlName,
|
|
Labels: map[string]string{
|
|
applabels.ApplicationLabel: applicationName,
|
|
componentlabels.KubernetesInstanceLabel: componentName,
|
|
applabels.ManagedBy: "odo",
|
|
applabels.ManagerVersion: version.VERSION,
|
|
labels.URLLabel: urlName,
|
|
applabels.App: applicationName,
|
|
},
|
|
},
|
|
RouteSpecParams: generator.RouteSpecParams{
|
|
ServiceName: componentName,
|
|
PortNumber: intstr.FromInt(port),
|
|
Secure: true,
|
|
},
|
|
})
|
|
generatedRoute.Spec.Host = "example.com"
|
|
return generatedRoute
|
|
}
|