Merge pull request #68419 from xing-yang/apigroup

Make APIGroup optional in TypedLocalObjectReference
pull/8/head
k8s-ci-robot 2018-09-13 06:13:17 -07:00 committed by GitHub
commit 020b1d5ff5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 869 additions and 835 deletions

View File

@ -84666,13 +84666,12 @@
"io.k8s.api.core.v1.TypedLocalObjectReference": {
"description": "TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the same namespace.",
"required": [
"apiGroup",
"kind",
"name"
],
"properties": {
"apiGroup": {
"description": "APIGroup is the group for the resource being referenced",
"description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.",
"type": "string"
},
"kind": {

View File

@ -9550,7 +9550,7 @@
"properties": {
"apiGroup": {
"type": "string",
"description": "APIGroup is the group for the resource being referenced"
"description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required."
},
"kind": {
"type": "string",

View File

@ -6832,7 +6832,7 @@
"properties": {
"apiGroup": {
"type": "string",
"description": "APIGroup is the group for the resource being referenced"
"description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required."
},
"kind": {
"type": "string",

View File

@ -9554,7 +9554,7 @@
"properties": {
"apiGroup": {
"type": "string",
"description": "APIGroup is the group for the resource being referenced"
"description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required."
},
"kind": {
"type": "string",

View File

@ -19390,7 +19390,7 @@
"properties": {
"apiGroup": {
"type": "string",
"description": "APIGroup is the group for the resource being referenced"
"description": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required."
},
"kind": {
"type": "string",

View File

@ -575,7 +575,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">apiGroup</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>

View File

@ -686,7 +686,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">apiGroup</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>

View File

@ -578,7 +578,7 @@ span.icon > [class^="icon-"], span.icon > [class*=" icon-"] { cursor: default; }
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">apiGroup</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>

View File

@ -6723,7 +6723,7 @@ Examples:<br>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock">apiGroup</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">true</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">string</p></td>
<td class="tableblock halign-left valign-top"></td>

View File

@ -3976,8 +3976,11 @@ type LocalObjectReference struct {
// TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the same namespace.
type TypedLocalObjectReference struct {
// APIGroup is the group for the resource being referenced
APIGroup string
// APIGroup is the group for the resource being referenced.
// If APIGroup is not specified, the specified Kind must be in the core API group.
// For any other third-party types, APIGroup is required.
// +optional
APIGroup *string
// Kind is the type of resource being referenced
Kind string
// Name is the name of resource being referenced

View File

@ -7255,7 +7255,7 @@ func Convert_core_TopologySelectorTerm_To_v1_TopologySelectorTerm(in *core.Topol
}
func autoConvert_v1_TypedLocalObjectReference_To_core_TypedLocalObjectReference(in *v1.TypedLocalObjectReference, out *core.TypedLocalObjectReference, s conversion.Scope) error {
out.APIGroup = in.APIGroup
out.APIGroup = (*string)(unsafe.Pointer(in.APIGroup))
out.Kind = in.Kind
out.Name = in.Name
return nil
@ -7267,7 +7267,7 @@ func Convert_v1_TypedLocalObjectReference_To_core_TypedLocalObjectReference(in *
}
func autoConvert_core_TypedLocalObjectReference_To_v1_TypedLocalObjectReference(in *core.TypedLocalObjectReference, out *v1.TypedLocalObjectReference, s conversion.Scope) error {
out.APIGroup = in.APIGroup
out.APIGroup = (*string)(unsafe.Pointer(in.APIGroup))
out.Kind = in.Kind
out.Name = in.Name
return nil

View File

@ -32,6 +32,7 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/validation:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/labels:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/diff:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/intstr:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/sets:go_default_library",

View File

@ -36,6 +36,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
unversionedvalidation "k8s.io/apimachinery/pkg/apis/meta/v1/validation"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/util/sets"
@ -1501,8 +1502,9 @@ var supportedReclaimPolicy = sets.NewString(string(core.PersistentVolumeReclaimD
var supportedVolumeModes = sets.NewString(string(core.PersistentVolumeBlock), string(core.PersistentVolumeFilesystem))
var supportedDataSourceKinds = sets.NewString(string("VolumeSnapshot"))
var supportedDataSourceAPIGroups = sets.NewString(string("snapshot.storage.k8s.io"))
var supportedDataSourceAPIGroupKinds = map[schema.GroupKind]bool{
{Group: "snapshot.storage.k8s.io", Kind: "VolumeSnapshot"}: true,
}
func ValidatePersistentVolume(pv *core.PersistentVolume) field.ErrorList {
metaPath := field.NewPath("metadata")
@ -1833,10 +1835,18 @@ func ValidatePersistentVolumeClaimSpec(spec *core.PersistentVolumeClaimSpec, fld
} else if spec.DataSource != nil {
if len(spec.DataSource.Name) == 0 {
allErrs = append(allErrs, field.Required(fldPath.Child("dataSource", "name"), ""))
} else if !supportedDataSourceKinds.Has(string(spec.DataSource.Kind)) {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("dataSource"), spec.DataSource.Kind, supportedDataSourceKinds.List()))
} else if !supportedDataSourceAPIGroups.Has(string(spec.DataSource.APIGroup)) {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("dataSource"), spec.DataSource.APIGroup, supportedDataSourceAPIGroups.List()))
}
groupKind := schema.GroupKind{Group: "", Kind: spec.DataSource.Kind}
if spec.DataSource.APIGroup != nil {
groupKind.Group = string(*spec.DataSource.APIGroup)
}
groupKindList := make([]string, 0, len(supportedDataSourceAPIGroupKinds))
for grp := range supportedDataSourceAPIGroupKinds {
groupKindList = append(groupKindList, grp.String())
}
if !supportedDataSourceAPIGroupKinds[groupKind] {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("dataSource"), groupKind.String(), groupKindList))
}
}

View File

@ -726,7 +726,7 @@ func testVolumeSnapshotDataSourceInSpec(name string, kind string, apiGroup strin
},
StorageClassName: &scName,
DataSource: &core.TypedLocalObjectReference{
APIGroup: apiGroup,
APIGroup: &apiGroup,
Kind: kind,
Name: name,
},

View File

@ -2689,7 +2689,7 @@ func (in *PersistentVolumeClaimSpec) DeepCopyInto(out *PersistentVolumeClaimSpec
if in.DataSource != nil {
in, out := &in.DataSource, &out.DataSource
*out = new(TypedLocalObjectReference)
**out = **in
(*in).DeepCopyInto(*out)
}
return
}
@ -5075,6 +5075,11 @@ func (in *TopologySelectorTerm) DeepCopy() *TopologySelectorTerm {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TypedLocalObjectReference) DeepCopyInto(out *TypedLocalObjectReference) {
*out = *in
if in.APIGroup != nil {
in, out := &in.APIGroup, &out.APIGroup
*out = new(string)
**out = **in
}
return
}

File diff suppressed because it is too large Load Diff

View File

@ -4503,7 +4503,10 @@ message TopologySelectorTerm {
// TypedLocalObjectReference contains enough information to let you locate the
// typed referenced object inside the same namespace.
message TypedLocalObjectReference {
// APIGroup is the group for the resource being referenced
// APIGroup is the group for the resource being referenced.
// If APIGroup is not specified, the specified Kind must be in the core API group.
// For any other third-party types, APIGroup is required.
// +optional
optional string apiGroup = 1;
// Kind is the type of resource being referenced

View File

@ -4495,8 +4495,11 @@ type LocalObjectReference struct {
// TypedLocalObjectReference contains enough information to let you locate the
// typed referenced object inside the same namespace.
type TypedLocalObjectReference struct {
// APIGroup is the group for the resource being referenced
APIGroup string `json:"apiGroup" protobuf:"bytes,1,opt,name=apiGroup"`
// APIGroup is the group for the resource being referenced.
// If APIGroup is not specified, the specified Kind must be in the core API group.
// For any other third-party types, APIGroup is required.
// +optional
APIGroup *string `json:"apiGroup" protobuf:"bytes,1,opt,name=apiGroup"`
// Kind is the type of resource being referenced
Kind string `json:"kind" protobuf:"bytes,2,opt,name=kind"`
// Name is the name of resource being referenced

View File

@ -2211,7 +2211,7 @@ func (TopologySelectorTerm) SwaggerDoc() map[string]string {
var map_TypedLocalObjectReference = map[string]string{
"": "TypedLocalObjectReference contains enough information to let you locate the typed referenced object inside the same namespace.",
"apiGroup": "APIGroup is the group for the resource being referenced",
"apiGroup": "APIGroup is the group for the resource being referenced. If APIGroup is not specified, the specified Kind must be in the core API group. For any other third-party types, APIGroup is required.",
"kind": "Kind is the type of resource being referenced",
"name": "Name is the name of resource being referenced",
}

View File

@ -2687,7 +2687,7 @@ func (in *PersistentVolumeClaimSpec) DeepCopyInto(out *PersistentVolumeClaimSpec
if in.DataSource != nil {
in, out := &in.DataSource, &out.DataSource
*out = new(TypedLocalObjectReference)
**out = **in
(*in).DeepCopyInto(*out)
}
return
}
@ -5090,6 +5090,11 @@ func (in *TopologySelectorTerm) DeepCopy() *TopologySelectorTerm {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TypedLocalObjectReference) DeepCopyInto(out *TypedLocalObjectReference) {
*out = *in
if in.APIGroup != nil {
in, out := &in.APIGroup, &out.APIGroup
*out = new(string)
**out = **in
}
return
}