forked from kubernetes-sigs/controller-runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose CRDInstallOptions via envtest.Environment
This change provides better control for installing CRDs in `envtest`. Addresses kubernetes-sigs#541
- Loading branch information
1 parent
d7467fc
commit fd5c30a
Showing
5 changed files
with
66 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package envtest | ||
|
||
import apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1" | ||
|
||
// mergePaths merges two string slices containing paths. | ||
// This function makes no guarantees about order of the merged slice. | ||
func mergePaths(s1, s2 []string) []string { | ||
m := make(map[string]struct{}) | ||
for _, s := range s1 { | ||
m[s] = struct{}{} | ||
} | ||
for _, s := range s2 { | ||
m[s] = struct{}{} | ||
} | ||
merged := make([]string, len(m)) | ||
i := 0 | ||
for key, _ := range m { | ||
merged[i] = key | ||
i++ | ||
} | ||
return merged | ||
} | ||
|
||
// mergeCRDs merges two CRD slices using their names. | ||
// This function makes no guarantees about order of the merged slice. | ||
func mergeCRDs(s1, s2 []*apiextensionsv1beta1.CustomResourceDefinition) []*apiextensionsv1beta1.CustomResourceDefinition { | ||
m := make(map[string]*apiextensionsv1beta1.CustomResourceDefinition) | ||
for _, crd := range s1 { | ||
m[crd.Name] = crd | ||
} | ||
for _, crd := range s2 { | ||
m[crd.Name] = crd | ||
} | ||
merged := make([]*apiextensionsv1beta1.CustomResourceDefinition, len(m)) | ||
i := 0 | ||
for _, crd := range m { | ||
merged[i] = crd | ||
i++ | ||
} | ||
return merged | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters