Skip to content

Commit

Permalink
address theo's remarks, round 2: easy and obvious fixes again
Browse files Browse the repository at this point in the history
  • Loading branch information
hervenicol committed Dec 20, 2024
1 parent 3449953 commit 618382d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
12 changes: 6 additions & 6 deletions internal/controller/dashboard_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ func getDashboardUID(jsonDashboard string) (string, error) {
func getDashboardCMOrg(dashboard *v1.ConfigMap) (string, error) {

// Try to look for an annotation first
orgName, ok := dashboard.GetAnnotations()[organization.OrganizationLabel]
if ok && orgName != "" {
return orgName, nil
annotations := dashboard.GetAnnotations()
if annotations != nil && annotations[organization.OrganizationLabel] != "" {
return annotations[organization.OrganizationLabel], nil
}

// Then look for a label
orgName, ok = dashboard.GetLabels()[organization.OrganizationLabel]
if ok && orgName != "" {
return orgName, nil
labels := dashboard.GetLabels()
if labels != nil && labels[organization.OrganizationLabel] != "" {
return labels[organization.OrganizationLabel], nil
}

// Return an error if no label was found
Expand Down
16 changes: 0 additions & 16 deletions internal/controller/dashboard_controller_test.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/*
Copyright 2024.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package controller

import (
Expand Down

0 comments on commit 618382d

Please sign in to comment.