...

Source file src/k8s.io/kubernetes/pkg/apis/storage/util/helpers.go

Documentation: k8s.io/kubernetes/pkg/apis/storage/util

     1  /*
     2  Copyright 2016 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 util
    18  
    19  import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    20  
    21  // IsDefaultStorageClassAnnotation represents a StorageClass annotation that
    22  // marks a class as the default StorageClass
    23  const IsDefaultStorageClassAnnotation = "storageclass.kubernetes.io/is-default-class"
    24  
    25  // BetaIsDefaultStorageClassAnnotation is the beta version of IsDefaultStorageClassAnnotation.
    26  // TODO: remove Beta when no longer used
    27  const BetaIsDefaultStorageClassAnnotation = "storageclass.beta.kubernetes.io/is-default-class"
    28  
    29  // AlphaIsDefaultVolumeAttributesClassAnnotation is the alpha version of IsDefaultVolumeAttributesClassAnnotation.
    30  const AlphaIsDefaultVolumeAttributesClassAnnotation = "volumeattributesclass.alpha.kubernetes.io/is-default-class"
    31  
    32  // IsDefaultAnnotation returns a boolean if
    33  // the annotation is set
    34  // TODO: remove Beta when no longer needed
    35  func IsDefaultAnnotation(obj metav1.ObjectMeta) bool {
    36  	if obj.Annotations[IsDefaultStorageClassAnnotation] == "true" {
    37  		return true
    38  	}
    39  	if obj.Annotations[BetaIsDefaultStorageClassAnnotation] == "true" {
    40  		return true
    41  	}
    42  
    43  	return false
    44  }
    45  
    46  // IsDefaultAnnotationForVolumeAttributesClass returns a boolean if
    47  // the annotation is set
    48  func IsDefaultAnnotationForVolumeAttributesClass(obj metav1.ObjectMeta) bool {
    49  	return obj.Annotations[AlphaIsDefaultVolumeAttributesClassAnnotation] == "true"
    50  }
    51  

View as plain text