Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for CloneAndRemoveLabel (0.47 sec)

  1. pkg/util/labels/labels.go

    	for key, value := range labels {
    		newLabels[key] = value
    	}
    	newLabels[labelKey] = labelValue
    	return newLabels
    }
    
    // CloneAndRemoveLabel clones the given map and returns a new map with the given key removed.
    // Returns the given map, if labelKey is empty.
    func CloneAndRemoveLabel(labels map[string]string, labelKey string) map[string]string {
    	if labelKey == "" {
    		// Don't need to add a label.
    		return labels
    	}
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Jan 11 17:34:12 UTC 2017
    - 3.7K bytes
    - Viewed (0)
  2. pkg/util/labels/labels_test.go

    		got := CloneAndAddLabel(tc.labels, tc.labelKey, tc.labelValue)
    		if !reflect.DeepEqual(got, tc.want) {
    			t.Errorf("[Add] got %v, want %v", got, tc.want)
    		}
    		// now test the inverse.
    		got_rm := CloneAndRemoveLabel(got, tc.labelKey)
    		if !reflect.DeepEqual(got_rm, tc.labels) {
    			t.Errorf("[RM] got %v, want %v", got_rm, tc.labels)
    		}
    	}
    }
    
    func TestAddLabel(t *testing.T) {
    	labels := map[string]string{
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed Jan 11 17:34:12 UTC 2017
    - 4.1K bytes
    - Viewed (0)
Back to top