Add merge support for serviceaccounts

All properties from a backup will be merged into the ServiceAccount
except for the default token secret.

Signed-off-by: Nolan Brubaker <nolan@heptio.com>
This commit is contained in:
Nolan Brubaker
2018-06-15 12:40:59 -04:00
parent 0396ca1dee
commit e7d00cf5fd
9 changed files with 1054 additions and 87 deletions
+11
View File
@@ -122,3 +122,14 @@ func Exists(root map[string]interface{}, path string) bool {
_, err := GetValue(root, path)
return err == nil
}
// MergeMaps takes two map[string]string and merges missing keys from the second into the first.
// If a key already exists, its value is not overwritten.
func MergeMaps(first, second map[string]string) {
for k, v := range second {
_, ok := first[k]
if !ok {
first[k] = v
}
}
}
+3 -1
View File
@@ -16,7 +16,9 @@ limitations under the License.
package collections
import "testing"
import (
"testing"
)
func TestGetString(t *testing.T) {
var testCases = []struct {
+5
View File
@@ -64,3 +64,8 @@ func (c *FakeDynamicClient) Get(name string, opts metav1.GetOptions) (*unstructu
args := c.Called(name, opts)
return args.Get(0).(*unstructured.Unstructured), args.Error(1)
}
func (c *FakeDynamicClient) Patch(name string, data []byte) (*unstructured.Unstructured, error) {
args := c.Called(name, data)
return args.Get(0).(*unstructured.Unstructured), args.Error(1)
}