-
Notifications
You must be signed in to change notification settings - Fork 244
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
Add Dev and Project labeling / refactoring labeling and annotations #5551
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,15 +11,16 @@ import ( | |
|
||
"github.com/pkg/errors" | ||
|
||
applabels "github.com/redhat-developer/odo/pkg/application/labels" | ||
"github.com/redhat-developer/odo/pkg/devfile/location" | ||
|
||
"github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2" | ||
"github.com/devfile/api/v2/pkg/devfile" | ||
"github.com/devfile/library/pkg/devfile/parser" | ||
parsercommon "github.com/devfile/library/pkg/devfile/parser/data/v2/common" | ||
dfutil "github.com/devfile/library/pkg/util" | ||
|
||
applabels "github.com/redhat-developer/odo/pkg/application/labels" | ||
componentlabels "github.com/redhat-developer/odo/pkg/component/labels" | ||
"github.com/redhat-developer/odo/pkg/devfile/location" | ||
"github.com/redhat-developer/odo/pkg/envinfo" | ||
"github.com/redhat-developer/odo/pkg/kclient" | ||
"github.com/redhat-developer/odo/pkg/libdevfile" | ||
|
@@ -42,7 +43,6 @@ const componentRandomNamePartsMaxLen = 12 | |
const componentNameMaxRetries = 3 | ||
const componentNameMaxLen = -1 | ||
const NotAvailable = "Not available" | ||
|
||
const apiVersion = "odo.dev/v1alpha1" | ||
|
||
// GetComponentDir returns source repo name | ||
|
@@ -141,7 +141,7 @@ func ListDevfileComponents(client kclient.ClientInterface, selector string) (Com | |
|
||
// create a list of object metadata based on the component and application name (extracted from Deployment labels) | ||
for _, elem := range deploymentList { | ||
component, err := GetComponent(client, elem.Labels[componentlabels.ComponentLabel], elem.Labels[applabels.ApplicationLabel], client.GetCurrentNamespace()) | ||
component, err := GetComponent(client, elem.Labels[componentlabels.ComponentKubernetesInstanceLabel], elem.Labels[applabels.ApplicationLabel], client.GetCurrentNamespace()) | ||
if err != nil { | ||
return ComponentList{}, errors.Wrap(err, "Unable to get component") | ||
} | ||
|
@@ -231,6 +231,7 @@ func GetLanguageFromDevfileMetadata(metadata devfile.DevfileMetadata) string { | |
|
||
func getComponentFrom(info localConfigProvider.LocalConfigProvider, componentType string) (Component, error) { | ||
if info.Exists() { | ||
|
||
component := newComponentWithType(info.GetName(), componentType) | ||
|
||
component.Namespace = info.GetNamespace() | ||
|
@@ -328,8 +329,9 @@ func Exists(client kclient.ClientInterface, componentName, applicationName strin | |
return false, nil | ||
} | ||
|
||
func GetComponentState(client kclient.ClientInterface, componentName, applicationName string) State { | ||
// first check if a deployment exists | ||
// GetComponentState ... | ||
cdrage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
func GetComponentState(client kclient.ClientInterface, componentName, applicationName string) string { | ||
// Check to see if the deployment has been pushed or not | ||
c, err := GetPushedComponent(client, componentName, applicationName) | ||
if err != nil { | ||
return StateTypeUnknown | ||
|
@@ -413,13 +415,14 @@ func getRemoteComponentMetadata(client kclient.ClientInterface, componentName st | |
// Annotations | ||
component.Annotations = fromCluster.GetAnnotations() | ||
|
||
// Mark the component status as pushed | ||
component.Status.State = componentlabels.ComponentPushedName | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably use |
||
|
||
// Labels | ||
component.Labels = fromCluster.GetLabels() | ||
|
||
component.Namespace = client.GetCurrentNamespace() | ||
component.Spec.App = applicationName | ||
component.Spec.Env = filteredEnv | ||
component.Status.State = StateTypePushed | ||
|
||
return component, nil | ||
} | ||
|
@@ -476,7 +479,7 @@ func setLinksServiceNames(client kclient.ClientInterface, linkedSecrets []Secret | |
|
||
serviceCompMap := make(map[string]string) | ||
for _, gotService := range services { | ||
serviceCompMap[gotService.Labels[componentlabels.ComponentLabel]] = gotService.Name | ||
serviceCompMap[gotService.Labels[componentlabels.ComponentKubernetesInstanceLabel]] = gotService.Name | ||
} | ||
|
||
for _, secret := range secrets { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,30 +5,43 @@ import ( | |
"github.com/redhat-developer/odo/pkg/util" | ||
) | ||
|
||
// ComponentLabel is a label key used to identify the component name | ||
const ComponentLabel = "app.kubernetes.io/instance" | ||
// ComponentKubernetesInstanceLabel is a label key used to identify the component name | ||
const ComponentKubernetesInstanceLabel = "app.kubernetes.io/instance" | ||
|
||
// ComponentTypeLabel is Kubernetes label that identifies the type of a component being used | ||
const ComponentTypeLabel = "app.kubernetes.io/name" | ||
// ComponentKubernetesNameLabel is Kubernetes label that identifies the type of a component being used | ||
const ComponentKubernetesNameLabel = "app.kubernetes.io/name" | ||
|
||
const ComponentTypeAnnotation = "odo.dev/project-type" | ||
// ComponentUnknownLabel is the label that is used to display something we do not know | ||
const ComponentUnknownLabel = "<unknown>" | ||
|
||
// ComponentDeployLabel ... | ||
const ComponentDeployLabel = "Deploy" | ||
// KubernetesManagedByLabel ... | ||
cdrage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const KubernetesManagedByLabel = "app.kubernetes.io/managed-by" | ||
|
||
// ComponentModeLabel ... | ||
const ComponentModeLabel = "odo.dev/mode" | ||
cdrage marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
// ComponentProjectTypeLabel ... | ||
const ComponentProjectTypeLabel = "odo.dev/project-type" | ||
// ComponentDevName ... | ||
const ComponentDevName = "Dev" | ||
|
||
// ComponentDeployName ... | ||
const ComponentDeployName = "Deploy" | ||
|
||
// ComponentNoneName ... | ||
const ComponentNoneName = "None" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used anywhere. |
||
|
||
// ComponentPushedName ... | ||
const ComponentPushedName = "Pushed" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not used as a label or its value it should not be in this file. Similar constant is already defined in pkg/component/types.go |
||
|
||
// ComponentProjectTypeAnnotation ... | ||
const ComponentProjectTypeAnnotation = "odo.dev/project-type" | ||
|
||
// GetLabels return labels that should be applied to every object for given component in active application | ||
// additional labels are used only for creating object | ||
// if you are creating something use additional=true | ||
// if you need labels to filter component then use additional=false | ||
func GetLabels(componentName string, applicationName string, additional bool) map[string]string { | ||
labels := applabels.GetLabels(applicationName, additional) | ||
labels[ComponentLabel] = componentName | ||
labels[ComponentKubernetesInstanceLabel] = componentName | ||
return labels | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we keep the import grouping as it were?