...

Source file src/k8s.io/kubectl/pkg/polymorphichelpers/canbeexposed.go

Documentation: k8s.io/kubectl/pkg/polymorphichelpers

     1  /*
     2  Copyright 2018 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package polymorphichelpers
    18  
    19  import (
    20  	"fmt"
    21  
    22  	appsv1 "k8s.io/api/apps/v1"
    23  	corev1 "k8s.io/api/core/v1"
    24  	extensionsv1beta1 "k8s.io/api/extensions/v1beta1"
    25  	"k8s.io/apimachinery/pkg/runtime/schema"
    26  )
    27  
    28  // Check whether the kind of resources could be exposed
    29  func canBeExposed(kind schema.GroupKind) error {
    30  	switch kind {
    31  	case
    32  		corev1.SchemeGroupVersion.WithKind("ReplicationController").GroupKind(),
    33  		corev1.SchemeGroupVersion.WithKind("Service").GroupKind(),
    34  		corev1.SchemeGroupVersion.WithKind("Pod").GroupKind(),
    35  		appsv1.SchemeGroupVersion.WithKind("Deployment").GroupKind(),
    36  		appsv1.SchemeGroupVersion.WithKind("ReplicaSet").GroupKind(),
    37  		extensionsv1beta1.SchemeGroupVersion.WithKind("Deployment").GroupKind(),
    38  		extensionsv1beta1.SchemeGroupVersion.WithKind("ReplicaSet").GroupKind():
    39  		// nothing to do here
    40  	default:
    41  		return fmt.Errorf("cannot expose a %s", kind)
    42  	}
    43  	return nil
    44  }
    45  

View as plain text