mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #100568 from lauchokyip/addDescribe
Added BinaryData description to kubectl describe
This commit is contained in:
		@@ -4298,6 +4298,12 @@ func (d *ConfigMapDescriber) Describe(namespace, name string, describerSettings
 | 
				
			|||||||
			w.Write(LEVEL_0, "%s:\n----\n", k)
 | 
								w.Write(LEVEL_0, "%s:\n----\n", k)
 | 
				
			||||||
			w.Write(LEVEL_0, "%s\n", string(v))
 | 
								w.Write(LEVEL_0, "%s\n", string(v))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							w.Write(LEVEL_0, "\nBinaryData\n====\n")
 | 
				
			||||||
 | 
							for k, v := range configMap.BinaryData {
 | 
				
			||||||
 | 
								w.Write(LEVEL_0, "%s: %s bytes\n", k, strconv.Itoa(len(v)))
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							w.Write(LEVEL_0, "\n")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if describerSettings.ShowEvents {
 | 
							if describerSettings.ShowEvents {
 | 
				
			||||||
			events, err := searchEvents(d.CoreV1(), configMap, describerSettings.ChunkSize)
 | 
								events, err := searchEvents(d.CoreV1(), configMap, describerSettings.ChunkSize)
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -284,6 +284,10 @@ func TestDescribeConfigMap(t *testing.T) {
 | 
				
			|||||||
			"key1": "value1",
 | 
								"key1": "value1",
 | 
				
			||||||
			"key2": "value2",
 | 
								"key2": "value2",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
							BinaryData: map[string][]byte{
 | 
				
			||||||
 | 
								"binarykey1": {0xFF, 0xFE, 0xFD, 0xFC, 0xFB},
 | 
				
			||||||
 | 
								"binarykey2": {0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA},
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	c := &describeClient{T: t, Namespace: "foo", Interface: fake}
 | 
						c := &describeClient{T: t, Namespace: "foo", Interface: fake}
 | 
				
			||||||
	d := ConfigMapDescriber{c}
 | 
						d := ConfigMapDescriber{c}
 | 
				
			||||||
@@ -291,7 +295,13 @@ func TestDescribeConfigMap(t *testing.T) {
 | 
				
			|||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		t.Errorf("unexpected error: %v", err)
 | 
							t.Errorf("unexpected error: %v", err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if !strings.Contains(out, "foo") || !strings.Contains(out, "mycm") || !strings.Contains(out, "key1") || !strings.Contains(out, "value1") || !strings.Contains(out, "key2") || !strings.Contains(out, "value2") {
 | 
						if !strings.Contains(out, "foo") || !strings.Contains(out, "mycm") {
 | 
				
			||||||
 | 
							t.Errorf("unexpected out: %s", out)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if !strings.Contains(out, "key1") || !strings.Contains(out, "value1") || !strings.Contains(out, "key2") || !strings.Contains(out, "value2") {
 | 
				
			||||||
 | 
							t.Errorf("unexpected out: %s", out)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if !strings.Contains(out, "binarykey1") || !strings.Contains(out, "5 bytes") || !strings.Contains(out, "binarykey2") || !strings.Contains(out, "6 bytes") {
 | 
				
			||||||
		t.Errorf("unexpected out: %s", out)
 | 
							t.Errorf("unexpected out: %s", out)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user