Skip to content
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

bugfix: fix rr label issue #577

Merged
merged 1 commit into from
Oct 12, 2022
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
19 changes: 10 additions & 9 deletions pkg/controller/recommendation/recommendation_rule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,24 +251,25 @@ func (c *RecommendationRuleController) CreateRecommendationObject(recommendation
OwnerReferences: []metav1.OwnerReference{
*newOwnerRef(recommendationRule),
},
Labels: id.Labels,
},
Spec: analysisv1alph1.RecommendationSpec{
TargetRef: target,
Type: analysisv1alph1.AnalysisType(recommenderName),
},
}

if recommendation.Labels == nil {
recommendation.Labels = map[string]string{}
labels := map[string]string{}
labels[known.RecommendationRuleNameLabel] = recommendationRule.Name
labels[known.RecommendationRuleUidLabel] = string(recommendationRule.UID)
labels[known.RecommendationRuleRecommenderLabel] = recommenderName
labels[known.RecommendationRuleTargetKindLabel] = target.Kind
labels[known.RecommendationRuleTargetVersionLabel] = target.GroupVersionKind().Version
labels[known.RecommendationRuleTargetNameLabel] = target.Name
for k, v := range id.Labels {
labels[k] = v
}
recommendation.Labels[known.RecommendationRuleNameLabel] = recommendationRule.Name
recommendation.Labels[known.RecommendationRuleUidLabel] = string(recommendationRule.UID)
recommendation.Labels[known.RecommendationRuleRecommenderLabel] = recommenderName
recommendation.Labels[known.RecommendationRuleTargetKindLabel] = target.Kind
recommendation.Labels[known.RecommendationRuleTargetApiVersionLabel] = target.APIVersion
recommendation.Labels[known.RecommendationRuleTargetNameLabel] = target.Name

recommendation.Labels = labels
return recommendation
}

Expand Down
12 changes: 6 additions & 6 deletions pkg/known/label.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ const (
)

const (
RecommendationRuleNameLabel = "analysis.crane.io/recommendation-rule-name"
RecommendationRuleUidLabel = "analysis.crane.io/recommendation-rule-uid"
RecommendationRuleRecommenderLabel = "analysis.crane.io/recommendation-rule-recommender"
RecommendationRuleTargetKindLabel = "analysis.crane.io/recommendation-target-kind"
RecommendationRuleTargetApiVersionLabel = "analysis.crane.io/recommendation-target-apiversion"
RecommendationRuleTargetNameLabel = "analysis.crane.io/recommendation-target-name"
RecommendationRuleNameLabel = "analysis.crane.io/recommendation-rule-name"
RecommendationRuleUidLabel = "analysis.crane.io/recommendation-rule-uid"
RecommendationRuleRecommenderLabel = "analysis.crane.io/recommendation-rule-recommender"
RecommendationRuleTargetKindLabel = "analysis.crane.io/recommendation-target-kind"
RecommendationRuleTargetVersionLabel = "analysis.crane.io/recommendation-target-version"
RecommendationRuleTargetNameLabel = "analysis.crane.io/recommendation-target-name"
)