mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Rename IsEmpty to Empty
Signed-off-by: Kara Alexandra <kalexandra@us.ibm.com>
This commit is contained in:
parent
5f7875a9bc
commit
d12a66a422
@ -329,9 +329,9 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource unversion
|
||||
}
|
||||
}
|
||||
switch {
|
||||
case !qualifiedResource.IsEmpty() && len(name) > 0:
|
||||
case !qualifiedResource.Empty() && len(name) > 0:
|
||||
message = fmt.Sprintf("%s (%s %s %s)", message, strings.ToLower(verb), qualifiedResource.String(), name)
|
||||
case !qualifiedResource.IsEmpty():
|
||||
case !qualifiedResource.Empty():
|
||||
message = fmt.Sprintf("%s (%s %s)", message, strings.ToLower(verb), qualifiedResource.String())
|
||||
}
|
||||
var causes []unversioned.StatusCause
|
||||
|
@ -183,7 +183,7 @@ func (m *DefaultRESTMapper) ResourceSingularizer(resourceType string) (string, e
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if singular.IsEmpty() {
|
||||
if singular.Empty() {
|
||||
singular = currSingular
|
||||
continue
|
||||
}
|
||||
@ -193,7 +193,7 @@ func (m *DefaultRESTMapper) ResourceSingularizer(resourceType string) (string, e
|
||||
}
|
||||
}
|
||||
|
||||
if singular.IsEmpty() {
|
||||
if singular.Empty() {
|
||||
return resourceType, fmt.Errorf("no singular of resource %v has been defined", resourceType)
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ func (gr GroupResource) WithVersion(version string) GroupVersionResource {
|
||||
return GroupVersionResource{Group: gr.Group, Version: version, Resource: gr.Resource}
|
||||
}
|
||||
|
||||
func (gr GroupResource) IsEmpty() bool {
|
||||
func (gr GroupResource) Empty() bool {
|
||||
return len(gr.Group) == 0 && len(gr.Resource) == 0
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ type GroupVersionResource struct {
|
||||
Resource string `protobuf:"bytes,3,opt,name=resource"`
|
||||
}
|
||||
|
||||
func (gvr GroupVersionResource) IsEmpty() bool {
|
||||
func (gvr GroupVersionResource) Empty() bool {
|
||||
return len(gvr.Group) == 0 && len(gvr.Version) == 0 && len(gvr.Resource) == 0
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ type GroupKind struct {
|
||||
Kind string `protobuf:"bytes,2,opt,name=kind"`
|
||||
}
|
||||
|
||||
func (gk GroupKind) IsEmpty() bool {
|
||||
func (gk GroupKind) Empty() bool {
|
||||
return len(gk.Group) == 0 && len(gk.Kind) == 0
|
||||
}
|
||||
|
||||
@ -131,8 +131,8 @@ type GroupVersionKind struct {
|
||||
Kind string `protobuf:"bytes,3,opt,name=kind"`
|
||||
}
|
||||
|
||||
// IsEmpty returns true if group, version, and kind are empty
|
||||
func (gvk GroupVersionKind) IsEmpty() bool {
|
||||
// Empty returns true if group, version, and kind are empty
|
||||
func (gvk GroupVersionKind) Empty() bool {
|
||||
return len(gvk.Group) == 0 && len(gvk.Version) == 0 && len(gvk.Kind) == 0
|
||||
}
|
||||
|
||||
@ -156,8 +156,8 @@ type GroupVersion struct {
|
||||
Version string `protobuf:"bytes,2,opt,name=version"`
|
||||
}
|
||||
|
||||
// IsEmpty returns true if group and version are empty
|
||||
func (gv GroupVersion) IsEmpty() bool {
|
||||
// Empty returns true if group and version are empty
|
||||
func (gv GroupVersion) Empty() bool {
|
||||
return len(gv.Group) == 0 && len(gv.Version) == 0
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ func (gv GroupVersion) IsEmpty() bool {
|
||||
// it returns "v1".
|
||||
func (gv GroupVersion) String() string {
|
||||
// special case the internal apiVersion for the legacy kube types
|
||||
if gv.IsEmpty() {
|
||||
if gv.Empty() {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ func (a *APIInstaller) getResourceKind(path string, storage rest.Storage) (unver
|
||||
fqKindToRegister = a.group.GroupVersion.WithKind(fqKind.Kind)
|
||||
}
|
||||
}
|
||||
if fqKindToRegister.IsEmpty() {
|
||||
if fqKindToRegister.Empty() {
|
||||
return unversioned.GroupVersionKind{}, fmt.Errorf("unable to locate fully qualified kind for %v: found %v when registering for %v", reflect.TypeOf(object), fqKinds, a.group.GroupVersion)
|
||||
}
|
||||
return fqKindToRegister, nil
|
||||
|
@ -234,7 +234,7 @@ func (d *DiscoveryClient) ServerVersion() (*version.Info, error) {
|
||||
|
||||
// SwaggerSchema retrieves and parses the swagger API schema the server supports.
|
||||
func (d *DiscoveryClient) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
if version.IsEmpty() {
|
||||
if version.Empty() {
|
||||
return nil, fmt.Errorf("groupVersion cannot be empty")
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
|
||||
if fullySpecifiedGVR != nil {
|
||||
gvk, _ = mapper.KindFor(*fullySpecifiedGVR)
|
||||
}
|
||||
if gvk.IsEmpty() {
|
||||
if gvk.Empty() {
|
||||
gvk, err = mapper.KindFor(groupResource.WithVersion(""))
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1270,10 +1270,10 @@ func (f *Factory) PrinterForMapping(cmd *cobra.Command, mapping *meta.RESTMappin
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if version.IsEmpty() && mapping != nil {
|
||||
if version.Empty() && mapping != nil {
|
||||
version = mapping.GroupVersionKind.GroupVersion()
|
||||
}
|
||||
if version.IsEmpty() {
|
||||
if version.Empty() {
|
||||
return nil, fmt.Errorf("you must specify an output-version when using this output format")
|
||||
}
|
||||
|
||||
|
@ -454,7 +454,7 @@ func (b *Builder) mappingFor(resourceArg string) (*meta.RESTMapping, error) {
|
||||
if fullySpecifiedGVR != nil {
|
||||
gvk, _ = b.mapper.KindFor(*fullySpecifiedGVR)
|
||||
}
|
||||
if gvk.IsEmpty() {
|
||||
if gvk.Empty() {
|
||||
var err error
|
||||
gvk, err = b.mapper.KindFor(groupResource.WithVersion(""))
|
||||
if err != nil {
|
||||
|
@ -250,7 +250,7 @@ func AsVersionedObjects(infos []*Info, version unversioned.GroupVersion, encoder
|
||||
|
||||
// objects that are not part of api.Scheme must be converted to JSON
|
||||
// TODO: convert to map[string]interface{}, attach to runtime.Unknown?
|
||||
if !version.IsEmpty() {
|
||||
if !version.Empty() {
|
||||
if _, _, err := api.Scheme.ObjectKinds(info.Object); runtime.IsNotRegisteredError(err) {
|
||||
// TODO: ideally this would encode to version, but we don't expose multiple codecs here.
|
||||
data, err := runtime.Encode(encoder, info.Object)
|
||||
@ -277,7 +277,7 @@ func AsVersionedObjects(infos []*Info, version unversioned.GroupVersion, encoder
|
||||
func tryConvert(converter runtime.ObjectConvertor, object runtime.Object, versions ...unversioned.GroupVersion) (runtime.Object, error) {
|
||||
var last error
|
||||
for _, version := range versions {
|
||||
if version.IsEmpty() {
|
||||
if version.Empty() {
|
||||
return object, nil
|
||||
}
|
||||
obj, err := converter.ConvertToVersion(object, version)
|
||||
|
@ -385,7 +385,7 @@ func (v FlattenListVisitor) Visit(fn VisitorFunc) error {
|
||||
|
||||
// If we have a GroupVersionKind on the list, prioritize that when asking for info on the objects contained in the list
|
||||
var preferredGVKs []unversioned.GroupVersionKind
|
||||
if info.Mapping != nil && !info.Mapping.GroupVersionKind.IsEmpty() {
|
||||
if info.Mapping != nil && !info.Mapping.GroupVersionKind.Empty() {
|
||||
preferredGVKs = append(preferredGVKs, info.Mapping.GroupVersionKind)
|
||||
}
|
||||
|
||||
|
@ -517,7 +517,7 @@ func (t *thirdPartyResourceDataEncoder) Encode(obj runtime.Object, stream io.Wri
|
||||
listItems[ix] = json.RawMessage(buff.Bytes())
|
||||
}
|
||||
|
||||
if t.gvk.IsEmpty() {
|
||||
if t.gvk.Empty() {
|
||||
return fmt.Errorf("thirdPartyResourceDataEncoder was not given a target version")
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ func (UnstructuredObjectConverter) Convert(in, out, context interface{}) error {
|
||||
}
|
||||
|
||||
func (UnstructuredObjectConverter) ConvertToVersion(in Object, target GroupVersioner) (Object, error) {
|
||||
if kind := in.GetObjectKind().GroupVersionKind(); !kind.IsEmpty() {
|
||||
if kind := in.GetObjectKind().GroupVersionKind(); !kind.Empty() {
|
||||
gvk, ok := target.KindForGroupVersionKinds([]unversioned.GroupVersionKind{kind})
|
||||
if !ok {
|
||||
// TODO: should this be a typed error?
|
||||
|
Loading…
Reference in New Issue
Block a user