mirror of
https://github.com/kubernetes/sample-controller.git
synced 2026-04-12 00:00:26 +08:00
Merge pull request #59842 from ixdy/update-rules_go-02-2018
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Update bazelbuild/rules_go, kubernetes/repo-infra, and gazelle dependencies **What this PR does / why we need it**: updates our bazelbuild/rules_go dependency in order to bump everything to go1.9.4. I'm separating this effort into two separate PRs, since updating rules_go requires a large cleanup, removing an attribute from most build rules. **Release note**: ```release-note NONE ``` Kubernetes-commit: 96ec3187180b9c1d722756b3ea0984ebe65424dc
This commit is contained in:
-1
@@ -10,7 +10,6 @@ go_test(
|
||||
name = "go_default_test",
|
||||
srcs = ["group_version_test.go"],
|
||||
embed = [":go_default_library"],
|
||||
importpath = "k8s.io/apimachinery/pkg/runtime/schema",
|
||||
)
|
||||
|
||||
go_library(
|
||||
|
||||
+24
@@ -36,6 +36,21 @@ func ParseResourceArg(arg string) (*GroupVersionResource, GroupResource) {
|
||||
return gvr, ParseGroupResource(arg)
|
||||
}
|
||||
|
||||
// ParseKindArg takes the common style of string which may be either `Kind.group.com` or `Kind.version.group.com`
|
||||
// and parses it out into both possibilities. This code takes no responsibility for knowing which representation was intended
|
||||
// but with a knowledge of all GroupKinds, calling code can take a very good guess. If there are only two segments, then
|
||||
// `*GroupVersionResource` is nil.
|
||||
// `Kind.group.com` -> `group=com, version=group, kind=Kind` and `group=group.com, kind=Kind`
|
||||
func ParseKindArg(arg string) (*GroupVersionKind, GroupKind) {
|
||||
var gvk *GroupVersionKind
|
||||
if strings.Count(arg, ".") >= 2 {
|
||||
s := strings.SplitN(arg, ".", 3)
|
||||
gvk = &GroupVersionKind{Group: s[2], Version: s[1], Kind: s[0]}
|
||||
}
|
||||
|
||||
return gvk, ParseGroupKind(arg)
|
||||
}
|
||||
|
||||
// GroupResource specifies a Group and a Resource, but does not force a version. This is useful for identifying
|
||||
// concepts during lookup stages without having partially valid types
|
||||
type GroupResource struct {
|
||||
@@ -58,6 +73,15 @@ func (gr *GroupResource) String() string {
|
||||
return gr.Resource + "." + gr.Group
|
||||
}
|
||||
|
||||
func ParseGroupKind(gk string) GroupKind {
|
||||
i := strings.Index(gk, ".")
|
||||
if i == -1 {
|
||||
return GroupKind{Kind: gk}
|
||||
}
|
||||
|
||||
return GroupKind{Group: gk[i+1:], Kind: gk[:i]}
|
||||
}
|
||||
|
||||
// ParseGroupResource turns "resource.group" string into a GroupResource struct. Empty strings are allowed
|
||||
// for each field.
|
||||
func ParseGroupResource(gr string) GroupResource {
|
||||
|
||||
Reference in New Issue
Block a user