mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +00:00
Move ConfigMap to main API
This commit is contained in:
parent
454ebc4e30
commit
9030f16071
@ -1,4 +1,4 @@
|
||||
apiVersion: extensions/v1beta1
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: test-configmap
|
||||
|
@ -98,6 +98,8 @@ func AddToScheme(scheme *runtime.Scheme) {
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
&RangeAllocation{},
|
||||
&ConfigMap{},
|
||||
&ConfigMapList{},
|
||||
)
|
||||
|
||||
// Register Unversioned types under their own special group
|
||||
@ -172,3 +174,6 @@ func (obj *RangeAllocation) GetObjectMeta() meta.Object { r
|
||||
func (obj *RangeAllocation) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ObjectReference) GetObjectKind() unversioned.ObjectKind { return obj }
|
||||
func (obj *ExportOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMap) GetObjectMeta() meta.Object { return &obj.ObjectMeta }
|
||||
func (obj *ConfigMap) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMapList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -2150,6 +2150,25 @@ type SecretList struct {
|
||||
Items []Secret `json:"items"`
|
||||
}
|
||||
|
||||
// ConfigMap holds configuration data for components or applications to consume.
|
||||
type ConfigMap struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Data contains the configuration data.
|
||||
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
|
||||
Data map[string]string `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigMapList is a resource containing a list of ConfigMap objects.
|
||||
type ConfigMapList struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Items is the list of ConfigMaps.
|
||||
Items []ConfigMap `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// These constants are for remote command execution and port forwarding and are
|
||||
// used by both the client side and server side components.
|
||||
//
|
||||
|
@ -59,6 +59,7 @@ func addConversionFuncs(scheme *runtime.Scheme) {
|
||||
"PersistentVolumeClaim",
|
||||
"Service",
|
||||
"ServiceAccount",
|
||||
"ConfigMap",
|
||||
} {
|
||||
err = api.Scheme.AddFieldLabelConversionFunc("v1", kind,
|
||||
func(label, value string) (string, string, error) {
|
||||
|
@ -243,6 +243,11 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
|
||||
}
|
||||
}
|
||||
},
|
||||
func(obj *ConfigMap) {
|
||||
if obj.Data == nil {
|
||||
obj.Data = make(map[string]string)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,8 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&ComponentStatusList{},
|
||||
&SerializedReference{},
|
||||
&RangeAllocation{},
|
||||
&ConfigMap{},
|
||||
&ConfigMapList{},
|
||||
)
|
||||
|
||||
// Add common types
|
||||
@ -127,3 +129,5 @@ func (obj *ComponentStatusList) GetObjectKind() unversioned.ObjectKind { r
|
||||
func (obj *SerializedReference) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *RangeAllocation) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ExportOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMap) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMapList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -2566,6 +2566,29 @@ type SecretList struct {
|
||||
Items []Secret `json:"items"`
|
||||
}
|
||||
|
||||
// ConfigMap holds configuration data for pods to consume.
|
||||
type ConfigMap struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
// Standard object's metadata.
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Data contains the configuration data.
|
||||
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
|
||||
Data map[string]string `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigMapList is a resource containing a list of ConfigMap objects.
|
||||
type ConfigMapList struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Items is the list of ConfigMaps.
|
||||
Items []ConfigMap `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// Type and constants for component health validation.
|
||||
type ComponentConditionType string
|
||||
|
||||
|
@ -1987,6 +1987,36 @@ func ValidateSecretUpdate(newSecret, oldSecret *api.Secret) field.ErrorList {
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateConfigMapName can be used to check whether the given ConfigMap name is valid.
|
||||
// Prefix indicates this name will be used as part of generation, in which case
|
||||
// trailing dashes are allowed.
|
||||
func ValidateConfigMapName(name string, prefix bool) (bool, string) {
|
||||
return NameIsDNSSubdomain(name, prefix)
|
||||
}
|
||||
|
||||
// ValidateConfigMap tests whether required fields in the ConfigMap are set.
|
||||
func ValidateConfigMap(cfg *api.ConfigMap) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, ValidateObjectMeta(&cfg.ObjectMeta, true, ValidateConfigMapName, field.NewPath("metadata"))...)
|
||||
|
||||
for key := range cfg.Data {
|
||||
if !IsSecretKey(key) {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("data").Key(key), key, fmt.Sprintf("must have at most %d characters and match regex %s", validation.DNS1123SubdomainMaxLength, SecretKeyFmt)))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateConfigMapUpdate tests if required fields in the ConfigMap are set.
|
||||
func ValidateConfigMapUpdate(newCfg, oldCfg *api.ConfigMap) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newCfg.ObjectMeta, &oldCfg.ObjectMeta, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, ValidateConfigMap(newCfg)...)
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
func validateBasicResource(quantity resource.Quantity, fldPath *field.Path) field.ErrorList {
|
||||
if quantity.Value() < 0 {
|
||||
return field.ErrorList{field.Invalid(fldPath, quantity.Value(), "must be a valid resource quantity")}
|
||||
|
@ -4455,3 +4455,105 @@ func TestValidPodLogOptions(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateConfigMap(t *testing.T) {
|
||||
newConfigMap := func(name, namespace string, data map[string]string) api.ConfigMap {
|
||||
return api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
validConfigMap = newConfigMap("validname", "validns", map[string]string{"key": "value"})
|
||||
maxKeyLength = newConfigMap("validname", "validns", map[string]string{strings.Repeat("a", 253): "value"})
|
||||
|
||||
emptyName = newConfigMap("", "validns", nil)
|
||||
invalidName = newConfigMap("NoUppercaseOrSpecialCharsLike=Equals", "validns", nil)
|
||||
emptyNs = newConfigMap("validname", "", nil)
|
||||
invalidNs = newConfigMap("validname", "NoUppercaseOrSpecialCharsLike=Equals", nil)
|
||||
invalidKey = newConfigMap("validname", "validns", map[string]string{"a..b": "value"})
|
||||
leadingDotKey = newConfigMap("validname", "validns", map[string]string{".ab": "value"})
|
||||
dotKey = newConfigMap("validname", "validns", map[string]string{".": "value"})
|
||||
doubleDotKey = newConfigMap("validname", "validns", map[string]string{"..": "value"})
|
||||
overMaxKeyLength = newConfigMap("validname", "validns", map[string]string{strings.Repeat("a", 254): "value"})
|
||||
)
|
||||
|
||||
tests := map[string]struct {
|
||||
cfg api.ConfigMap
|
||||
isValid bool
|
||||
}{
|
||||
"valid": {validConfigMap, true},
|
||||
"max key length": {maxKeyLength, true},
|
||||
"leading dot key": {leadingDotKey, true},
|
||||
"empty name": {emptyName, false},
|
||||
"invalid name": {invalidName, false},
|
||||
"invalid key": {invalidKey, false},
|
||||
"empty namespace": {emptyNs, false},
|
||||
"invalid namespace": {invalidNs, false},
|
||||
"dot key": {dotKey, false},
|
||||
"double dot key": {doubleDotKey, false},
|
||||
"over max key length": {overMaxKeyLength, false},
|
||||
}
|
||||
|
||||
for name, tc := range tests {
|
||||
errs := ValidateConfigMap(&tc.cfg)
|
||||
if tc.isValid && len(errs) > 0 {
|
||||
t.Errorf("%v: unexpected error: %v", name, errs)
|
||||
}
|
||||
if !tc.isValid && len(errs) == 0 {
|
||||
t.Errorf("%v: unexpected non-error", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateConfigMapUpdate(t *testing.T) {
|
||||
newConfigMap := func(version, name, namespace string, data map[string]string) api.ConfigMap {
|
||||
return api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
ResourceVersion: version,
|
||||
},
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
validConfigMap = newConfigMap("1", "validname", "validns", map[string]string{"key": "value"})
|
||||
noVersion = newConfigMap("", "validname", "validns", map[string]string{"key": "value"})
|
||||
)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
newCfg api.ConfigMap
|
||||
oldCfg api.ConfigMap
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
name: "valid",
|
||||
newCfg: validConfigMap,
|
||||
oldCfg: validConfigMap,
|
||||
isValid: true,
|
||||
},
|
||||
{
|
||||
name: "invalid",
|
||||
newCfg: noVersion,
|
||||
oldCfg: validConfigMap,
|
||||
isValid: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
errs := ValidateConfigMapUpdate(&tc.newCfg, &tc.oldCfg)
|
||||
if tc.isValid && len(errs) > 0 {
|
||||
t.Errorf("%v: unexpected error: %v", tc.name, errs)
|
||||
}
|
||||
if !tc.isValid && len(errs) == 0 {
|
||||
t.Errorf("%v: unexpected non-error", tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,8 +66,6 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&Ingress{},
|
||||
&IngressList{},
|
||||
&api.ListOptions{},
|
||||
&ConfigMap{},
|
||||
&ConfigMapList{},
|
||||
&ReplicaSet{},
|
||||
&ReplicaSetList{},
|
||||
&api.ExportOptions{},
|
||||
@ -92,7 +90,5 @@ func (obj *ThirdPartyResourceData) GetObjectKind() unversioned.ObjectKind {
|
||||
func (obj *ThirdPartyResourceDataList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *Ingress) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *IngressList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMap) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMapList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -784,29 +784,6 @@ const (
|
||||
LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
|
||||
)
|
||||
|
||||
// ConfigMap holds configuration data for components or applications to consume.
|
||||
type ConfigMap struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
|
||||
api.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Data contains the configuration data.
|
||||
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
|
||||
Data map[string]string `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigMapList is a resource containing a list of ConfigMap objects.
|
||||
type ConfigMapList struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Items is the list of ConfigMaps.
|
||||
Items []ConfigMap `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// ReplicaSet represents the configuration of a replica set.
|
||||
type ReplicaSet struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
@ -54,7 +54,7 @@ func addConversionFuncs(scheme *runtime.Scheme) {
|
||||
}
|
||||
|
||||
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
|
||||
for _, kind := range []string{"ConfigMap", "DaemonSet", "Deployment", "Ingress"} {
|
||||
for _, kind := range []string{"DaemonSet", "Deployment", "Ingress"} {
|
||||
err = api.Scheme.AddFieldLabelConversionFunc("extensions/v1beta1", kind,
|
||||
func(label, value string) (string, string, error) {
|
||||
switch label {
|
||||
|
@ -142,11 +142,6 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
|
||||
obj.Spec.CPUUtilization = &CPUTargetUtilization{TargetPercentage: 80}
|
||||
}
|
||||
},
|
||||
func(obj *ConfigMap) {
|
||||
if obj.Data == nil {
|
||||
obj.Data = make(map[string]string)
|
||||
}
|
||||
},
|
||||
func(obj *ReplicaSet) {
|
||||
var labels map[string]string
|
||||
if obj.Spec.Template != nil {
|
||||
|
@ -56,8 +56,6 @@ func addKnownTypes(scheme *runtime.Scheme) {
|
||||
&Ingress{},
|
||||
&IngressList{},
|
||||
&ListOptions{},
|
||||
&ConfigMap{},
|
||||
&ConfigMapList{},
|
||||
&v1.DeleteOptions{},
|
||||
&ReplicaSet{},
|
||||
&ReplicaSetList{},
|
||||
@ -83,7 +81,5 @@ func (obj *ThirdPartyResourceDataList) GetObjectKind() unversioned.ObjectKind {
|
||||
func (obj *Ingress) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *IngressList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ListOptions) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMap) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ConfigMapList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSet) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
func (obj *ReplicaSetList) GetObjectKind() unversioned.ObjectKind { return &obj.TypeMeta }
|
||||
|
@ -809,29 +809,6 @@ const (
|
||||
LabelSelectorOpDoesNotExist LabelSelectorOperator = "DoesNotExist"
|
||||
)
|
||||
|
||||
// ConfigMap holds configuration data for pods to consume.
|
||||
type ConfigMap struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// Standard object metadata; More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata.
|
||||
v1.ObjectMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Data contains the configuration data.
|
||||
// Each key must be a valid DNS_SUBDOMAIN with an optional leading dot.
|
||||
Data map[string]string `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// ConfigMapList is a resource containing a list of ConfigMap objects.
|
||||
type ConfigMapList struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
||||
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
|
||||
unversioned.ListMeta `json:"metadata,omitempty"`
|
||||
|
||||
// Items is the list of ConfigMaps.
|
||||
Items []ConfigMap `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
// ReplicaSet represents the configuration of a ReplicaSet.
|
||||
type ReplicaSet struct {
|
||||
unversioned.TypeMeta `json:",inline"`
|
||||
|
@ -17,7 +17,6 @@ limitations under the License.
|
||||
package validation
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"regexp"
|
||||
"strconv"
|
||||
@ -629,35 +628,6 @@ func ValidateScale(scale *extensions.Scale) field.ErrorList {
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateConfigMapName can be used to check whether the given ConfigMap name is valid.
|
||||
// Prefix indicates this name will be used as part of generation, in which case
|
||||
// trailing dashes are allowed.
|
||||
func ValidateConfigMapName(name string, prefix bool) (bool, string) {
|
||||
return apivalidation.NameIsDNSSubdomain(name, prefix)
|
||||
}
|
||||
|
||||
// ValidateConfigMap tests whether required fields in the ConfigMap are set.
|
||||
func ValidateConfigMap(cfg *extensions.ConfigMap) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&cfg.ObjectMeta, true, ValidateConfigMapName, field.NewPath("metadata"))...)
|
||||
|
||||
for key := range cfg.Data {
|
||||
if !apivalidation.IsSecretKey(key) {
|
||||
allErrs = append(allErrs, field.Invalid(field.NewPath("data").Key(key), key, fmt.Sprintf("must have at most %d characters and match regex %s", validation.DNS1123SubdomainMaxLength, apivalidation.SecretKeyFmt)))
|
||||
}
|
||||
}
|
||||
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateConfigMapUpdate tests if required fields in the ConfigMap are set.
|
||||
func ValidateConfigMapUpdate(newCfg, oldCfg *extensions.ConfigMap) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&newCfg.ObjectMeta, &oldCfg.ObjectMeta, field.NewPath("metadata"))...)
|
||||
allErrs = append(allErrs, ValidateConfigMap(newCfg)...)
|
||||
return allErrs
|
||||
}
|
||||
|
||||
// ValidateReplicaSetName can be used to check whether the given ReplicaSet
|
||||
// name is valid.
|
||||
// Prefix indicates this name will be used as part of generation, in which case
|
||||
|
@ -1458,108 +1458,6 @@ func TestValidateScale(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateConfigMap(t *testing.T) {
|
||||
newConfigMap := func(name, namespace string, data map[string]string) extensions.ConfigMap {
|
||||
return extensions.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
},
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
validConfigMap = newConfigMap("validname", "validns", map[string]string{"key": "value"})
|
||||
maxKeyLength = newConfigMap("validname", "validns", map[string]string{strings.Repeat("a", 253): "value"})
|
||||
|
||||
emptyName = newConfigMap("", "validns", nil)
|
||||
invalidName = newConfigMap("NoUppercaseOrSpecialCharsLike=Equals", "validns", nil)
|
||||
emptyNs = newConfigMap("validname", "", nil)
|
||||
invalidNs = newConfigMap("validname", "NoUppercaseOrSpecialCharsLike=Equals", nil)
|
||||
invalidKey = newConfigMap("validname", "validns", map[string]string{"a..b": "value"})
|
||||
leadingDotKey = newConfigMap("validname", "validns", map[string]string{".ab": "value"})
|
||||
dotKey = newConfigMap("validname", "validns", map[string]string{".": "value"})
|
||||
doubleDotKey = newConfigMap("validname", "validns", map[string]string{"..": "value"})
|
||||
overMaxKeyLength = newConfigMap("validname", "validns", map[string]string{strings.Repeat("a", 254): "value"})
|
||||
)
|
||||
|
||||
tests := map[string]struct {
|
||||
cfg extensions.ConfigMap
|
||||
isValid bool
|
||||
}{
|
||||
"valid": {validConfigMap, true},
|
||||
"max key length": {maxKeyLength, true},
|
||||
"leading dot key": {leadingDotKey, true},
|
||||
"empty name": {emptyName, false},
|
||||
"invalid name": {invalidName, false},
|
||||
"invalid key": {invalidKey, false},
|
||||
"empty namespace": {emptyNs, false},
|
||||
"invalid namespace": {invalidNs, false},
|
||||
"dot key": {dotKey, false},
|
||||
"double dot key": {doubleDotKey, false},
|
||||
"over max key length": {overMaxKeyLength, false},
|
||||
}
|
||||
|
||||
for name, tc := range tests {
|
||||
errs := ValidateConfigMap(&tc.cfg)
|
||||
if tc.isValid && len(errs) > 0 {
|
||||
t.Errorf("%v: unexpected error: %v", name, errs)
|
||||
}
|
||||
if !tc.isValid && len(errs) == 0 {
|
||||
t.Errorf("%v: unexpected non-error", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateConfigMapUpdate(t *testing.T) {
|
||||
newConfigMap := func(version, name, namespace string, data map[string]string) extensions.ConfigMap {
|
||||
return extensions.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
Namespace: namespace,
|
||||
ResourceVersion: version,
|
||||
},
|
||||
Data: data,
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
validConfigMap = newConfigMap("1", "validname", "validns", map[string]string{"key": "value"})
|
||||
noVersion = newConfigMap("", "validname", "validns", map[string]string{"key": "value"})
|
||||
)
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
newCfg extensions.ConfigMap
|
||||
oldCfg extensions.ConfigMap
|
||||
isValid bool
|
||||
}{
|
||||
{
|
||||
name: "valid",
|
||||
newCfg: validConfigMap,
|
||||
oldCfg: validConfigMap,
|
||||
isValid: true,
|
||||
},
|
||||
{
|
||||
name: "invalid",
|
||||
newCfg: noVersion,
|
||||
oldCfg: validConfigMap,
|
||||
isValid: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
errs := ValidateConfigMapUpdate(&tc.newCfg, &tc.oldCfg)
|
||||
if tc.isValid && len(errs) > 0 {
|
||||
t.Errorf("%v: unexpected error: %v", tc.name, errs)
|
||||
}
|
||||
if !tc.isValid && len(errs) == 0 {
|
||||
t.Errorf("%v: unexpected non-error", tc.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateReplicaSetStatusUpdate(t *testing.T) {
|
||||
validLabels := map[string]string{"a": "b"}
|
||||
validPodTemplate := api.PodTemplate{
|
||||
|
@ -40,6 +40,7 @@ type Interface interface {
|
||||
PersistentVolumesInterface
|
||||
PersistentVolumeClaimsNamespacer
|
||||
ComponentStatusesInterface
|
||||
ConfigMapsNamespacer
|
||||
Extensions() ExtensionsInterface
|
||||
Discovery() DiscoveryInterface
|
||||
}
|
||||
@ -103,6 +104,10 @@ func (c *Client) ComponentStatuses() ComponentStatusInterface {
|
||||
return newComponentStatuses(c)
|
||||
}
|
||||
|
||||
func (c *Client) ConfigMaps(namespace string) ConfigMapsInterface {
|
||||
return newConfigMaps(c, namespace)
|
||||
}
|
||||
|
||||
// Client is the implementation of a Kubernetes client.
|
||||
type Client struct {
|
||||
*RESTClient
|
||||
|
@ -18,7 +18,6 @@ package unversioned
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
@ -31,31 +30,31 @@ type ConfigMapsNamespacer interface {
|
||||
}
|
||||
|
||||
type ConfigMapsInterface interface {
|
||||
Get(string) (*extensions.ConfigMap, error)
|
||||
List(opts api.ListOptions) (*extensions.ConfigMapList, error)
|
||||
Create(*extensions.ConfigMap) (*extensions.ConfigMap, error)
|
||||
Get(string) (*api.ConfigMap, error)
|
||||
List(opts api.ListOptions) (*api.ConfigMapList, error)
|
||||
Create(*api.ConfigMap) (*api.ConfigMap, error)
|
||||
Delete(string) error
|
||||
Update(*extensions.ConfigMap) (*extensions.ConfigMap, error)
|
||||
Update(*api.ConfigMap) (*api.ConfigMap, error)
|
||||
Watch(api.ListOptions) (watch.Interface, error)
|
||||
}
|
||||
|
||||
type ConfigMaps struct {
|
||||
client *ExtensionsClient
|
||||
client *Client
|
||||
namespace string
|
||||
}
|
||||
|
||||
// ConfigMaps should implement ConfigMapsInterface
|
||||
var _ ConfigMapsInterface = &ConfigMaps{}
|
||||
|
||||
func newConfigMaps(c *ExtensionsClient, ns string) *ConfigMaps {
|
||||
func newConfigMaps(c *Client, ns string) *ConfigMaps {
|
||||
return &ConfigMaps{
|
||||
client: c,
|
||||
namespace: ns,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *ConfigMaps) Get(name string) (*extensions.ConfigMap, error) {
|
||||
result := &extensions.ConfigMap{}
|
||||
func (c *ConfigMaps) Get(name string) (*api.ConfigMap, error) {
|
||||
result := &api.ConfigMap{}
|
||||
err := c.client.Get().
|
||||
Namespace(c.namespace).
|
||||
Resource(ConfigMapResourceName).
|
||||
@ -66,8 +65,8 @@ func (c *ConfigMaps) Get(name string) (*extensions.ConfigMap, error) {
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (c *ConfigMaps) List(opts api.ListOptions) (*extensions.ConfigMapList, error) {
|
||||
result := &extensions.ConfigMapList{}
|
||||
func (c *ConfigMaps) List(opts api.ListOptions) (*api.ConfigMapList, error) {
|
||||
result := &api.ConfigMapList{}
|
||||
err := c.client.Get().
|
||||
Namespace(c.namespace).
|
||||
Resource(ConfigMapResourceName).
|
||||
@ -78,8 +77,8 @@ func (c *ConfigMaps) List(opts api.ListOptions) (*extensions.ConfigMapList, erro
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (c *ConfigMaps) Create(cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) {
|
||||
result := &extensions.ConfigMap{}
|
||||
func (c *ConfigMaps) Create(cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
result := &api.ConfigMap{}
|
||||
err := c.client.Post().
|
||||
Namespace(c.namespace).
|
||||
Resource(ConfigMapResourceName).
|
||||
@ -99,8 +98,8 @@ func (c *ConfigMaps) Delete(name string) error {
|
||||
Error()
|
||||
}
|
||||
|
||||
func (c *ConfigMaps) Update(cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) {
|
||||
result := &extensions.ConfigMap{}
|
||||
func (c *ConfigMaps) Update(cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
result := &api.ConfigMap{}
|
||||
|
||||
err := c.client.Put().
|
||||
Namespace(c.namespace).
|
||||
|
@ -34,7 +34,6 @@ type ExtensionsInterface interface {
|
||||
JobsNamespacer
|
||||
IngressNamespacer
|
||||
ThirdPartyResourceNamespacer
|
||||
ConfigMapsNamespacer
|
||||
}
|
||||
|
||||
// ExtensionsClient is used to interact with experimental Kubernetes features.
|
||||
@ -68,10 +67,6 @@ func (c *ExtensionsClient) Ingress(namespace string) IngressInterface {
|
||||
return newIngress(c, namespace)
|
||||
}
|
||||
|
||||
func (c *ExtensionsClient) ConfigMaps(namespace string) ConfigMapsInterface {
|
||||
return newConfigMaps(c, namespace)
|
||||
}
|
||||
|
||||
func (c *ExtensionsClient) ThirdPartyResources(namespace string) ThirdPartyResourceInterface {
|
||||
return newThirdPartyResources(c, namespace)
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package testclient
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
@ -29,48 +28,48 @@ const (
|
||||
// FakeConfigMaps implements ConfigMapInterface. Meant to be embedded into a struct to get a default
|
||||
// implementation. This makes faking out just the method you want to test easier.
|
||||
type FakeConfigMaps struct {
|
||||
Fake *FakeExperimental
|
||||
Fake *Fake
|
||||
Namespace string
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Get(name string) (*extensions.ConfigMap, error) {
|
||||
obj, err := c.Fake.Invokes(NewGetAction(configMapResourceName, c.Namespace, name), &extensions.ConfigMap{})
|
||||
func (c *FakeConfigMaps) Get(name string) (*api.ConfigMap, error) {
|
||||
obj, err := c.Fake.Invokes(NewGetAction(configMapResourceName, c.Namespace, name), &api.ConfigMap{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMap), err
|
||||
return obj.(*api.ConfigMap), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) List(opts api.ListOptions) (*extensions.ConfigMapList, error) {
|
||||
obj, err := c.Fake.Invokes(NewListAction(configMapResourceName, c.Namespace, opts), &extensions.ConfigMapList{})
|
||||
func (c *FakeConfigMaps) List(opts api.ListOptions) (*api.ConfigMapList, error) {
|
||||
obj, err := c.Fake.Invokes(NewListAction(configMapResourceName, c.Namespace, opts), &api.ConfigMapList{})
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMapList), err
|
||||
return obj.(*api.ConfigMapList), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Create(cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) {
|
||||
func (c *FakeConfigMaps) Create(cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
obj, err := c.Fake.Invokes(NewCreateAction(configMapResourceName, c.Namespace, cfg), cfg)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMap), err
|
||||
return obj.(*api.ConfigMap), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Update(cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) {
|
||||
func (c *FakeConfigMaps) Update(cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
obj, err := c.Fake.Invokes(NewUpdateAction(configMapResourceName, c.Namespace, cfg), cfg)
|
||||
if obj == nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMap), err
|
||||
return obj.(*api.ConfigMap), err
|
||||
}
|
||||
|
||||
func (c *FakeConfigMaps) Delete(name string) error {
|
||||
_, err := c.Fake.Invokes(NewDeleteAction(configMapResourceName, c.Namespace, name), &extensions.ConfigMap{})
|
||||
_, err := c.Fake.Invokes(NewDeleteAction(configMapResourceName, c.Namespace, name), &api.ConfigMap{})
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -282,6 +282,10 @@ func (c *Fake) ComponentStatuses() client.ComponentStatusInterface {
|
||||
return &FakeComponentStatuses{Fake: c}
|
||||
}
|
||||
|
||||
func (c *Fake) ConfigMaps(namespace string) client.ConfigMapsInterface {
|
||||
return &FakeConfigMaps{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
// SwaggerSchema returns an empty swagger.ApiDeclaration for testing
|
||||
func (c *Fake) SwaggerSchema(version unversioned.GroupVersion) (*swagger.ApiDeclaration, error) {
|
||||
action := ActionImpl{}
|
||||
@ -329,10 +333,6 @@ func (c *FakeExperimental) Ingress(namespace string) client.IngressInterface {
|
||||
return &FakeIngress{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *FakeExperimental) ConfigMaps(namespace string) client.ConfigMapsInterface {
|
||||
return &FakeConfigMaps{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
||||
func (c *FakeExperimental) ThirdPartyResources(namespace string) client.ThirdPartyResourceInterface {
|
||||
return &FakeThirdPartyResources{Fake: c, Namespace: namespace}
|
||||
}
|
||||
|
@ -84,13 +84,13 @@ func describerMap(c *client.Client) map[unversioned.GroupKind]Describer {
|
||||
api.Kind("PersistentVolumeClaim"): &PersistentVolumeClaimDescriber{c},
|
||||
api.Kind("Namespace"): &NamespaceDescriber{c},
|
||||
api.Kind("Endpoints"): &EndpointsDescriber{c},
|
||||
api.Kind("ConfigMap"): &ConfigMapDescriber{c},
|
||||
|
||||
extensions.Kind("HorizontalPodAutoscaler"): &HorizontalPodAutoscalerDescriber{c},
|
||||
extensions.Kind("DaemonSet"): &DaemonSetDescriber{c},
|
||||
extensions.Kind("Job"): &JobDescriber{c},
|
||||
extensions.Kind("Deployment"): &DeploymentDescriber{c},
|
||||
extensions.Kind("Ingress"): &IngressDescriber{c},
|
||||
extensions.Kind("ConfigMap"): &ConfigMapDescriber{c},
|
||||
}
|
||||
|
||||
return m
|
||||
@ -1709,7 +1709,7 @@ type ConfigMapDescriber struct {
|
||||
}
|
||||
|
||||
func (d *ConfigMapDescriber) Describe(namespace, name string) (string, error) {
|
||||
c := d.Extensions().ConfigMaps(namespace)
|
||||
c := d.ConfigMaps(namespace)
|
||||
|
||||
configMap, err := c.Get(name)
|
||||
if err != nil {
|
||||
@ -1719,7 +1719,7 @@ func (d *ConfigMapDescriber) Describe(namespace, name string) (string, error) {
|
||||
return describeConfigMap(configMap)
|
||||
}
|
||||
|
||||
func describeConfigMap(configMap *extensions.ConfigMap) (string, error) {
|
||||
func describeConfigMap(configMap *api.ConfigMap) (string, error) {
|
||||
return tabbedString(func(out io.Writer) error {
|
||||
fmt.Fprintf(out, "Name:\t%s\n", configMap.Name)
|
||||
fmt.Fprintf(out, "Namespace:\t%s\n", configMap.Namespace)
|
||||
|
@ -1451,7 +1451,7 @@ func printHorizontalPodAutoscalerList(list *extensions.HorizontalPodAutoscalerLi
|
||||
return nil
|
||||
}
|
||||
|
||||
func printConfigMap(configMap *extensions.ConfigMap, w io.Writer, options printOptions) error {
|
||||
func printConfigMap(configMap *api.ConfigMap, w io.Writer, options printOptions) error {
|
||||
name := configMap.Name
|
||||
namespace := configMap.Namespace
|
||||
|
||||
@ -1467,7 +1467,7 @@ func printConfigMap(configMap *extensions.ConfigMap, w io.Writer, options printO
|
||||
return err
|
||||
}
|
||||
|
||||
func printConfigMapList(list *extensions.ConfigMapList, w io.Writer, options printOptions) error {
|
||||
func printConfigMapList(list *api.ConfigMapList, w io.Writer, options printOptions) error {
|
||||
for i := range list.Items {
|
||||
if err := printConfigMap(&list.Items[i], w, options); err != nil {
|
||||
return err
|
||||
|
@ -39,7 +39,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api/resource"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/api/validation"
|
||||
apiextensions "k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/client/cache"
|
||||
"k8s.io/kubernetes/pkg/client/record"
|
||||
client "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
@ -1364,7 +1363,7 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
|
||||
// 3. Add remaining service environment vars
|
||||
var (
|
||||
tmpEnv = make(map[string]string)
|
||||
configMaps = make(map[string]*apiextensions.ConfigMap)
|
||||
configMaps = make(map[string]*api.ConfigMap)
|
||||
secrets = make(map[string]*api.Secret)
|
||||
mappingFunc = expansion.MappingFuncFor(tmpEnv, serviceEnv)
|
||||
)
|
||||
@ -1393,7 +1392,7 @@ func (kl *Kubelet) makeEnvironmentVariables(pod *api.Pod, container *api.Contain
|
||||
key := envVar.ValueFrom.ConfigMapKeyRef.Key
|
||||
configMap, ok := configMaps[name]
|
||||
if !ok {
|
||||
configMap, err = kl.kubeClient.Extensions().ConfigMaps(pod.Namespace).Get(name)
|
||||
configMap, err = kl.kubeClient.ConfigMaps(pod.Namespace).Get(name)
|
||||
if err != nil {
|
||||
return result, err
|
||||
}
|
||||
|
@ -274,6 +274,7 @@ func (m *Master) initV1ResourcesStorage(c *Config) {
|
||||
serviceAccountStorage := serviceaccountetcd.NewREST(dbClient("serviceAccounts"), storageDecorator)
|
||||
persistentVolumeStorage, persistentVolumeStatusStorage := pvetcd.NewREST(dbClient("persistentVolumes"), storageDecorator)
|
||||
persistentVolumeClaimStorage, persistentVolumeClaimStatusStorage := pvcetcd.NewREST(dbClient("persistentVolumeClaims"), storageDecorator)
|
||||
configMapStorage := configmapetcd.NewREST(dbClient("configMaps"), storageDecorator)
|
||||
|
||||
namespaceStorage, namespaceStatusStorage, namespaceFinalizeStorage := namespaceetcd.NewREST(dbClient("namespaces"), storageDecorator)
|
||||
m.namespaceRegistry = namespace.NewRegistry(namespaceStorage)
|
||||
@ -352,6 +353,7 @@ func (m *Master) initV1ResourcesStorage(c *Config) {
|
||||
"persistentVolumes/status": persistentVolumeStatusStorage,
|
||||
"persistentVolumeClaims": persistentVolumeClaimStorage,
|
||||
"persistentVolumeClaims/status": persistentVolumeClaimStatusStorage,
|
||||
"configMaps": configMapStorage,
|
||||
|
||||
"componentStatuses": componentstatus.NewStorage(func() map[string]apiserver.Server { return m.getServersToValidate(c) }),
|
||||
}
|
||||
@ -569,7 +571,7 @@ func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupV
|
||||
// getExperimentalResources returns the resources for extenstions api
|
||||
func (m *Master) getExtensionResources(c *Config) map[string]rest.Storage {
|
||||
// All resources except these are disabled by default.
|
||||
enabledResources := sets.NewString("jobs", "horizontalpodautoscalers", "ingresses", "configmaps")
|
||||
enabledResources := sets.NewString("jobs", "horizontalpodautoscalers", "ingresses")
|
||||
resourceOverrides := m.ApiGroupVersionOverrides["extensions/v1beta1"].ResourceOverrides
|
||||
isEnabled := func(resource string) bool {
|
||||
// Check if the resource has been overriden.
|
||||
@ -631,9 +633,6 @@ func (m *Master) getExtensionResources(c *Config) map[string]rest.Storage {
|
||||
storage["ingresses"] = ingressStorage
|
||||
storage["ingresses/status"] = ingressStatusStorage
|
||||
}
|
||||
if isEnabled("configmaps") {
|
||||
storage["configmaps"] = configmapetcd.NewREST(dbClient("configmaps"), storageDecorator)
|
||||
}
|
||||
|
||||
return storage
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ package etcd
|
||||
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/registry/configmap"
|
||||
"k8s.io/kubernetes/pkg/registry/generic"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
@ -36,13 +35,13 @@ type REST struct {
|
||||
func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) *REST {
|
||||
prefix := "/configmaps"
|
||||
|
||||
newListFunc := func() runtime.Object { return &extensions.ConfigMapList{} }
|
||||
newListFunc := func() runtime.Object { return &api.ConfigMapList{} }
|
||||
storageInterface := storageDecorator(
|
||||
s, 100, &extensions.ConfigMap{}, prefix, false, newListFunc)
|
||||
s, 100, &api.ConfigMap{}, prefix, false, newListFunc)
|
||||
|
||||
store := &etcdgeneric.Etcd{
|
||||
NewFunc: func() runtime.Object {
|
||||
return &extensions.ConfigMap{}
|
||||
return &api.ConfigMap{}
|
||||
},
|
||||
|
||||
// NewListFunc returns an object to store results of an etcd list.
|
||||
@ -62,13 +61,13 @@ func NewREST(s storage.Interface, storageDecorator generic.StorageDecorator) *RE
|
||||
|
||||
// Retrieves the name field of a ConfigMap object.
|
||||
ObjectNameFunc: func(obj runtime.Object) (string, error) {
|
||||
return obj.(*extensions.ConfigMap).Name, nil
|
||||
return obj.(*api.ConfigMap).Name, nil
|
||||
},
|
||||
|
||||
// Matches objects based on labels/fields for list and watch
|
||||
PredicateFunc: configmap.MatchConfigMap,
|
||||
|
||||
QualifiedResource: extensions.Resource("configmaps"),
|
||||
QualifiedResource: api.Resource("configmaps"),
|
||||
|
||||
CreateStrategy: configmap.Strategy,
|
||||
UpdateStrategy: configmap.Strategy,
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/registry/generic"
|
||||
@ -30,12 +29,12 @@ import (
|
||||
)
|
||||
|
||||
func newStorage(t *testing.T) (*REST, *etcdtesting.EtcdTestServer) {
|
||||
etcdStorage, server := registrytest.NewEtcdStorage(t, "extensions")
|
||||
etcdStorage, server := registrytest.NewEtcdStorage(t, "")
|
||||
return NewREST(etcdStorage, generic.UndecoratedStorage), server
|
||||
}
|
||||
|
||||
func validNewConfigMap() *extensions.ConfigMap {
|
||||
return &extensions.ConfigMap{
|
||||
func validNewConfigMap() *api.ConfigMap {
|
||||
return &api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "foo",
|
||||
Namespace: "default",
|
||||
@ -62,13 +61,13 @@ func TestCreate(t *testing.T) {
|
||||
|
||||
test.TestCreate(
|
||||
validConfigMap,
|
||||
&extensions.ConfigMap{
|
||||
&api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{Name: "badName"},
|
||||
Data: map[string]string{
|
||||
"key": "value",
|
||||
},
|
||||
},
|
||||
&extensions.ConfigMap{
|
||||
&api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{Name: "name-2"},
|
||||
Data: map[string]string{
|
||||
"..dotfile": "do: nothing\n",
|
||||
@ -86,13 +85,13 @@ func TestUpdate(t *testing.T) {
|
||||
validNewConfigMap(),
|
||||
// updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
cfg := obj.(*extensions.ConfigMap)
|
||||
cfg := obj.(*api.ConfigMap)
|
||||
cfg.Data["update-test"] = "value"
|
||||
return cfg
|
||||
},
|
||||
// invalid updateFunc
|
||||
func(obj runtime.Object) runtime.Object {
|
||||
cfg := obj.(*extensions.ConfigMap)
|
||||
cfg := obj.(*api.ConfigMap)
|
||||
cfg.Data["badKey"] = "value"
|
||||
return cfg
|
||||
},
|
||||
|
@ -19,17 +19,16 @@ package configmap
|
||||
import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/watch"
|
||||
)
|
||||
|
||||
// Registry is an interface for things that know how to store ConfigMaps.
|
||||
type Registry interface {
|
||||
ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error)
|
||||
ListConfigMaps(ctx api.Context, options *api.ListOptions) (*api.ConfigMapList, error)
|
||||
WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error)
|
||||
GetConfigMap(ctx api.Context, name string) (*extensions.ConfigMap, error)
|
||||
CreateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error)
|
||||
UpdateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error)
|
||||
GetConfigMap(ctx api.Context, name string) (*api.ConfigMap, error)
|
||||
CreateConfigMap(ctx api.Context, cfg *api.ConfigMap) (*api.ConfigMap, error)
|
||||
UpdateConfigMap(ctx api.Context, cfg *api.ConfigMap) (*api.ConfigMap, error)
|
||||
DeleteConfigMap(ctx api.Context, name string) error
|
||||
}
|
||||
|
||||
@ -44,44 +43,44 @@ func NewRegistry(s rest.StandardStorage) Registry {
|
||||
return &storage{s}
|
||||
}
|
||||
|
||||
func (s *storage) ListConfigMaps(ctx api.Context, options *api.ListOptions) (*extensions.ConfigMapList, error) {
|
||||
func (s *storage) ListConfigMaps(ctx api.Context, options *api.ListOptions) (*api.ConfigMapList, error) {
|
||||
obj, err := s.List(ctx, options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMapList), err
|
||||
return obj.(*api.ConfigMapList), err
|
||||
}
|
||||
|
||||
func (s *storage) WatchConfigMaps(ctx api.Context, options *api.ListOptions) (watch.Interface, error) {
|
||||
return s.Watch(ctx, options)
|
||||
}
|
||||
|
||||
func (s *storage) GetConfigMap(ctx api.Context, name string) (*extensions.ConfigMap, error) {
|
||||
func (s *storage) GetConfigMap(ctx api.Context, name string) (*api.ConfigMap, error) {
|
||||
obj, err := s.Get(ctx, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMap), nil
|
||||
return obj.(*api.ConfigMap), nil
|
||||
}
|
||||
|
||||
func (s *storage) CreateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) {
|
||||
func (s *storage) CreateConfigMap(ctx api.Context, cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
obj, err := s.Create(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMap), nil
|
||||
return obj.(*api.ConfigMap), nil
|
||||
}
|
||||
|
||||
func (s *storage) UpdateConfigMap(ctx api.Context, cfg *extensions.ConfigMap) (*extensions.ConfigMap, error) {
|
||||
func (s *storage) UpdateConfigMap(ctx api.Context, cfg *api.ConfigMap) (*api.ConfigMap, error) {
|
||||
obj, _, err := s.Update(ctx, cfg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return obj.(*extensions.ConfigMap), nil
|
||||
return obj.(*api.ConfigMap), nil
|
||||
}
|
||||
|
||||
func (s *storage) DeleteConfigMap(ctx api.Context, name string) error {
|
||||
|
@ -21,8 +21,7 @@ import (
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/rest"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions/validation"
|
||||
"k8s.io/kubernetes/pkg/api/validation"
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/registry/generic"
|
||||
@ -51,11 +50,11 @@ func (strategy) NamespaceScoped() bool {
|
||||
}
|
||||
|
||||
func (strategy) PrepareForCreate(obj runtime.Object) {
|
||||
_ = obj.(*extensions.ConfigMap)
|
||||
_ = obj.(*api.ConfigMap)
|
||||
}
|
||||
|
||||
func (strategy) Validate(ctx api.Context, obj runtime.Object) field.ErrorList {
|
||||
cfg := obj.(*extensions.ConfigMap)
|
||||
cfg := obj.(*api.ConfigMap)
|
||||
|
||||
return validation.ValidateConfigMap(cfg)
|
||||
}
|
||||
@ -69,8 +68,8 @@ func (strategy) AllowCreateOnUpdate() bool {
|
||||
}
|
||||
|
||||
func (strategy) PrepareForUpdate(newObj, oldObj runtime.Object) {
|
||||
_ = oldObj.(*extensions.ConfigMap)
|
||||
_ = newObj.(*extensions.ConfigMap)
|
||||
_ = oldObj.(*api.ConfigMap)
|
||||
_ = newObj.(*api.ConfigMap)
|
||||
}
|
||||
|
||||
func (strategy) AllowUnconditionalUpdate() bool {
|
||||
@ -78,13 +77,13 @@ func (strategy) AllowUnconditionalUpdate() bool {
|
||||
}
|
||||
|
||||
func (strategy) ValidateUpdate(ctx api.Context, newObj, oldObj runtime.Object) field.ErrorList {
|
||||
oldCfg, newCfg := oldObj.(*extensions.ConfigMap), newObj.(*extensions.ConfigMap)
|
||||
oldCfg, newCfg := oldObj.(*api.ConfigMap), newObj.(*api.ConfigMap)
|
||||
|
||||
return validation.ValidateConfigMapUpdate(newCfg, oldCfg)
|
||||
}
|
||||
|
||||
// ConfigMapToSelectableFields returns a field set that represents the object for matching purposes.
|
||||
func ConfigMapToSelectableFields(cfg *extensions.ConfigMap) fields.Set {
|
||||
func ConfigMapToSelectableFields(cfg *api.ConfigMap) fields.Set {
|
||||
return generic.ObjectMetaFieldsSet(cfg.ObjectMeta, true)
|
||||
}
|
||||
|
||||
@ -94,7 +93,7 @@ func MatchConfigMap(label labels.Selector, field fields.Selector) generic.Matche
|
||||
Label: label,
|
||||
Field: field,
|
||||
GetAttrs: func(obj runtime.Object) (labels.Set, fields.Set, error) {
|
||||
cfg, ok := obj.(*extensions.ConfigMap)
|
||||
cfg, ok := obj.(*api.ConfigMap)
|
||||
if !ok {
|
||||
return nil, nil, fmt.Errorf("given object is not of type ConfigMap")
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/api/testapi"
|
||||
apitesting "k8s.io/kubernetes/pkg/api/testing"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
)
|
||||
|
||||
@ -35,7 +34,7 @@ func TestConfigMapStrategy(t *testing.T) {
|
||||
t.Errorf("ConfigMap should not allow create on update")
|
||||
}
|
||||
|
||||
cfg := &extensions.ConfigMap{
|
||||
cfg := &api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "valid-config-data",
|
||||
Namespace: api.NamespaceDefault,
|
||||
@ -52,7 +51,7 @@ func TestConfigMapStrategy(t *testing.T) {
|
||||
t.Errorf("unexpected error validating %v", errs)
|
||||
}
|
||||
|
||||
newCfg := &extensions.ConfigMap{
|
||||
newCfg := &api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "valid-config-data-2",
|
||||
Namespace: api.NamespaceDefault,
|
||||
@ -73,9 +72,9 @@ func TestConfigMapStrategy(t *testing.T) {
|
||||
|
||||
func TestSelectableFieldLabelConversions(t *testing.T) {
|
||||
apitesting.TestSelectableFieldLabelConversionsOfKind(t,
|
||||
testapi.Extensions.GroupVersion().String(),
|
||||
testapi.Default.GroupVersion().String(),
|
||||
"ConfigMap",
|
||||
labels.Set(ConfigMapToSelectableFields(&extensions.ConfigMap{})),
|
||||
labels.Set(ConfigMapToSelectableFields(&api.ConfigMap{})),
|
||||
nil,
|
||||
)
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api"
|
||||
"k8s.io/kubernetes/pkg/apis/extensions"
|
||||
"k8s.io/kubernetes/pkg/util"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
@ -31,7 +30,7 @@ var _ = Describe("ConfigMap", func() {
|
||||
|
||||
It("should be consumable via environment variable [Conformance]", func() {
|
||||
name := "configmap-test-" + string(util.NewUUID())
|
||||
configMap := &extensions.ConfigMap{
|
||||
configMap := &api.ConfigMap{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Namespace: f.Namespace.Name,
|
||||
Name: name,
|
||||
@ -46,12 +45,12 @@ var _ = Describe("ConfigMap", func() {
|
||||
By(fmt.Sprintf("Creating configMap %v/%v", f.Namespace.Name, configMap.Name))
|
||||
defer func() {
|
||||
By("Cleaning up the configMap")
|
||||
if err := f.Client.Extensions().ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
|
||||
if err := f.Client.ConfigMaps(f.Namespace.Name).Delete(configMap.Name); err != nil {
|
||||
Failf("unable to delete configMap %v: %v", configMap.Name, err)
|
||||
}
|
||||
}()
|
||||
var err error
|
||||
if configMap, err = f.Client.Extensions().ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
|
||||
if configMap, err = f.Client.ConfigMaps(f.Namespace.Name).Create(configMap); err != nil {
|
||||
Failf("unable to create test configMap %s: %v", configMap.Name, err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user