pkg/apis/core: fixup package names

pull/6/head
Dr. Stefan Schimanski 2017-10-09 17:58:37 +02:00
parent 3848e0a478
commit 33b20f22ee
34 changed files with 5657 additions and 5658 deletions

View File

@ -10,22 +10,15 @@ cmd/kubelet/app
cmd/kubelet/app/options
cmd/kubemark
examples/guestbook-go
pkg/api
pkg/api/endpoints
pkg/api/helper
pkg/api/helper/qos
pkg/api/ref
pkg/api/testapi
pkg/api/testing
pkg/api/testing/compat
pkg/api/unversioned
pkg/api/v1/endpoints
pkg/api/v1/helper
pkg/api/v1/helper/qos
pkg/api/v1/pod
pkg/api/v1/resource
pkg/api/v1/validation
pkg/api/validation
pkg/apis/abac
pkg/apis/abac/latest
pkg/apis/admission
@ -51,6 +44,13 @@ pkg/apis/certificates/v1beta1
pkg/apis/certificates/validation
pkg/apis/componentconfig
pkg/apis/componentconfig/v1alpha1
pkg/apis/core
pkg/apis/core/helper
pkg/apis/core/helper/qos
pkg/apis/core/v1/helper
pkg/apis/core/v1/helper/qos
pkg/apis/core/v1/validation
pkg/apis/core/validation
pkg/apis/extensions
pkg/apis/extensions/validation
pkg/apis/imagepolicy

View File

@ -43,8 +43,7 @@ find_files() {
-o -wholename '*/vendor/*' \
\) -prune \
\) \
\( -wholename '*pkg/api/v*/types.go' \
-o -wholename '*pkg/apis/*/v*/types.go' \
\( -wholename '*pkg/apis/*/v*/types.go' \
-o -wholename '*pkg/api/unversioned/types.go' \
\)
}
@ -71,7 +70,7 @@ for file in $versioned_api_files; do
fi
done
internal_types_files="${KUBE_ROOT}/pkg/api/types.go ${KUBE_ROOT}/pkg/apis/extensions/types.go"
internal_types_files="${KUBE_ROOT}/pkg/apis/core/types.go ${KUBE_ROOT}/pkg/apis/extensions/types.go"
for internal_types_file in $internal_types_files; do
if [[ ! -e $internal_types_file ]]; then
echo "Internal types file ${internal_types_file} does not exist"

View File

@ -16,7 +16,7 @@ limitations under the License.
// This file should be consistent with pkg/api/v1/annotation_key_constants.go.
package api
package core
const (
// ImagePolicyFailedOpenKey is added to pods created by failing open when the image policy

View File

@ -21,4 +21,4 @@ limitations under the License.
// The contract presented to clients is located in the versioned packages,
// which are sub-directories. The first one is "v1". Those packages
// describe how a particular version is serialized to storage/network.
package api // import "k8s.io/kubernetes/pkg/api"
package core // import "k8s.io/kubernetes/pkg/apis/core"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package api
package core
// Field path constants that are specific to the internal API
// representation.

View File

@ -29,16 +29,16 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/core"
)
// Funcs returns the fuzzer functions for the core api group.
// Funcs returns the fuzzer functions for the core core group.
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
func(q *resource.Quantity, c fuzz.Continue) {
*q = *resource.NewQuantity(c.Int63n(1000), resource.DecimalExponent)
},
func(j *api.ObjectReference, c fuzz.Continue) {
func(j *core.ObjectReference, c fuzz.Continue) {
// We have to customize the randomization of TypeMetas because their
// APIVersion and Kind must remain blank in memory.
j.APIVersion = c.RandString()
@ -48,21 +48,21 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
j.ResourceVersion = strconv.FormatUint(c.RandUint64(), 10)
j.FieldPath = c.RandString()
},
func(j *api.ListOptions, c fuzz.Continue) {
func(j *core.ListOptions, c fuzz.Continue) {
label, _ := labels.Parse("a=b")
j.LabelSelector = label
field, _ := fields.ParseSelector("a=b")
j.FieldSelector = field
},
func(j *api.PodExecOptions, c fuzz.Continue) {
func(j *core.PodExecOptions, c fuzz.Continue) {
j.Stdout = true
j.Stderr = true
},
func(j *api.PodAttachOptions, c fuzz.Continue) {
func(j *core.PodAttachOptions, c fuzz.Continue) {
j.Stdout = true
j.Stderr = true
},
func(j *api.PodPortForwardOptions, c fuzz.Continue) {
func(j *core.PodPortForwardOptions, c fuzz.Continue) {
if c.RandBool() {
j.Ports = make([]int32, c.Intn(10))
for i := range j.Ports {
@ -70,7 +70,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
}
}
},
func(s *api.PodSpec, c fuzz.Continue) {
func(s *core.PodSpec, c fuzz.Continue) {
c.FuzzNoCustom(s)
// has a default value
ttl := int64(30)
@ -82,35 +82,35 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
c.Fuzz(s.SecurityContext)
if s.SecurityContext == nil {
s.SecurityContext = new(api.PodSecurityContext)
s.SecurityContext = new(core.PodSecurityContext)
}
if s.Affinity == nil {
s.Affinity = new(api.Affinity)
s.Affinity = new(core.Affinity)
}
if s.SchedulerName == "" {
s.SchedulerName = api.DefaultSchedulerName
s.SchedulerName = core.DefaultSchedulerName
}
},
func(j *api.PodPhase, c fuzz.Continue) {
statuses := []api.PodPhase{api.PodPending, api.PodRunning, api.PodFailed, api.PodUnknown}
func(j *core.PodPhase, c fuzz.Continue) {
statuses := []core.PodPhase{core.PodPending, core.PodRunning, core.PodFailed, core.PodUnknown}
*j = statuses[c.Rand.Intn(len(statuses))]
},
func(j *api.Binding, c fuzz.Continue) {
func(j *core.Binding, c fuzz.Continue) {
c.Fuzz(&j.ObjectMeta)
j.Target.Name = c.RandString()
},
func(j *api.ReplicationControllerSpec, c fuzz.Continue) {
func(j *core.ReplicationControllerSpec, c fuzz.Continue) {
c.FuzzNoCustom(j) // fuzz self without calling this function again
//j.TemplateRef = nil // this is required for round trip
},
func(j *api.List, c fuzz.Continue) {
func(j *core.List, c fuzz.Continue) {
c.FuzzNoCustom(j) // fuzz self without calling this function again
// TODO: uncomment when round trip starts from a versioned object
if false { //j.Items == nil {
j.Items = []runtime.Object{}
}
},
func(q *api.ResourceRequirements, c fuzz.Continue) {
func(q *core.ResourceRequirements, c fuzz.Continue) {
randomQuantity := func() resource.Quantity {
var q resource.Quantity
c.Fuzz(&q)
@ -118,52 +118,52 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
_ = q.String()
return q
}
q.Limits = make(api.ResourceList)
q.Requests = make(api.ResourceList)
q.Limits = make(core.ResourceList)
q.Requests = make(core.ResourceList)
cpuLimit := randomQuantity()
q.Limits[api.ResourceCPU] = *cpuLimit.Copy()
q.Requests[api.ResourceCPU] = *cpuLimit.Copy()
q.Limits[core.ResourceCPU] = *cpuLimit.Copy()
q.Requests[core.ResourceCPU] = *cpuLimit.Copy()
memoryLimit := randomQuantity()
q.Limits[api.ResourceMemory] = *memoryLimit.Copy()
q.Requests[api.ResourceMemory] = *memoryLimit.Copy()
q.Limits[core.ResourceMemory] = *memoryLimit.Copy()
q.Requests[core.ResourceMemory] = *memoryLimit.Copy()
storageLimit := randomQuantity()
q.Limits[api.ResourceStorage] = *storageLimit.Copy()
q.Requests[api.ResourceStorage] = *storageLimit.Copy()
q.Limits[core.ResourceStorage] = *storageLimit.Copy()
q.Requests[core.ResourceStorage] = *storageLimit.Copy()
},
func(q *api.LimitRangeItem, c fuzz.Continue) {
func(q *core.LimitRangeItem, c fuzz.Continue) {
var cpuLimit resource.Quantity
c.Fuzz(&cpuLimit)
q.Type = api.LimitTypeContainer
q.Default = make(api.ResourceList)
q.Default[api.ResourceCPU] = *(cpuLimit.Copy())
q.Type = core.LimitTypeContainer
q.Default = make(core.ResourceList)
q.Default[core.ResourceCPU] = *(cpuLimit.Copy())
q.DefaultRequest = make(api.ResourceList)
q.DefaultRequest[api.ResourceCPU] = *(cpuLimit.Copy())
q.DefaultRequest = make(core.ResourceList)
q.DefaultRequest[core.ResourceCPU] = *(cpuLimit.Copy())
q.Max = make(api.ResourceList)
q.Max[api.ResourceCPU] = *(cpuLimit.Copy())
q.Max = make(core.ResourceList)
q.Max[core.ResourceCPU] = *(cpuLimit.Copy())
q.Min = make(api.ResourceList)
q.Min[api.ResourceCPU] = *(cpuLimit.Copy())
q.Min = make(core.ResourceList)
q.Min[core.ResourceCPU] = *(cpuLimit.Copy())
q.MaxLimitRequestRatio = make(api.ResourceList)
q.MaxLimitRequestRatio[api.ResourceCPU] = resource.MustParse("10")
q.MaxLimitRequestRatio = make(core.ResourceList)
q.MaxLimitRequestRatio[core.ResourceCPU] = resource.MustParse("10")
},
func(p *api.PullPolicy, c fuzz.Continue) {
policies := []api.PullPolicy{api.PullAlways, api.PullNever, api.PullIfNotPresent}
func(p *core.PullPolicy, c fuzz.Continue) {
policies := []core.PullPolicy{core.PullAlways, core.PullNever, core.PullIfNotPresent}
*p = policies[c.Rand.Intn(len(policies))]
},
func(rp *api.RestartPolicy, c fuzz.Continue) {
policies := []api.RestartPolicy{api.RestartPolicyAlways, api.RestartPolicyNever, api.RestartPolicyOnFailure}
func(rp *core.RestartPolicy, c fuzz.Continue) {
policies := []core.RestartPolicy{core.RestartPolicyAlways, core.RestartPolicyNever, core.RestartPolicyOnFailure}
*rp = policies[c.Rand.Intn(len(policies))]
},
// api.DownwardAPIVolumeFile needs to have a specific func since FieldRef has to be
// core.DownwardAPIVolumeFile needs to have a specific func since FieldRef has to be
// defaulted to a version otherwise roundtrip will fail
func(m *api.DownwardAPIVolumeFile, c fuzz.Continue) {
func(m *core.DownwardAPIVolumeFile, c fuzz.Continue) {
m.Path = c.RandString()
versions := []string{"v1"}
m.FieldRef = &api.ObjectFieldSelector{}
m.FieldRef = &core.ObjectFieldSelector{}
m.FieldRef.APIVersion = versions[c.Rand.Intn(len(versions))]
m.FieldRef.FieldPath = c.RandString()
c.Fuzz(m.Mode)
@ -171,7 +171,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
*m.Mode &= 0777
}
},
func(s *api.SecretVolumeSource, c fuzz.Continue) {
func(s *core.SecretVolumeSource, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
if c.RandBool() {
@ -185,7 +185,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
mode &= 0777
s.DefaultMode = &mode
},
func(cm *api.ConfigMapVolumeSource, c fuzz.Continue) {
func(cm *core.ConfigMapVolumeSource, c fuzz.Continue) {
c.FuzzNoCustom(cm) // fuzz self without calling this function again
if c.RandBool() {
@ -199,7 +199,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
mode &= 0777
cm.DefaultMode = &mode
},
func(d *api.DownwardAPIVolumeSource, c fuzz.Continue) {
func(d *core.DownwardAPIVolumeSource, c fuzz.Continue) {
c.FuzzNoCustom(d) // fuzz self without calling this function again
// DefaultMode should always be set, it has a default
@ -209,7 +209,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
mode &= 0777
d.DefaultMode = &mode
},
func(s *api.ProjectedVolumeSource, c fuzz.Continue) {
func(s *core.ProjectedVolumeSource, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
// DefaultMode should always be set, it has a default
@ -219,7 +219,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
mode &= 0777
s.DefaultMode = &mode
},
func(k *api.KeyToPath, c fuzz.Continue) {
func(k *core.KeyToPath, c fuzz.Continue) {
c.FuzzNoCustom(k) // fuzz self without calling this function again
k.Key = c.RandString()
k.Path = c.RandString()
@ -230,7 +230,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
*k.Mode &= 0777
}
},
func(vs *api.VolumeSource, c fuzz.Continue) {
func(vs *core.VolumeSource, c fuzz.Continue) {
// Exactly one of the fields must be set.
v := reflect.ValueOf(vs).Elem()
i := int(c.RandUint64() % uint64(v.NumField()))
@ -239,38 +239,38 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
c.Fuzz(t.Interface())
}
},
func(i *api.ISCSIVolumeSource, c fuzz.Continue) {
func(i *core.ISCSIVolumeSource, c fuzz.Continue) {
i.ISCSIInterface = c.RandString()
if i.ISCSIInterface == "" {
i.ISCSIInterface = "default"
}
},
func(d *api.DNSPolicy, c fuzz.Continue) {
policies := []api.DNSPolicy{api.DNSClusterFirst, api.DNSDefault}
func(d *core.DNSPolicy, c fuzz.Continue) {
policies := []core.DNSPolicy{core.DNSClusterFirst, core.DNSDefault}
*d = policies[c.Rand.Intn(len(policies))]
},
func(p *api.Protocol, c fuzz.Continue) {
protocols := []api.Protocol{api.ProtocolTCP, api.ProtocolUDP}
func(p *core.Protocol, c fuzz.Continue) {
protocols := []core.Protocol{core.ProtocolTCP, core.ProtocolUDP}
*p = protocols[c.Rand.Intn(len(protocols))]
},
func(p *api.ServiceAffinity, c fuzz.Continue) {
types := []api.ServiceAffinity{api.ServiceAffinityClientIP, api.ServiceAffinityNone}
func(p *core.ServiceAffinity, c fuzz.Continue) {
types := []core.ServiceAffinity{core.ServiceAffinityClientIP, core.ServiceAffinityNone}
*p = types[c.Rand.Intn(len(types))]
},
func(p *api.ServiceType, c fuzz.Continue) {
types := []api.ServiceType{api.ServiceTypeClusterIP, api.ServiceTypeNodePort, api.ServiceTypeLoadBalancer}
func(p *core.ServiceType, c fuzz.Continue) {
types := []core.ServiceType{core.ServiceTypeClusterIP, core.ServiceTypeNodePort, core.ServiceTypeLoadBalancer}
*p = types[c.Rand.Intn(len(types))]
},
func(p *api.ServiceExternalTrafficPolicyType, c fuzz.Continue) {
types := []api.ServiceExternalTrafficPolicyType{api.ServiceExternalTrafficPolicyTypeCluster, api.ServiceExternalTrafficPolicyTypeLocal}
func(p *core.ServiceExternalTrafficPolicyType, c fuzz.Continue) {
types := []core.ServiceExternalTrafficPolicyType{core.ServiceExternalTrafficPolicyTypeCluster, core.ServiceExternalTrafficPolicyTypeLocal}
*p = types[c.Rand.Intn(len(types))]
},
func(ct *api.Container, c fuzz.Continue) {
func(ct *core.Container, c fuzz.Continue) {
c.FuzzNoCustom(ct) // fuzz self without calling this function again
ct.TerminationMessagePath = "/" + ct.TerminationMessagePath // Must be non-empty
ct.TerminationMessagePolicy = "File"
},
func(p *api.Probe, c fuzz.Continue) {
func(p *core.Probe, c fuzz.Continue) {
c.FuzzNoCustom(p)
// These fields have default values.
intFieldsWithDefaults := [...]string{"TimeoutSeconds", "PeriodSeconds", "SuccessThreshold", "FailureThreshold"}
@ -282,13 +282,13 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
}
}
},
func(ev *api.EnvVar, c fuzz.Continue) {
func(ev *core.EnvVar, c fuzz.Continue) {
ev.Name = c.RandString()
if c.RandBool() {
ev.Value = c.RandString()
} else {
ev.ValueFrom = &api.EnvVarSource{}
ev.ValueFrom.FieldRef = &api.ObjectFieldSelector{}
ev.ValueFrom = &core.EnvVarSource{}
ev.ValueFrom.FieldRef = &core.ObjectFieldSelector{}
versions := []schema.GroupVersion{
{Group: "admission.k8s.io", Version: "v1alpha1"},
@ -301,7 +301,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
ev.ValueFrom.FieldRef.FieldPath = c.RandString()
}
},
func(ev *api.EnvFromSource, c fuzz.Continue) {
func(ev *core.EnvFromSource, c fuzz.Continue) {
if c.RandBool() {
ev.Prefix = "p_"
}
@ -311,17 +311,17 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
c.Fuzz(&ev.SecretRef)
}
},
func(cm *api.ConfigMapEnvSource, c fuzz.Continue) {
func(cm *core.ConfigMapEnvSource, c fuzz.Continue) {
c.FuzzNoCustom(cm) // fuzz self without calling this function again
if c.RandBool() {
opt := c.RandBool()
cm.Optional = &opt
}
},
func(s *api.SecretEnvSource, c fuzz.Continue) {
func(s *core.SecretEnvSource, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
},
func(sc *api.SecurityContext, c fuzz.Continue) {
func(sc *core.SecurityContext, c fuzz.Continue) {
c.FuzzNoCustom(sc) // fuzz self without calling this function again
if c.RandBool() {
priv := c.RandBool()
@ -329,19 +329,19 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
}
if c.RandBool() {
sc.Capabilities = &api.Capabilities{
Add: make([]api.Capability, 0),
Drop: make([]api.Capability, 0),
sc.Capabilities = &core.Capabilities{
Add: make([]core.Capability, 0),
Drop: make([]core.Capability, 0),
}
c.Fuzz(&sc.Capabilities.Add)
c.Fuzz(&sc.Capabilities.Drop)
}
},
func(s *api.Secret, c fuzz.Continue) {
func(s *core.Secret, c fuzz.Continue) {
c.FuzzNoCustom(s) // fuzz self without calling this function again
s.Type = api.SecretTypeOpaque
s.Type = core.SecretTypeOpaque
},
func(r *api.RBDVolumeSource, c fuzz.Continue) {
func(r *core.RBDVolumeSource, c fuzz.Continue) {
r.RBDPool = c.RandString()
if r.RBDPool == "" {
r.RBDPool = "rbd"
@ -355,7 +355,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
r.Keyring = "/etc/ceph/keyring"
}
},
func(r *api.RBDPersistentVolumeSource, c fuzz.Continue) {
func(r *core.RBDPersistentVolumeSource, c fuzz.Continue) {
r.RBDPool = c.RandString()
if r.RBDPool == "" {
r.RBDPool = "rbd"
@ -369,36 +369,36 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
r.Keyring = "/etc/ceph/keyring"
}
},
func(obj *api.HostPathVolumeSource, c fuzz.Continue) {
func(obj *core.HostPathVolumeSource, c fuzz.Continue) {
c.FuzzNoCustom(obj)
types := []api.HostPathType{api.HostPathUnset, api.HostPathDirectoryOrCreate, api.HostPathDirectory,
api.HostPathFileOrCreate, api.HostPathFile, api.HostPathSocket, api.HostPathCharDev, api.HostPathBlockDev}
types := []core.HostPathType{core.HostPathUnset, core.HostPathDirectoryOrCreate, core.HostPathDirectory,
core.HostPathFileOrCreate, core.HostPathFile, core.HostPathSocket, core.HostPathCharDev, core.HostPathBlockDev}
typeVol := types[c.Rand.Intn(len(types))]
if obj.Type == nil {
obj.Type = &typeVol
}
},
func(pv *api.PersistentVolume, c fuzz.Continue) {
func(pv *core.PersistentVolume, c fuzz.Continue) {
c.FuzzNoCustom(pv) // fuzz self without calling this function again
types := []api.PersistentVolumePhase{api.VolumeAvailable, api.VolumePending, api.VolumeBound, api.VolumeReleased, api.VolumeFailed}
types := []core.PersistentVolumePhase{core.VolumeAvailable, core.VolumePending, core.VolumeBound, core.VolumeReleased, core.VolumeFailed}
pv.Status.Phase = types[c.Rand.Intn(len(types))]
pv.Status.Message = c.RandString()
reclamationPolicies := []api.PersistentVolumeReclaimPolicy{api.PersistentVolumeReclaimRecycle, api.PersistentVolumeReclaimRetain}
reclamationPolicies := []core.PersistentVolumeReclaimPolicy{core.PersistentVolumeReclaimRecycle, core.PersistentVolumeReclaimRetain}
pv.Spec.PersistentVolumeReclaimPolicy = reclamationPolicies[c.Rand.Intn(len(reclamationPolicies))]
},
func(pvc *api.PersistentVolumeClaim, c fuzz.Continue) {
func(pvc *core.PersistentVolumeClaim, c fuzz.Continue) {
c.FuzzNoCustom(pvc) // fuzz self without calling this function again
types := []api.PersistentVolumeClaimPhase{api.ClaimBound, api.ClaimPending, api.ClaimLost}
types := []core.PersistentVolumeClaimPhase{core.ClaimBound, core.ClaimPending, core.ClaimLost}
pvc.Status.Phase = types[c.Rand.Intn(len(types))]
},
func(obj *api.AzureDiskVolumeSource, c fuzz.Continue) {
func(obj *core.AzureDiskVolumeSource, c fuzz.Continue) {
if obj.CachingMode == nil {
obj.CachingMode = new(api.AzureDataDiskCachingMode)
*obj.CachingMode = api.AzureDataDiskCachingReadWrite
obj.CachingMode = new(core.AzureDataDiskCachingMode)
*obj.CachingMode = core.AzureDataDiskCachingReadWrite
}
if obj.Kind == nil {
obj.Kind = new(api.AzureDataDiskKind)
*obj.Kind = api.AzureSharedBlobDisk
obj.Kind = new(core.AzureDataDiskKind)
*obj.Kind = core.AzureSharedBlobDisk
}
if obj.FSType == nil {
obj.FSType = new(string)
@ -409,7 +409,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
*obj.ReadOnly = false
}
},
func(sio *api.ScaleIOVolumeSource, c fuzz.Continue) {
func(sio *core.ScaleIOVolumeSource, c fuzz.Continue) {
sio.StorageMode = c.RandString()
if sio.StorageMode == "" {
sio.StorageMode = "ThinProvisioned"
@ -419,7 +419,7 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
sio.FSType = "xfs"
}
},
func(sio *api.ScaleIOPersistentVolumeSource, c fuzz.Continue) {
func(sio *core.ScaleIOPersistentVolumeSource, c fuzz.Continue) {
sio.StorageMode = c.RandString()
if sio.StorageMode == "" {
sio.StorageMode = "ThinProvisioned"
@ -429,22 +429,22 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
sio.FSType = "xfs"
}
},
func(s *api.NamespaceSpec, c fuzz.Continue) {
s.Finalizers = []api.FinalizerName{api.FinalizerKubernetes}
func(s *core.NamespaceSpec, c fuzz.Continue) {
s.Finalizers = []core.FinalizerName{core.FinalizerKubernetes}
},
func(s *api.NamespaceStatus, c fuzz.Continue) {
s.Phase = api.NamespaceActive
func(s *core.NamespaceStatus, c fuzz.Continue) {
s.Phase = core.NamespaceActive
},
func(http *api.HTTPGetAction, c fuzz.Continue) {
func(http *core.HTTPGetAction, c fuzz.Continue) {
c.FuzzNoCustom(http) // fuzz self without calling this function again
http.Path = "/" + http.Path // can't be blank
http.Scheme = "x" + http.Scheme // can't be blank
},
func(ss *api.ServiceSpec, c fuzz.Continue) {
func(ss *core.ServiceSpec, c fuzz.Continue) {
c.FuzzNoCustom(ss) // fuzz self without calling this function again
if len(ss.Ports) == 0 {
// There must be at least 1 port.
ss.Ports = append(ss.Ports, api.ServicePort{})
ss.Ports = append(ss.Ports, core.ServicePort{})
c.Fuzz(&ss.Ports[0])
}
for i := range ss.Ports {
@ -455,25 +455,25 @@ var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
ss.Ports[i].TargetPort.StrVal = "x" + ss.Ports[i].TargetPort.StrVal // non-empty
}
}
types := []api.ServiceAffinity{api.ServiceAffinityNone, api.ServiceAffinityClientIP}
types := []core.ServiceAffinity{core.ServiceAffinityNone, core.ServiceAffinityClientIP}
ss.SessionAffinity = types[c.Rand.Intn(len(types))]
switch ss.SessionAffinity {
case api.ServiceAffinityClientIP:
timeoutSeconds := int32(c.Rand.Intn(int(api.MaxClientIPServiceAffinitySeconds)))
ss.SessionAffinityConfig = &api.SessionAffinityConfig{
ClientIP: &api.ClientIPConfig{
case core.ServiceAffinityClientIP:
timeoutSeconds := int32(c.Rand.Intn(int(core.MaxClientIPServiceAffinitySeconds)))
ss.SessionAffinityConfig = &core.SessionAffinityConfig{
ClientIP: &core.ClientIPConfig{
TimeoutSeconds: &timeoutSeconds,
},
}
case api.ServiceAffinityNone:
case core.ServiceAffinityNone:
ss.SessionAffinityConfig = nil
}
},
func(n *api.Node, c fuzz.Continue) {
func(n *core.Node, c fuzz.Continue) {
c.FuzzNoCustom(n)
n.Spec.ExternalID = "external"
},
func(s *api.NodeStatus, c fuzz.Continue) {
func(s *core.NodeStatus, c fuzz.Continue) {
c.FuzzNoCustom(s)
s.Allocatable = s.Capacity
},

View File

@ -28,30 +28,30 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/core"
)
// IsHugePageResourceName returns true if the resource name has the huge page
// resource prefix.
func IsHugePageResourceName(name api.ResourceName) bool {
return strings.HasPrefix(string(name), api.ResourceHugePagesPrefix)
func IsHugePageResourceName(name core.ResourceName) bool {
return strings.HasPrefix(string(name), core.ResourceHugePagesPrefix)
}
// HugePageResourceName returns a ResourceName with the canonical hugepage
// prefix prepended for the specified page size. The page size is converted
// to its canonical representation.
func HugePageResourceName(pageSize resource.Quantity) api.ResourceName {
return api.ResourceName(fmt.Sprintf("%s%s", api.ResourceHugePagesPrefix, pageSize.String()))
func HugePageResourceName(pageSize resource.Quantity) core.ResourceName {
return core.ResourceName(fmt.Sprintf("%s%s", core.ResourceHugePagesPrefix, pageSize.String()))
}
// HugePageSizeFromResourceName returns the page size for the specified huge page
// resource name. If the specified input is not a valid huge page resource name
// an error is returned.
func HugePageSizeFromResourceName(name api.ResourceName) (resource.Quantity, error) {
func HugePageSizeFromResourceName(name core.ResourceName) (resource.Quantity, error) {
if !IsHugePageResourceName(name) {
return resource.Quantity{}, fmt.Errorf("resource name: %s is not valid hugepage name", name)
}
pageSize := strings.TrimPrefix(string(name), api.ResourceHugePagesPrefix)
pageSize := strings.TrimPrefix(string(name), core.ResourceHugePagesPrefix)
return resource.ParseQuantity(pageSize)
}
@ -60,14 +60,14 @@ func HugePageSizeFromResourceName(name api.ResourceName) (resource.Quantity, err
func NonConvertibleFields(annotations map[string]string) map[string]string {
nonConvertibleKeys := map[string]string{}
for key, value := range annotations {
if strings.HasPrefix(key, api.NonConvertibleAnnotationPrefix) {
if strings.HasPrefix(key, core.NonConvertibleAnnotationPrefix) {
nonConvertibleKeys[key] = value
}
}
return nonConvertibleKeys
}
// Semantic can do semantic deep equality checks for api objects.
// Semantic can do semantic deep equality checks for core objects.
// Example: apiequality.Semantic.DeepEqual(aPod, aPodWithNonNilButEmptyMaps) == true
var Semantic = conversion.EqualitiesOrDie(
func(a, b resource.Quantity) bool {
@ -92,10 +92,10 @@ var Semantic = conversion.EqualitiesOrDie(
)
var standardResourceQuotaScopes = sets.NewString(
string(api.ResourceQuotaScopeTerminating),
string(api.ResourceQuotaScopeNotTerminating),
string(api.ResourceQuotaScopeBestEffort),
string(api.ResourceQuotaScopeNotBestEffort),
string(core.ResourceQuotaScopeTerminating),
string(core.ResourceQuotaScopeNotTerminating),
string(core.ResourceQuotaScopeBestEffort),
string(core.ResourceQuotaScopeNotBestEffort),
)
// IsStandardResourceQuotaScope returns true if the scope is a standard value
@ -104,24 +104,24 @@ func IsStandardResourceQuotaScope(str string) bool {
}
var podObjectCountQuotaResources = sets.NewString(
string(api.ResourcePods),
string(core.ResourcePods),
)
var podComputeQuotaResources = sets.NewString(
string(api.ResourceCPU),
string(api.ResourceMemory),
string(api.ResourceLimitsCPU),
string(api.ResourceLimitsMemory),
string(api.ResourceRequestsCPU),
string(api.ResourceRequestsMemory),
string(core.ResourceCPU),
string(core.ResourceMemory),
string(core.ResourceLimitsCPU),
string(core.ResourceLimitsMemory),
string(core.ResourceRequestsCPU),
string(core.ResourceRequestsMemory),
)
// IsResourceQuotaScopeValidForResource returns true if the resource applies to the specified scope
func IsResourceQuotaScopeValidForResource(scope api.ResourceQuotaScope, resource string) bool {
func IsResourceQuotaScopeValidForResource(scope core.ResourceQuotaScope, resource string) bool {
switch scope {
case api.ResourceQuotaScopeTerminating, api.ResourceQuotaScopeNotTerminating, api.ResourceQuotaScopeNotBestEffort:
case core.ResourceQuotaScopeTerminating, core.ResourceQuotaScopeNotTerminating, core.ResourceQuotaScopeNotBestEffort:
return podObjectCountQuotaResources.Has(resource) || podComputeQuotaResources.Has(resource)
case api.ResourceQuotaScopeBestEffort:
case core.ResourceQuotaScopeBestEffort:
return podObjectCountQuotaResources.Has(resource)
default:
return true
@ -129,20 +129,20 @@ func IsResourceQuotaScopeValidForResource(scope api.ResourceQuotaScope, resource
}
var standardContainerResources = sets.NewString(
string(api.ResourceCPU),
string(api.ResourceMemory),
string(api.ResourceEphemeralStorage),
string(core.ResourceCPU),
string(core.ResourceMemory),
string(core.ResourceEphemeralStorage),
)
// IsStandardContainerResourceName returns true if the container can make a resource request
// for the specified resource
func IsStandardContainerResourceName(str string) bool {
return standardContainerResources.Has(str) || IsHugePageResourceName(api.ResourceName(str))
return standardContainerResources.Has(str) || IsHugePageResourceName(core.ResourceName(str))
}
// IsExtendedResourceName returns true if the resource name is not in the
// default namespace, or it has the opaque integer resource prefix.
func IsExtendedResourceName(name api.ResourceName) bool {
func IsExtendedResourceName(name core.ResourceName) bool {
// TODO: Remove OIR part following deprecation.
return !IsDefaultNamespaceResource(name) || IsOpaqueIntResourceName(name)
}
@ -150,41 +150,41 @@ func IsExtendedResourceName(name api.ResourceName) bool {
// IsDefaultNamespaceResource returns true if the resource name is in the
// *kubernetes.io/ namespace. Partially-qualified (unprefixed) names are
// implicitly in the kubernetes.io/ namespace.
func IsDefaultNamespaceResource(name api.ResourceName) bool {
func IsDefaultNamespaceResource(name core.ResourceName) bool {
return !strings.Contains(string(name), "/") ||
strings.Contains(string(name), api.ResourceDefaultNamespacePrefix)
strings.Contains(string(name), core.ResourceDefaultNamespacePrefix)
}
// IsOpaqueIntResourceName returns true if the resource name has the opaque
// integer resource prefix.
func IsOpaqueIntResourceName(name api.ResourceName) bool {
return strings.HasPrefix(string(name), api.ResourceOpaqueIntPrefix)
func IsOpaqueIntResourceName(name core.ResourceName) bool {
return strings.HasPrefix(string(name), core.ResourceOpaqueIntPrefix)
}
// OpaqueIntResourceName returns a ResourceName with the canonical opaque
// integer prefix prepended. If the argument already has the prefix, it is
// returned unmodified.
func OpaqueIntResourceName(name string) api.ResourceName {
if IsOpaqueIntResourceName(api.ResourceName(name)) {
return api.ResourceName(name)
func OpaqueIntResourceName(name string) core.ResourceName {
if IsOpaqueIntResourceName(core.ResourceName(name)) {
return core.ResourceName(name)
}
return api.ResourceName(fmt.Sprintf("%s%s", api.ResourceOpaqueIntPrefix, name))
return core.ResourceName(fmt.Sprintf("%s%s", core.ResourceOpaqueIntPrefix, name))
}
var overcommitBlacklist = sets.NewString(string(api.ResourceNvidiaGPU))
var overcommitBlacklist = sets.NewString(string(core.ResourceNvidiaGPU))
// IsOvercommitAllowed returns true if the resource is in the default
// namespace and not blacklisted.
func IsOvercommitAllowed(name api.ResourceName) bool {
func IsOvercommitAllowed(name core.ResourceName) bool {
return IsDefaultNamespaceResource(name) &&
!IsHugePageResourceName(name) &&
!overcommitBlacklist.Has(string(name))
}
var standardLimitRangeTypes = sets.NewString(
string(api.LimitTypePod),
string(api.LimitTypeContainer),
string(api.LimitTypePersistentVolumeClaim),
string(core.LimitTypePod),
string(core.LimitTypeContainer),
string(core.LimitTypePersistentVolumeClaim),
)
// IsStandardLimitRangeType returns true if the type is Pod or Container
@ -193,25 +193,25 @@ func IsStandardLimitRangeType(str string) bool {
}
var standardQuotaResources = sets.NewString(
string(api.ResourceCPU),
string(api.ResourceMemory),
string(api.ResourceEphemeralStorage),
string(api.ResourceRequestsCPU),
string(api.ResourceRequestsMemory),
string(api.ResourceRequestsStorage),
string(api.ResourceRequestsEphemeralStorage),
string(api.ResourceLimitsCPU),
string(api.ResourceLimitsMemory),
string(api.ResourceLimitsEphemeralStorage),
string(api.ResourcePods),
string(api.ResourceQuotas),
string(api.ResourceServices),
string(api.ResourceReplicationControllers),
string(api.ResourceSecrets),
string(api.ResourcePersistentVolumeClaims),
string(api.ResourceConfigMaps),
string(api.ResourceServicesNodePorts),
string(api.ResourceServicesLoadBalancers),
string(core.ResourceCPU),
string(core.ResourceMemory),
string(core.ResourceEphemeralStorage),
string(core.ResourceRequestsCPU),
string(core.ResourceRequestsMemory),
string(core.ResourceRequestsStorage),
string(core.ResourceRequestsEphemeralStorage),
string(core.ResourceLimitsCPU),
string(core.ResourceLimitsMemory),
string(core.ResourceLimitsEphemeralStorage),
string(core.ResourcePods),
string(core.ResourceQuotas),
string(core.ResourceServices),
string(core.ResourceReplicationControllers),
string(core.ResourceSecrets),
string(core.ResourcePersistentVolumeClaims),
string(core.ResourceConfigMaps),
string(core.ResourceServicesNodePorts),
string(core.ResourceServicesLoadBalancers),
)
// IsStandardQuotaResourceName returns true if the resource is known to
@ -221,84 +221,84 @@ func IsStandardQuotaResourceName(str string) bool {
}
var standardResources = sets.NewString(
string(api.ResourceCPU),
string(api.ResourceMemory),
string(api.ResourceEphemeralStorage),
string(api.ResourceRequestsCPU),
string(api.ResourceRequestsMemory),
string(api.ResourceRequestsEphemeralStorage),
string(api.ResourceLimitsCPU),
string(api.ResourceLimitsMemory),
string(api.ResourceLimitsEphemeralStorage),
string(api.ResourcePods),
string(api.ResourceQuotas),
string(api.ResourceServices),
string(api.ResourceReplicationControllers),
string(api.ResourceSecrets),
string(api.ResourceConfigMaps),
string(api.ResourcePersistentVolumeClaims),
string(api.ResourceStorage),
string(api.ResourceRequestsStorage),
string(api.ResourceServicesNodePorts),
string(api.ResourceServicesLoadBalancers),
string(core.ResourceCPU),
string(core.ResourceMemory),
string(core.ResourceEphemeralStorage),
string(core.ResourceRequestsCPU),
string(core.ResourceRequestsMemory),
string(core.ResourceRequestsEphemeralStorage),
string(core.ResourceLimitsCPU),
string(core.ResourceLimitsMemory),
string(core.ResourceLimitsEphemeralStorage),
string(core.ResourcePods),
string(core.ResourceQuotas),
string(core.ResourceServices),
string(core.ResourceReplicationControllers),
string(core.ResourceSecrets),
string(core.ResourceConfigMaps),
string(core.ResourcePersistentVolumeClaims),
string(core.ResourceStorage),
string(core.ResourceRequestsStorage),
string(core.ResourceServicesNodePorts),
string(core.ResourceServicesLoadBalancers),
)
// IsStandardResourceName returns true if the resource is known to the system
func IsStandardResourceName(str string) bool {
return standardResources.Has(str) || IsHugePageResourceName(api.ResourceName(str))
return standardResources.Has(str) || IsHugePageResourceName(core.ResourceName(str))
}
var integerResources = sets.NewString(
string(api.ResourcePods),
string(api.ResourceQuotas),
string(api.ResourceServices),
string(api.ResourceReplicationControllers),
string(api.ResourceSecrets),
string(api.ResourceConfigMaps),
string(api.ResourcePersistentVolumeClaims),
string(api.ResourceServicesNodePorts),
string(api.ResourceServicesLoadBalancers),
string(core.ResourcePods),
string(core.ResourceQuotas),
string(core.ResourceServices),
string(core.ResourceReplicationControllers),
string(core.ResourceSecrets),
string(core.ResourceConfigMaps),
string(core.ResourcePersistentVolumeClaims),
string(core.ResourceServicesNodePorts),
string(core.ResourceServicesLoadBalancers),
)
// IsIntegerResourceName returns true if the resource is measured in integer values
func IsIntegerResourceName(str string) bool {
return integerResources.Has(str) || IsExtendedResourceName(api.ResourceName(str))
return integerResources.Has(str) || IsExtendedResourceName(core.ResourceName(str))
}
// Extended and HugePages resources
func IsScalarResourceName(name api.ResourceName) bool {
func IsScalarResourceName(name core.ResourceName) bool {
return IsExtendedResourceName(name) || IsHugePageResourceName(name)
}
// this function aims to check if the service's ClusterIP is set or not
// the objective is not to perform validation here
func IsServiceIPSet(service *api.Service) bool {
return service.Spec.ClusterIP != api.ClusterIPNone && service.Spec.ClusterIP != ""
func IsServiceIPSet(service *core.Service) bool {
return service.Spec.ClusterIP != core.ClusterIPNone && service.Spec.ClusterIP != ""
}
// this function aims to check if the service's cluster IP is requested or not
func IsServiceIPRequested(service *api.Service) bool {
func IsServiceIPRequested(service *core.Service) bool {
// ExternalName services are CNAME aliases to external ones. Ignore the IP.
if service.Spec.Type == api.ServiceTypeExternalName {
if service.Spec.Type == core.ServiceTypeExternalName {
return false
}
return service.Spec.ClusterIP == ""
}
var standardFinalizers = sets.NewString(
string(api.FinalizerKubernetes),
string(core.FinalizerKubernetes),
metav1.FinalizerOrphanDependents,
metav1.FinalizerDeleteDependents,
)
// HasAnnotation returns a bool if passed in annotation exists
func HasAnnotation(obj api.ObjectMeta, ann string) bool {
func HasAnnotation(obj core.ObjectMeta, ann string) bool {
_, found := obj.Annotations[ann]
return found
}
// SetMetaDataAnnotation sets the annotation and value
func SetMetaDataAnnotation(obj *api.ObjectMeta, ann string, value string) {
func SetMetaDataAnnotation(obj *core.ObjectMeta, ann string, value string) {
if obj.Annotations == nil {
obj.Annotations = make(map[string]string)
}
@ -311,7 +311,7 @@ func IsStandardFinalizerName(str string) bool {
// AddToNodeAddresses appends the NodeAddresses to the passed-by-pointer slice,
// only if they do not already exist
func AddToNodeAddresses(addresses *[]api.NodeAddress, addAddresses ...api.NodeAddress) {
func AddToNodeAddresses(addresses *[]core.NodeAddress, addAddresses ...core.NodeAddress) {
for _, add := range addAddresses {
exists := false
for _, existing := range *addresses {
@ -327,11 +327,11 @@ func AddToNodeAddresses(addresses *[]api.NodeAddress, addAddresses ...api.NodeAd
}
// TODO: make method on LoadBalancerStatus?
func LoadBalancerStatusEqual(l, r *api.LoadBalancerStatus) bool {
func LoadBalancerStatusEqual(l, r *core.LoadBalancerStatus) bool {
return ingressSliceEqual(l.Ingress, r.Ingress)
}
func ingressSliceEqual(lhs, rhs []api.LoadBalancerIngress) bool {
func ingressSliceEqual(lhs, rhs []core.LoadBalancerIngress) bool {
if len(lhs) != len(rhs) {
return false
}
@ -343,7 +343,7 @@ func ingressSliceEqual(lhs, rhs []api.LoadBalancerIngress) bool {
return true
}
func ingressEqual(lhs, rhs *api.LoadBalancerIngress) bool {
func ingressEqual(lhs, rhs *core.LoadBalancerIngress) bool {
if lhs.IP != rhs.IP {
return false
}
@ -354,9 +354,9 @@ func ingressEqual(lhs, rhs *api.LoadBalancerIngress) bool {
}
// TODO: make method on LoadBalancerStatus?
func LoadBalancerStatusDeepCopy(lb *api.LoadBalancerStatus) *api.LoadBalancerStatus {
c := &api.LoadBalancerStatus{}
c.Ingress = make([]api.LoadBalancerIngress, len(lb.Ingress))
func LoadBalancerStatusDeepCopy(lb *core.LoadBalancerStatus) *core.LoadBalancerStatus {
c := &core.LoadBalancerStatus{}
c.Ingress = make([]core.LoadBalancerIngress, len(lb.Ingress))
for i := range lb.Ingress {
c.Ingress[i] = lb.Ingress[i]
}
@ -365,42 +365,42 @@ func LoadBalancerStatusDeepCopy(lb *api.LoadBalancerStatus) *api.LoadBalancerSta
// GetAccessModesAsString returns a string representation of an array of access modes.
// modes, when present, are always in the same order: RWO,ROX,RWX.
func GetAccessModesAsString(modes []api.PersistentVolumeAccessMode) string {
func GetAccessModesAsString(modes []core.PersistentVolumeAccessMode) string {
modes = removeDuplicateAccessModes(modes)
modesStr := []string{}
if containsAccessMode(modes, api.ReadWriteOnce) {
if containsAccessMode(modes, core.ReadWriteOnce) {
modesStr = append(modesStr, "RWO")
}
if containsAccessMode(modes, api.ReadOnlyMany) {
if containsAccessMode(modes, core.ReadOnlyMany) {
modesStr = append(modesStr, "ROX")
}
if containsAccessMode(modes, api.ReadWriteMany) {
if containsAccessMode(modes, core.ReadWriteMany) {
modesStr = append(modesStr, "RWX")
}
return strings.Join(modesStr, ",")
}
// GetAccessModesAsString returns an array of AccessModes from a string created by GetAccessModesAsString
func GetAccessModesFromString(modes string) []api.PersistentVolumeAccessMode {
func GetAccessModesFromString(modes string) []core.PersistentVolumeAccessMode {
strmodes := strings.Split(modes, ",")
accessModes := []api.PersistentVolumeAccessMode{}
accessModes := []core.PersistentVolumeAccessMode{}
for _, s := range strmodes {
s = strings.Trim(s, " ")
switch {
case s == "RWO":
accessModes = append(accessModes, api.ReadWriteOnce)
accessModes = append(accessModes, core.ReadWriteOnce)
case s == "ROX":
accessModes = append(accessModes, api.ReadOnlyMany)
accessModes = append(accessModes, core.ReadOnlyMany)
case s == "RWX":
accessModes = append(accessModes, api.ReadWriteMany)
accessModes = append(accessModes, core.ReadWriteMany)
}
}
return accessModes
}
// removeDuplicateAccessModes returns an array of access modes without any duplicates
func removeDuplicateAccessModes(modes []api.PersistentVolumeAccessMode) []api.PersistentVolumeAccessMode {
accessModes := []api.PersistentVolumeAccessMode{}
func removeDuplicateAccessModes(modes []core.PersistentVolumeAccessMode) []core.PersistentVolumeAccessMode {
accessModes := []core.PersistentVolumeAccessMode{}
for _, m := range modes {
if !containsAccessMode(accessModes, m) {
accessModes = append(accessModes, m)
@ -409,7 +409,7 @@ func removeDuplicateAccessModes(modes []api.PersistentVolumeAccessMode) []api.Pe
return accessModes
}
func containsAccessMode(modes []api.PersistentVolumeAccessMode, mode api.PersistentVolumeAccessMode) bool {
func containsAccessMode(modes []core.PersistentVolumeAccessMode, mode core.PersistentVolumeAccessMode) bool {
for _, m := range modes {
if m == mode {
return true
@ -418,9 +418,9 @@ func containsAccessMode(modes []api.PersistentVolumeAccessMode, mode api.Persist
return false
}
// NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement api type into a struct that implements
// NodeSelectorRequirementsAsSelector converts the []NodeSelectorRequirement core type into a struct that implements
// labels.Selector.
func NodeSelectorRequirementsAsSelector(nsm []api.NodeSelectorRequirement) (labels.Selector, error) {
func NodeSelectorRequirementsAsSelector(nsm []core.NodeSelectorRequirement) (labels.Selector, error) {
if len(nsm) == 0 {
return labels.Nothing(), nil
}
@ -428,17 +428,17 @@ func NodeSelectorRequirementsAsSelector(nsm []api.NodeSelectorRequirement) (labe
for _, expr := range nsm {
var op selection.Operator
switch expr.Operator {
case api.NodeSelectorOpIn:
case core.NodeSelectorOpIn:
op = selection.In
case api.NodeSelectorOpNotIn:
case core.NodeSelectorOpNotIn:
op = selection.NotIn
case api.NodeSelectorOpExists:
case core.NodeSelectorOpExists:
op = selection.Exists
case api.NodeSelectorOpDoesNotExist:
case core.NodeSelectorOpDoesNotExist:
op = selection.DoesNotExist
case api.NodeSelectorOpGt:
case core.NodeSelectorOpGt:
op = selection.GreaterThan
case api.NodeSelectorOpLt:
case core.NodeSelectorOpLt:
op = selection.LessThan
default:
return nil, fmt.Errorf("%q is not a valid node selector operator", expr.Operator)
@ -453,11 +453,11 @@ func NodeSelectorRequirementsAsSelector(nsm []api.NodeSelectorRequirement) (labe
}
// GetTolerationsFromPodAnnotations gets the json serialized tolerations data from Pod.Annotations
// and converts it to the []Toleration type in api.
func GetTolerationsFromPodAnnotations(annotations map[string]string) ([]api.Toleration, error) {
var tolerations []api.Toleration
if len(annotations) > 0 && annotations[api.TolerationsAnnotationKey] != "" {
err := json.Unmarshal([]byte(annotations[api.TolerationsAnnotationKey]), &tolerations)
// and converts it to the []Toleration type in core.
func GetTolerationsFromPodAnnotations(annotations map[string]string) ([]core.Toleration, error) {
var tolerations []core.Toleration
if len(annotations) > 0 && annotations[core.TolerationsAnnotationKey] != "" {
err := json.Unmarshal([]byte(annotations[core.TolerationsAnnotationKey]), &tolerations)
if err != nil {
return tolerations, err
}
@ -467,10 +467,10 @@ func GetTolerationsFromPodAnnotations(annotations map[string]string) ([]api.Tole
// AddOrUpdateTolerationInPod tries to add a toleration to the pod's toleration list.
// Returns true if something was updated, false otherwise.
func AddOrUpdateTolerationInPod(pod *api.Pod, toleration *api.Toleration) bool {
func AddOrUpdateTolerationInPod(pod *core.Pod, toleration *core.Toleration) bool {
podTolerations := pod.Spec.Tolerations
var newTolerations []api.Toleration
var newTolerations []core.Toleration
updated := false
for i := range podTolerations {
if toleration.MatchToleration(&podTolerations[i]) {
@ -494,7 +494,7 @@ func AddOrUpdateTolerationInPod(pod *api.Pod, toleration *api.Toleration) bool {
}
// TolerationToleratesTaint checks if the toleration tolerates the taint.
func TolerationToleratesTaint(toleration *api.Toleration, taint *api.Taint) bool {
func TolerationToleratesTaint(toleration *core.Toleration, taint *core.Taint) bool {
if len(toleration.Effect) != 0 && toleration.Effect != taint.Effect {
return false
}
@ -503,17 +503,17 @@ func TolerationToleratesTaint(toleration *api.Toleration, taint *api.Taint) bool
return false
}
// TODO: Use proper defaulting when Toleration becomes a field of PodSpec
if (len(toleration.Operator) == 0 || toleration.Operator == api.TolerationOpEqual) && toleration.Value == taint.Value {
if (len(toleration.Operator) == 0 || toleration.Operator == core.TolerationOpEqual) && toleration.Value == taint.Value {
return true
}
if toleration.Operator == api.TolerationOpExists {
if toleration.Operator == core.TolerationOpExists {
return true
}
return false
}
// TaintToleratedByTolerations checks if taint is tolerated by any of the tolerations.
func TaintToleratedByTolerations(taint *api.Taint, tolerations []api.Toleration) bool {
func TaintToleratedByTolerations(taint *core.Taint, tolerations []core.Toleration) bool {
tolerated := false
for i := range tolerations {
if TolerationToleratesTaint(&tolerations[i], taint) {
@ -525,13 +525,13 @@ func TaintToleratedByTolerations(taint *api.Taint, tolerations []api.Toleration)
}
// GetTaintsFromNodeAnnotations gets the json serialized taints data from Pod.Annotations
// and converts it to the []Taint type in api.
func GetTaintsFromNodeAnnotations(annotations map[string]string) ([]api.Taint, error) {
var taints []api.Taint
if len(annotations) > 0 && annotations[api.TaintsAnnotationKey] != "" {
err := json.Unmarshal([]byte(annotations[api.TaintsAnnotationKey]), &taints)
// and converts it to the []Taint type in core.
func GetTaintsFromNodeAnnotations(annotations map[string]string) ([]core.Taint, error) {
var taints []core.Taint
if len(annotations) > 0 && annotations[core.TaintsAnnotationKey] != "" {
err := json.Unmarshal([]byte(annotations[core.TaintsAnnotationKey]), &taints)
if err != nil {
return []api.Taint{}, err
return []core.Taint{}, err
}
}
return taints, nil
@ -540,12 +540,12 @@ func GetTaintsFromNodeAnnotations(annotations map[string]string) ([]api.Taint, e
// SysctlsFromPodAnnotations parses the sysctl annotations into a slice of safe Sysctls
// and a slice of unsafe Sysctls. This is only a convenience wrapper around
// SysctlsFromPodAnnotation.
func SysctlsFromPodAnnotations(a map[string]string) ([]api.Sysctl, []api.Sysctl, error) {
safe, err := SysctlsFromPodAnnotation(a[api.SysctlsPodAnnotationKey])
func SysctlsFromPodAnnotations(a map[string]string) ([]core.Sysctl, []core.Sysctl, error) {
safe, err := SysctlsFromPodAnnotation(a[core.SysctlsPodAnnotationKey])
if err != nil {
return nil, nil, err
}
unsafe, err := SysctlsFromPodAnnotation(a[api.UnsafeSysctlsPodAnnotationKey])
unsafe, err := SysctlsFromPodAnnotation(a[core.UnsafeSysctlsPodAnnotationKey])
if err != nil {
return nil, nil, err
}
@ -554,13 +554,13 @@ func SysctlsFromPodAnnotations(a map[string]string) ([]api.Sysctl, []api.Sysctl,
}
// SysctlsFromPodAnnotation parses an annotation value into a slice of Sysctls.
func SysctlsFromPodAnnotation(annotation string) ([]api.Sysctl, error) {
func SysctlsFromPodAnnotation(annotation string) ([]core.Sysctl, error) {
if len(annotation) == 0 {
return nil, nil
}
kvs := strings.Split(annotation, ",")
sysctls := make([]api.Sysctl, len(kvs))
sysctls := make([]core.Sysctl, len(kvs))
for i, kv := range kvs {
cs := strings.Split(kv, "=")
if len(cs) != 2 || len(cs[0]) == 0 {
@ -573,7 +573,7 @@ func SysctlsFromPodAnnotation(annotation string) ([]api.Sysctl, error) {
}
// PodAnnotationsFromSysctls creates an annotation value for a slice of Sysctls.
func PodAnnotationsFromSysctls(sysctls []api.Sysctl) string {
func PodAnnotationsFromSysctls(sysctls []core.Sysctl) string {
if len(sysctls) == 0 {
return ""
}
@ -586,9 +586,9 @@ func PodAnnotationsFromSysctls(sysctls []api.Sysctl) string {
}
// GetPersistentVolumeClass returns StorageClassName.
func GetPersistentVolumeClass(volume *api.PersistentVolume) string {
func GetPersistentVolumeClass(volume *core.PersistentVolume) string {
// Use beta annotation first
if class, found := volume.Annotations[api.BetaStorageClassAnnotation]; found {
if class, found := volume.Annotations[core.BetaStorageClassAnnotation]; found {
return class
}
@ -597,9 +597,9 @@ func GetPersistentVolumeClass(volume *api.PersistentVolume) string {
// GetPersistentVolumeClaimClass returns StorageClassName. If no storage class was
// requested, it returns "".
func GetPersistentVolumeClaimClass(claim *api.PersistentVolumeClaim) string {
func GetPersistentVolumeClaimClass(claim *core.PersistentVolumeClaim) string {
// Use beta annotation first
if class, found := claim.Annotations[api.BetaStorageClassAnnotation]; found {
if class, found := claim.Annotations[core.BetaStorageClassAnnotation]; found {
return class
}
@ -611,9 +611,9 @@ func GetPersistentVolumeClaimClass(claim *api.PersistentVolumeClaim) string {
}
// PersistentVolumeClaimHasClass returns true if given claim has set StorageClassName field.
func PersistentVolumeClaimHasClass(claim *api.PersistentVolumeClaim) bool {
func PersistentVolumeClaimHasClass(claim *core.PersistentVolumeClaim) bool {
// Use beta annotation first
if _, found := claim.Annotations[api.BetaStorageClassAnnotation]; found {
if _, found := claim.Annotations[core.BetaStorageClassAnnotation]; found {
return true
}
@ -625,12 +625,12 @@ func PersistentVolumeClaimHasClass(claim *api.PersistentVolumeClaim) bool {
}
// GetStorageNodeAffinityFromAnnotation gets the json serialized data from PersistentVolume.Annotations
// and converts it to the NodeAffinity type in api.
// and converts it to the NodeAffinity type in core.
// TODO: update when storage node affinity graduates to beta
func GetStorageNodeAffinityFromAnnotation(annotations map[string]string) (*api.NodeAffinity, error) {
if len(annotations) > 0 && annotations[api.AlphaStorageNodeAffinityAnnotation] != "" {
var affinity api.NodeAffinity
err := json.Unmarshal([]byte(annotations[api.AlphaStorageNodeAffinityAnnotation]), &affinity)
func GetStorageNodeAffinityFromAnnotation(annotations map[string]string) (*core.NodeAffinity, error) {
if len(annotations) > 0 && annotations[core.AlphaStorageNodeAffinityAnnotation] != "" {
var affinity core.NodeAffinity
err := json.Unmarshal([]byte(annotations[core.AlphaStorageNodeAffinityAnnotation]), &affinity)
if err != nil {
return nil, err
}
@ -641,7 +641,7 @@ func GetStorageNodeAffinityFromAnnotation(annotations map[string]string) (*api.N
// Converts NodeAffinity type to Alpha annotation for use in PersistentVolumes
// TODO: update when storage node affinity graduates to beta
func StorageNodeAffinityToAlphaAnnotation(annotations map[string]string, affinity *api.NodeAffinity) error {
func StorageNodeAffinityToAlphaAnnotation(annotations map[string]string, affinity *core.NodeAffinity) error {
if affinity == nil {
return nil
}
@ -650,6 +650,6 @@ func StorageNodeAffinityToAlphaAnnotation(annotations map[string]string, affinit
if err != nil {
return err
}
annotations[api.AlphaStorageNodeAffinityAnnotation] = string(json)
annotations[core.AlphaStorageNodeAffinityAnnotation] = string(json)
return nil
}

View File

@ -22,7 +22,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/core"
)
func TestSemantic(t *testing.T) {
@ -86,49 +86,49 @@ func TestIsStandardContainerResource(t *testing.T) {
func TestAddToNodeAddresses(t *testing.T) {
testCases := []struct {
existing []api.NodeAddress
toAdd []api.NodeAddress
expected []api.NodeAddress
existing []core.NodeAddress
toAdd []core.NodeAddress
expected []core.NodeAddress
}{
{
existing: []api.NodeAddress{},
toAdd: []api.NodeAddress{},
expected: []api.NodeAddress{},
existing: []core.NodeAddress{},
toAdd: []core.NodeAddress{},
expected: []core.NodeAddress{},
},
{
existing: []api.NodeAddress{},
toAdd: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
{Type: api.NodeHostName, Address: "localhost"},
existing: []core.NodeAddress{},
toAdd: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
{Type: core.NodeHostName, Address: "localhost"},
},
expected: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
{Type: api.NodeHostName, Address: "localhost"},
expected: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
{Type: core.NodeHostName, Address: "localhost"},
},
},
{
existing: []api.NodeAddress{},
toAdd: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
existing: []core.NodeAddress{},
toAdd: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
},
expected: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
expected: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
},
},
{
existing: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
{Type: api.NodeInternalIP, Address: "10.1.1.1"},
existing: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
{Type: core.NodeInternalIP, Address: "10.1.1.1"},
},
toAdd: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
{Type: api.NodeHostName, Address: "localhost"},
toAdd: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
{Type: core.NodeHostName, Address: "localhost"},
},
expected: []api.NodeAddress{
{Type: api.NodeExternalIP, Address: "1.1.1.1"},
{Type: api.NodeInternalIP, Address: "10.1.1.1"},
{Type: api.NodeHostName, Address: "localhost"},
expected: []core.NodeAddress{
{Type: core.NodeExternalIP, Address: "1.1.1.1"},
{Type: core.NodeInternalIP, Address: "10.1.1.1"},
{Type: core.NodeHostName, Address: "localhost"},
},
},
}
@ -143,30 +143,30 @@ func TestAddToNodeAddresses(t *testing.T) {
func TestGetAccessModesFromString(t *testing.T) {
modes := GetAccessModesFromString("ROX")
if !containsAccessMode(modes, api.ReadOnlyMany) {
t.Errorf("Expected mode %s, but got %+v", api.ReadOnlyMany, modes)
if !containsAccessMode(modes, core.ReadOnlyMany) {
t.Errorf("Expected mode %s, but got %+v", core.ReadOnlyMany, modes)
}
modes = GetAccessModesFromString("ROX,RWX")
if !containsAccessMode(modes, api.ReadOnlyMany) {
t.Errorf("Expected mode %s, but got %+v", api.ReadOnlyMany, modes)
if !containsAccessMode(modes, core.ReadOnlyMany) {
t.Errorf("Expected mode %s, but got %+v", core.ReadOnlyMany, modes)
}
if !containsAccessMode(modes, api.ReadWriteMany) {
t.Errorf("Expected mode %s, but got %+v", api.ReadWriteMany, modes)
if !containsAccessMode(modes, core.ReadWriteMany) {
t.Errorf("Expected mode %s, but got %+v", core.ReadWriteMany, modes)
}
modes = GetAccessModesFromString("RWO,ROX,RWX")
if !containsAccessMode(modes, api.ReadOnlyMany) {
t.Errorf("Expected mode %s, but got %+v", api.ReadOnlyMany, modes)
if !containsAccessMode(modes, core.ReadOnlyMany) {
t.Errorf("Expected mode %s, but got %+v", core.ReadOnlyMany, modes)
}
if !containsAccessMode(modes, api.ReadWriteMany) {
t.Errorf("Expected mode %s, but got %+v", api.ReadWriteMany, modes)
if !containsAccessMode(modes, core.ReadWriteMany) {
t.Errorf("Expected mode %s, but got %+v", core.ReadWriteMany, modes)
}
}
func TestRemoveDuplicateAccessModes(t *testing.T) {
modes := []api.PersistentVolumeAccessMode{
api.ReadWriteOnce, api.ReadOnlyMany, api.ReadOnlyMany, api.ReadOnlyMany,
modes := []core.PersistentVolumeAccessMode{
core.ReadWriteOnce, core.ReadOnlyMany, core.ReadOnlyMany, core.ReadOnlyMany,
}
modes = removeDuplicateAccessModes(modes)
if len(modes) != 2 {
@ -175,9 +175,9 @@ func TestRemoveDuplicateAccessModes(t *testing.T) {
}
func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
matchExpressions := []api.NodeSelectorRequirement{{
matchExpressions := []core.NodeSelectorRequirement{{
Key: "foo",
Operator: api.NodeSelectorOpIn,
Operator: core.NodeSelectorOpIn,
Values: []string{"bar", "baz"},
}}
mustParse := func(s string) labels.Selector {
@ -188,36 +188,36 @@ func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
return out
}
tc := []struct {
in []api.NodeSelectorRequirement
in []core.NodeSelectorRequirement
out labels.Selector
expectErr bool
}{
{in: nil, out: labels.Nothing()},
{in: []api.NodeSelectorRequirement{}, out: labels.Nothing()},
{in: []core.NodeSelectorRequirement{}, out: labels.Nothing()},
{
in: matchExpressions,
out: mustParse("foo in (baz,bar)"),
},
{
in: []api.NodeSelectorRequirement{{
in: []core.NodeSelectorRequirement{{
Key: "foo",
Operator: api.NodeSelectorOpExists,
Operator: core.NodeSelectorOpExists,
Values: []string{"bar", "baz"},
}},
expectErr: true,
},
{
in: []api.NodeSelectorRequirement{{
in: []core.NodeSelectorRequirement{{
Key: "foo",
Operator: api.NodeSelectorOpGt,
Operator: core.NodeSelectorOpGt,
Values: []string{"1"},
}},
out: mustParse("foo>1"),
},
{
in: []api.NodeSelectorRequirement{{
in: []core.NodeSelectorRequirement{{
Key: "bar",
Operator: api.NodeSelectorOpLt,
Operator: core.NodeSelectorOpLt,
Values: []string{"7"},
}},
out: mustParse("bar<7"),
@ -241,7 +241,7 @@ func TestNodeSelectorRequirementsAsSelector(t *testing.T) {
func TestSysctlsFromPodAnnotation(t *testing.T) {
type Test struct {
annotation string
expectValue []api.Sysctl
expectValue []core.Sysctl
expectErr bool
}
for i, test := range []Test{
@ -259,11 +259,11 @@ func TestSysctlsFromPodAnnotation(t *testing.T) {
},
{
annotation: "foo.bar=",
expectValue: []api.Sysctl{{Name: "foo.bar", Value: ""}},
expectValue: []core.Sysctl{{Name: "foo.bar", Value: ""}},
},
{
annotation: "foo.bar=42",
expectValue: []api.Sysctl{{Name: "foo.bar", Value: "42"}},
expectValue: []core.Sysctl{{Name: "foo.bar", Value: "42"}},
},
{
annotation: "foo.bar=42,",
@ -271,7 +271,7 @@ func TestSysctlsFromPodAnnotation(t *testing.T) {
},
{
annotation: "foo.bar=42,abc.def=1",
expectValue: []api.Sysctl{{Name: "foo.bar", Value: "42"}, {Name: "abc.def", Value: "1"}},
expectValue: []core.Sysctl{{Name: "foo.bar", Value: "42"}, {Name: "abc.def", Value: "1"}},
},
} {
sysctls, err := SysctlsFromPodAnnotation(test.annotation)
@ -301,7 +301,7 @@ func TestGetNodeAffinityFromAnnotations(t *testing.T) {
},
{
annotations: map[string]string{
api.AlphaStorageNodeAffinityAnnotation: `{
core.AlphaStorageNodeAffinityAnnotation: `{
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{ "matchExpressions": [
@ -321,7 +321,7 @@ func TestGetNodeAffinityFromAnnotations(t *testing.T) {
},
{
annotations: map[string]string{
api.AlphaStorageNodeAffinityAnnotation: `[{
core.AlphaStorageNodeAffinityAnnotation: `[{
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{ "matchExpressions": [
@ -341,7 +341,7 @@ func TestGetNodeAffinityFromAnnotations(t *testing.T) {
},
{
annotations: map[string]string{
api.AlphaStorageNodeAffinityAnnotation: `{
core.AlphaStorageNodeAffinityAnnotation: `{
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms":
"matchExpressions": [
@ -374,23 +374,23 @@ func TestGetNodeAffinityFromAnnotations(t *testing.T) {
func TestIsHugePageResourceName(t *testing.T) {
testCases := []struct {
name api.ResourceName
name core.ResourceName
result bool
}{
{
name: api.ResourceName("hugepages-2Mi"),
name: core.ResourceName("hugepages-2Mi"),
result: true,
},
{
name: api.ResourceName("hugepages-1Gi"),
name: core.ResourceName("hugepages-1Gi"),
result: true,
},
{
name: api.ResourceName("cpu"),
name: core.ResourceName("cpu"),
result: false,
},
{
name: api.ResourceName("memory"),
name: core.ResourceName("memory"),
result: false,
},
}
@ -404,20 +404,20 @@ func TestIsHugePageResourceName(t *testing.T) {
func TestHugePageResourceName(t *testing.T) {
testCases := []struct {
pageSize resource.Quantity
name api.ResourceName
name core.ResourceName
}{
{
pageSize: resource.MustParse("2Mi"),
name: api.ResourceName("hugepages-2Mi"),
name: core.ResourceName("hugepages-2Mi"),
},
{
pageSize: resource.MustParse("1Gi"),
name: api.ResourceName("hugepages-1Gi"),
name: core.ResourceName("hugepages-1Gi"),
},
{
// verify we do not regress our canonical representation
pageSize: *resource.NewQuantity(int64(2097152), resource.BinarySI),
name: api.ResourceName("hugepages-2Mi"),
name: core.ResourceName("hugepages-2Mi"),
},
}
for _, testCase := range testCases {
@ -429,22 +429,22 @@ func TestHugePageResourceName(t *testing.T) {
func TestHugePageSizeFromResourceName(t *testing.T) {
testCases := []struct {
name api.ResourceName
name core.ResourceName
expectErr bool
pageSize resource.Quantity
}{
{
name: api.ResourceName("hugepages-2Mi"),
name: core.ResourceName("hugepages-2Mi"),
pageSize: resource.MustParse("2Mi"),
expectErr: false,
},
{
name: api.ResourceName("hugepages-1Gi"),
name: core.ResourceName("hugepages-1Gi"),
pageSize: resource.MustParse("1Gi"),
expectErr: false,
},
{
name: api.ResourceName("hugepages-bad"),
name: core.ResourceName("hugepages-bad"),
expectErr: true,
},
}
@ -462,19 +462,19 @@ func TestHugePageSizeFromResourceName(t *testing.T) {
func TestIsOvercommitAllowed(t *testing.T) {
testCases := []struct {
name api.ResourceName
name core.ResourceName
allowed bool
}{
{
name: api.ResourceCPU,
name: core.ResourceCPU,
allowed: true,
},
{
name: api.ResourceMemory,
name: core.ResourceMemory,
allowed: true,
},
{
name: api.ResourceNvidiaGPU,
name: core.ResourceNvidiaGPU,
allowed: false,
},
{

View File

@ -21,12 +21,12 @@ package qos
import (
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/core/helper"
)
func isSupportedQoSComputeResource(name api.ResourceName) bool {
supportedQoSComputeResources := sets.NewString(string(api.ResourceCPU), string(api.ResourceMemory))
func isSupportedQoSComputeResource(name core.ResourceName) bool {
supportedQoSComputeResources := sets.NewString(string(core.ResourceCPU), string(core.ResourceMemory))
return supportedQoSComputeResources.Has(string(name)) || helper.IsHugePageResourceName(name)
}
@ -34,9 +34,9 @@ func isSupportedQoSComputeResource(name api.ResourceName) bool {
// A pod is besteffort if none of its containers have specified any requests or limits.
// A pod is guaranteed only when requests and limits are specified for all the containers and they are equal.
// A pod is burstable if limits and requests do not match across all containers.
func GetPodQOS(pod *api.Pod) api.PodQOSClass {
requests := api.ResourceList{}
limits := api.ResourceList{}
func GetPodQOS(pod *core.Pod) core.PodQOSClass {
requests := core.ResourceList{}
limits := core.ResourceList{}
zeroQuantity := resource.MustParse("0")
isGuaranteed := true
for _, container := range pod.Spec.Containers {
@ -73,12 +73,12 @@ func GetPodQOS(pod *api.Pod) api.PodQOSClass {
}
}
if !qosLimitsFound.HasAll(string(api.ResourceMemory), string(api.ResourceCPU)) {
if !qosLimitsFound.HasAll(string(core.ResourceMemory), string(core.ResourceCPU)) {
isGuaranteed = false
}
}
if len(requests) == 0 && len(limits) == 0 {
return api.PodQOSBestEffort
return core.PodQOSBestEffort
}
// Check is requests match limits for all resources.
if isGuaranteed {
@ -91,7 +91,7 @@ func GetPodQOS(pod *api.Pod) api.PodQOSClass {
}
if isGuaranteed &&
len(requests) == len(limits) {
return api.PodQOSGuaranteed
return core.PodQOSGuaranteed
}
return api.PodQOSBurstable
return core.PodQOSBurstable
}

View File

@ -23,9 +23,9 @@ import (
"k8s.io/apimachinery/pkg/apimachinery/registered"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/core/v1"
)
func init() {
@ -36,9 +36,9 @@ func init() {
func Install(groupFactoryRegistry announced.APIGroupFactoryRegistry, registry *registered.APIRegistrationManager, scheme *runtime.Scheme) {
if err := announced.NewGroupMetaFactory(
&announced.GroupMetaFactoryArgs{
GroupName: api.GroupName,
GroupName: core.GroupName,
VersionPreferenceOrder: []string{v1.SchemeGroupVersion.Version},
AddInternalObjectsToScheme: api.AddToScheme,
AddInternalObjectsToScheme: core.AddToScheme,
RootScopedKinds: sets.NewString(
"Node",
"Namespace",

View File

@ -25,8 +25,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
internal "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/legacyscheme"
internal "k8s.io/kubernetes/pkg/apis/core"
)
func TestResourceVersioner(t *testing.T) {

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package api
package core
import "encoding/json"

View File

@ -17,7 +17,7 @@ limitations under the License.
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package api
package core
import (
"k8s.io/apimachinery/pkg/runtime/schema"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package api
package core
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package api
package core
import (
"k8s.io/apimachinery/pkg/api/resource"

View File

@ -17,7 +17,7 @@ limitations under the License.
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package api
package core
import "fmt"

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package api
package core
import "testing"

View File

@ -17,7 +17,7 @@ limitations under the License.
//TODO: consider making these methods functions, because we don't want helper
//functions in the k8s.io/api repo.
package api
package core
// MatchToleration checks if the toleration matches tolerationToMatch. Tolerations are unique by <key,effect,operator,value>,
// if the two tolerations have same <key,effect,operator,value> combination, regard as they match.

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package api
package core
import (
"k8s.io/apimachinery/pkg/api/resource"

View File

@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/extensions"
)
@ -38,10 +38,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
switch a := objA.(type) {
case *v1.Pod:
switch b := objB.(type) {
case *api.Pod:
case *core.Pod:
return true, Convert_v1_Pod_To_api_Pod(a, b, s)
}
case *api.Pod:
case *core.Pod:
switch b := objB.(type) {
case *v1.Pod:
return true, Convert_api_Pod_To_v1_Pod(a, b, s)
@ -49,10 +49,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
case *v1.Event:
switch b := objB.(type) {
case *api.Event:
case *core.Event:
return true, Convert_v1_Event_To_api_Event(a, b, s)
}
case *api.Event:
case *core.Event:
switch b := objB.(type) {
case *v1.Event:
return true, Convert_api_Event_To_v1_Event(a, b, s)
@ -60,10 +60,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
case *v1.ReplicationController:
switch b := objB.(type) {
case *api.ReplicationController:
case *core.ReplicationController:
return true, Convert_v1_ReplicationController_To_api_ReplicationController(a, b, s)
}
case *api.ReplicationController:
case *core.ReplicationController:
switch b := objB.(type) {
case *v1.ReplicationController:
return true, Convert_api_ReplicationController_To_v1_ReplicationController(a, b, s)
@ -71,10 +71,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
case *v1.Node:
switch b := objB.(type) {
case *api.Node:
case *core.Node:
return true, Convert_v1_Node_To_api_Node(a, b, s)
}
case *api.Node:
case *core.Node:
switch b := objB.(type) {
case *v1.Node:
return true, Convert_api_Node_To_v1_Node(a, b, s)
@ -82,10 +82,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
case *v1.Namespace:
switch b := objB.(type) {
case *api.Namespace:
case *core.Namespace:
return true, Convert_v1_Namespace_To_api_Namespace(a, b, s)
}
case *api.Namespace:
case *core.Namespace:
switch b := objB.(type) {
case *v1.Namespace:
return true, Convert_api_Namespace_To_v1_Namespace(a, b, s)
@ -93,10 +93,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
case *v1.Service:
switch b := objB.(type) {
case *api.Service:
case *core.Service:
return true, Convert_v1_Service_To_api_Service(a, b, s)
}
case *api.Service:
case *core.Service:
switch b := objB.(type) {
case *v1.Service:
return true, Convert_api_Service_To_v1_Service(a, b, s)
@ -104,10 +104,10 @@ func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
case *v1.Endpoints:
switch b := objB.(type) {
case *api.Endpoints:
case *core.Endpoints:
return true, Convert_v1_Endpoints_To_api_Endpoints(a, b, s)
}
case *api.Endpoints:
case *core.Endpoints:
switch b := objB.(type) {
case *v1.Endpoints:
return true, Convert_api_Endpoints_To_v1_Endpoints(a, b, s)
@ -257,7 +257,7 @@ func Convert_v1_ReplicationControllerStatus_to_extensions_ReplicaSetStatus(in *v
for _, cond := range in.Conditions {
out.Conditions = append(out.Conditions, extensions.ReplicaSetCondition{
Type: extensions.ReplicaSetConditionType(cond.Type),
Status: api.ConditionStatus(cond.Status),
Status: core.ConditionStatus(cond.Status),
LastTransitionTime: cond.LastTransitionTime,
Reason: cond.Reason,
Message: cond.Message,
@ -317,7 +317,7 @@ func Convert_extensions_ReplicaSetStatus_to_v1_ReplicationControllerStatus(in *e
return nil
}
func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *api.ReplicationControllerSpec, out *v1.ReplicationControllerSpec, s conversion.Scope) error {
func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *core.ReplicationControllerSpec, out *v1.ReplicationControllerSpec, s conversion.Scope) error {
out.Replicas = &in.Replicas
out.MinReadySeconds = in.MinReadySeconds
out.Selector = in.Selector
@ -332,14 +332,14 @@ func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *a
return nil
}
func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *v1.ReplicationControllerSpec, out *api.ReplicationControllerSpec, s conversion.Scope) error {
func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *v1.ReplicationControllerSpec, out *core.ReplicationControllerSpec, s conversion.Scope) error {
if in.Replicas != nil {
out.Replicas = *in.Replicas
}
out.MinReadySeconds = in.MinReadySeconds
out.Selector = in.Selector
if in.Template != nil {
out.Template = new(api.PodTemplateSpec)
out.Template = new(core.PodTemplateSpec)
if err := Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in.Template, out.Template, s); err != nil {
return err
}
@ -349,7 +349,7 @@ func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *v
return nil
}
func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec, out *v1.PodTemplateSpec, s conversion.Scope) error {
func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *core.PodTemplateSpec, out *v1.PodTemplateSpec, s conversion.Scope) error {
if err := autoConvert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in, out, s); err != nil {
return err
}
@ -357,7 +357,7 @@ func Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in *api.PodTemplateSpec,
return nil
}
func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *v1.PodTemplateSpec, out *api.PodTemplateSpec, s conversion.Scope) error {
func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *v1.PodTemplateSpec, out *core.PodTemplateSpec, s conversion.Scope) error {
if err := autoConvert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in, out, s); err != nil {
return err
}
@ -367,7 +367,7 @@ func Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in *v1.PodTemplateSpec, o
// The following two v1.PodSpec conversions are done here to support v1.ServiceAccount
// as an alias for ServiceAccountName.
func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conversion.Scope) error {
func Convert_api_PodSpec_To_v1_PodSpec(in *core.PodSpec, out *v1.PodSpec, s conversion.Scope) error {
if err := autoConvert_api_PodSpec_To_v1_PodSpec(in, out, s); err != nil {
return err
}
@ -386,7 +386,7 @@ func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conve
return nil
}
func Convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conversion.Scope) error {
func Convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *core.PodSpec, s conversion.Scope) error {
if err := autoConvert_v1_PodSpec_To_api_PodSpec(in, out, s); err != nil {
return err
}
@ -400,7 +400,7 @@ func Convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conve
// the host namespace fields have to be handled specially for backward compatibility
// with v1.0.0
if out.SecurityContext == nil {
out.SecurityContext = new(api.PodSecurityContext)
out.SecurityContext = new(core.PodSecurityContext)
}
out.SecurityContext.HostNetwork = in.HostNetwork
out.SecurityContext.HostPID = in.HostPID
@ -409,7 +409,7 @@ func Convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conve
return nil
}
func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *v1.Pod, s conversion.Scope) error {
func Convert_api_Pod_To_v1_Pod(in *core.Pod, out *v1.Pod, s conversion.Scope) error {
if err := autoConvert_api_Pod_To_v1_Pod(in, out, s); err != nil {
return err
}
@ -431,7 +431,7 @@ func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *v1.Pod, s conversion.Scope) err
return nil
}
func Convert_v1_Secret_To_api_Secret(in *v1.Secret, out *api.Secret, s conversion.Scope) error {
func Convert_v1_Secret_To_api_Secret(in *v1.Secret, out *core.Secret, s conversion.Scope) error {
if err := autoConvert_v1_Secret_To_api_Secret(in, out, s); err != nil {
return err
}
@ -448,7 +448,7 @@ func Convert_v1_Secret_To_api_Secret(in *v1.Secret, out *api.Secret, s conversio
return nil
}
func Convert_api_SecurityContext_To_v1_SecurityContext(in *api.SecurityContext, out *v1.SecurityContext, s conversion.Scope) error {
func Convert_api_SecurityContext_To_v1_SecurityContext(in *core.SecurityContext, out *v1.SecurityContext, s conversion.Scope) error {
if in.Capabilities != nil {
out.Capabilities = new(v1.Capabilities)
if err := Convert_api_Capabilities_To_v1_Capabilities(in.Capabilities, out.Capabilities, s); err != nil {
@ -473,7 +473,7 @@ func Convert_api_SecurityContext_To_v1_SecurityContext(in *api.SecurityContext,
return nil
}
func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error {
func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *core.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error {
out.SupplementalGroups = in.SupplementalGroups
if in.SELinuxOptions != nil {
out.SELinuxOptions = new(v1.SELinuxOptions)
@ -489,10 +489,10 @@ func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurity
return nil
}
func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityContext, out *core.PodSecurityContext, s conversion.Scope) error {
out.SupplementalGroups = in.SupplementalGroups
if in.SELinuxOptions != nil {
out.SELinuxOptions = new(api.SELinuxOptions)
out.SELinuxOptions = new(core.SELinuxOptions)
if err := Convert_v1_SELinuxOptions_To_api_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
return err
}
@ -506,12 +506,12 @@ func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityC
}
// +k8s:conversion-fn=copy-only
func Convert_v1_ResourceList_To_api_ResourceList(in *v1.ResourceList, out *api.ResourceList, s conversion.Scope) error {
func Convert_v1_ResourceList_To_api_ResourceList(in *v1.ResourceList, out *core.ResourceList, s conversion.Scope) error {
if *in == nil {
return nil
}
if *out == nil {
*out = make(api.ResourceList, len(*in))
*out = make(core.ResourceList, len(*in))
}
for key, val := range *in {
// Moved to defaults
@ -520,7 +520,7 @@ func Convert_v1_ResourceList_To_api_ResourceList(in *v1.ResourceList, out *api.R
// const milliScale = -3
// val.RoundUp(milliScale)
(*out)[api.ResourceName(key)] = val
(*out)[core.ResourceName(key)] = val
}
return nil
}

View File

@ -32,10 +32,10 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/legacyscheme"
kapitesting "k8s.io/kubernetes/pkg/api/testing"
k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/core"
corev1 "k8s.io/kubernetes/pkg/apis/core/v1"
"k8s.io/kubernetes/pkg/apis/extensions"
utilpointer "k8s.io/kubernetes/pkg/util/pointer"
@ -59,7 +59,7 @@ func TestPodLogOptions(t *testing.T) {
TailLines: &tailLines,
LimitBytes: &limitBytes,
}
unversionedLogOptions := &api.PodLogOptions{
unversionedLogOptions := &core.PodLogOptions{
Container: "mycontainer",
Follow: true,
Previous: true,
@ -118,7 +118,7 @@ func TestPodLogOptions(t *testing.T) {
// query params -> unversioned
{
convertedLogOptions := &api.PodLogOptions{}
convertedLogOptions := &core.PodLogOptions{}
err := codec.DecodeParameters(expectedParameters, v1.SchemeGroupVersion, convertedLogOptions)
if err != nil {
t.Fatal(err)
@ -136,7 +136,7 @@ func TestPodSpecConversion(t *testing.T) {
// Test internal -> v1. Should have both alias (DeprecatedServiceAccount)
// and new field (ServiceAccountName).
i := &api.PodSpec{
i := &core.PodSpec{
ServiceAccountName: name,
}
v := v1.PodSpec{}
@ -164,13 +164,13 @@ func TestPodSpecConversion(t *testing.T) {
{ServiceAccountName: name, DeprecatedServiceAccount: other},
}
for k, v := range testCases {
got := api.PodSpec{}
got := core.PodSpec{}
err := legacyscheme.Scheme.Convert(v, &got, nil)
if err != nil {
t.Fatalf("unexpected error for case %d: %v", k, err)
}
if got.ServiceAccountName != name {
t.Fatalf("want api.ServiceAccountName %q, got %q", name, got.ServiceAccountName)
t.Fatalf("want core.ServiceAccountName %q, got %q", name, got.ServiceAccountName)
}
}
}
@ -181,7 +181,7 @@ func TestResourceListConversion(t *testing.T) {
tests := []struct {
input v1.ResourceList
expected api.ResourceList
expected core.ResourceList
}{
{ // No changes necessary.
input: v1.ResourceList{
@ -189,10 +189,10 @@ func TestResourceListConversion(t *testing.T) {
v1.ResourceCPU: resource.MustParse("100m"),
v1.ResourceStorage: resource.MustParse("1G"),
},
expected: api.ResourceList{
api.ResourceMemory: resource.MustParse("30M"),
api.ResourceCPU: resource.MustParse("100m"),
api.ResourceStorage: resource.MustParse("1G"),
expected: core.ResourceList{
core.ResourceMemory: resource.MustParse("30M"),
core.ResourceCPU: resource.MustParse("100m"),
core.ResourceStorage: resource.MustParse("1G"),
},
},
{ // Nano-scale values should be rounded up to milli-scale.
@ -200,9 +200,9 @@ func TestResourceListConversion(t *testing.T) {
v1.ResourceCPU: resource.MustParse("3.000023m"),
v1.ResourceMemory: resource.MustParse("500.000050m"),
},
expected: api.ResourceList{
api.ResourceCPU: resource.MustParse("4m"),
api.ResourceMemory: resource.MustParse("501m"),
expected: core.ResourceList{
core.ResourceCPU: resource.MustParse("4m"),
core.ResourceMemory: resource.MustParse("501m"),
},
},
{ // Large values should still be accurate.
@ -210,19 +210,19 @@ func TestResourceListConversion(t *testing.T) {
v1.ResourceCPU: *bigMilliQuantity.Copy(),
v1.ResourceStorage: *bigMilliQuantity.Copy(),
},
expected: api.ResourceList{
api.ResourceCPU: *bigMilliQuantity.Copy(),
api.ResourceStorage: *bigMilliQuantity.Copy(),
expected: core.ResourceList{
core.ResourceCPU: *bigMilliQuantity.Copy(),
core.ResourceStorage: *bigMilliQuantity.Copy(),
},
},
}
for i, test := range tests {
output := api.ResourceList{}
output := core.ResourceList{}
// defaulting is a separate step from conversion that is applied when reading from the API or from etcd.
// perform that step explicitly.
k8s_api_v1.SetDefaults_ResourceList(&test.input)
corev1.SetDefaults_ResourceList(&test.input)
err := legacyscheme.Scheme.Convert(&test.input, &output, nil)
if err != nil {
@ -306,14 +306,14 @@ func TestReplicationControllerConversion(t *testing.T) {
for _, in := range inputs {
rs := &extensions.ReplicaSet{}
// Use in.DeepCopy() to avoid sharing pointers with `in`.
if err := k8s_api_v1.Convert_v1_ReplicationController_to_extensions_ReplicaSet(in.DeepCopy(), rs, nil); err != nil {
if err := corev1.Convert_v1_ReplicationController_to_extensions_ReplicaSet(in.DeepCopy(), rs, nil); err != nil {
t.Errorf("can't convert RC to RS: %v", err)
continue
}
// Round-trip RS before converting back to RC.
rs = roundTripRS(t, rs)
out := &v1.ReplicationController{}
if err := k8s_api_v1.Convert_extensions_ReplicaSet_to_v1_ReplicationController(rs, out, nil); err != nil {
if err := corev1.Convert_extensions_ReplicaSet_to_v1_ReplicationController(rs, out, nil); err != nil {
t.Errorf("can't convert RS to RC: %v", err)
continue
}

View File

@ -27,14 +27,14 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/kubernetes/pkg/api/legacyscheme"
k8s_api_v1 "k8s.io/kubernetes/pkg/api/v1"
corev1 "k8s.io/kubernetes/pkg/apis/core/v1"
// enforce that all types are installed
_ "k8s.io/kubernetes/pkg/api/testapi"
)
func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
codec := legacyscheme.Codecs.LegacyCodec(v1.SchemeGroupVersion)
codec := legacyscheme.Codecs.LegacyCodec(corev1.SchemeGroupVersion)
data, err := runtime.Encode(codec, obj)
if err != nil {
t.Errorf("%v\n %#v", err, obj)
@ -1129,7 +1129,7 @@ func TestSetMinimumScalePod(t *testing.T) {
pod := &v1.Pod{
Spec: s,
}
k8s_api_v1.SetObjectDefaults_Pod(pod)
corev1.SetObjectDefaults_Pod(pod)
if expect := resource.MustParse("1m"); expect.Cmp(pod.Spec.Containers[0].Resources.Requests[v1.ResourceMemory]) != 0 {
t.Errorf("did not round resources: %#v", pod.Spec.Containers[0].Resources)

View File

@ -14,10 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/api
// +k8s:conversion-gen-external-types=../../../vendor/k8s.io/api/core/v1
// +k8s:conversion-gen=k8s.io/kubernetes/pkg/apis/core
// +k8s:conversion-gen-external-types=../../../../vendor/k8s.io/api/core/v1
// +k8s:defaulter-gen=TypeMeta
// +k8s:defaulter-gen-input=../../../vendor/k8s.io/api/core/v1
// +k8s:defaulter-gen-input=../../../../vendor/k8s.io/api/core/v1
// Package v1 is the v1 version of the API.
package v1 // import "k8s.io/kubernetes/pkg/api/v1"
package v1 // import "k8s.io/kubernetes/pkg/apis/core/v1"

View File

@ -26,7 +26,7 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/pkg/api/helper"
"k8s.io/kubernetes/pkg/apis/core/helper"
)
// IsExtendedResourceName returns true if the resource name is not in the

View File

@ -20,7 +20,7 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/sets"
v1helper "k8s.io/kubernetes/pkg/api/v1/helper"
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
)
// QOSList is a set of (resource name, QoS class) pairs.

View File

@ -22,9 +22,9 @@ import (
"k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/helper/qos"
k8sv1 "k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/core/helper/qos"
corev1 "k8s.io/kubernetes/pkg/apis/core/v1"
)
func TestGetPodQOS(t *testing.T) {
@ -142,11 +142,11 @@ func TestGetPodQOS(t *testing.T) {
t.Errorf("[%d]: invalid qos pod %s, expected: %s, actual: %s", id, testCase.pod.Name, testCase.expected, actual)
}
// Convert v1.Pod to api.Pod, and then check against `api.helper.GetPodQOS`.
pod := api.Pod{}
k8sv1.Convert_v1_Pod_To_api_Pod(testCase.pod, &pod, nil)
// Convert v1.Pod to core.Pod, and then check against `core.helper.GetPodQOS`.
pod := core.Pod{}
corev1.Convert_v1_Pod_To_api_Pod(testCase.pod, &pod, nil)
if actual := qos.GetPodQOS(&pod); api.PodQOSClass(testCase.expected) != actual {
if actual := qos.GetPodQOS(&pod); core.PodQOSClass(testCase.expected) != actual {
t.Errorf("[%d]: conversion invalid qos pod %s, expected: %s, actual: %s", id, testCase.pod.Name, testCase.expected, actual)
}
}

View File

@ -27,8 +27,8 @@ import (
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api/helper"
v1helper "k8s.io/kubernetes/pkg/api/v1/helper"
"k8s.io/kubernetes/pkg/apis/core/helper"
v1helper "k8s.io/kubernetes/pkg/apis/core/v1/helper"
)
const isNegativeErrorMsg string = `must be greater than or equal to 0`

File diff suppressed because it is too large Load Diff

View File

@ -16,4 +16,4 @@ limitations under the License.
// Package validation has functions for validating the correctness of api
// objects and explaining what is wrong with them when they aren't valid.
package validation // import "k8s.io/kubernetes/pkg/api/validation"
package validation // import "k8s.io/kubernetes/pkg/apis/core/validation"

View File

@ -24,12 +24,12 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/validation"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/core"
)
// ValidateEvent makes sure that the event makes sense.
func ValidateEvent(event *api.Event) field.ErrorList {
func ValidateEvent(event *core.Event) field.ErrorList {
allErrs := field.ErrorList{}
// Make sure event.Namespace and the involvedObject.Namespace agree

View File

@ -20,69 +20,69 @@ import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/apis/core"
)
func TestValidateEvent(t *testing.T) {
table := []struct {
*api.Event
*core.Event
valid bool
}{
{
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test1",
Namespace: "foo",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
Namespace: "bar",
Kind: "Pod",
},
},
false,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test2",
Namespace: "aoeu-_-aoeu",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
Namespace: "aoeu-_-aoeu",
Kind: "Pod",
},
},
false,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test3",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "v1",
Kind: "Node",
},
},
true,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test4",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "v1",
Kind: "Namespace",
},
},
true,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test5",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1",
Kind: "NoKind",
Namespace: metav1.NamespaceDefault,
@ -90,12 +90,12 @@ func TestValidateEvent(t *testing.T) {
},
true,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test6",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1",
Kind: "Job",
Namespace: "foo",
@ -103,12 +103,12 @@ func TestValidateEvent(t *testing.T) {
},
false,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test7",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "extensions/v1beta1",
Kind: "Job",
Namespace: metav1.NamespaceDefault,
@ -116,12 +116,12 @@ func TestValidateEvent(t *testing.T) {
},
true,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test8",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "other/v1beta1",
Kind: "Job",
Namespace: "foo",
@ -129,12 +129,12 @@ func TestValidateEvent(t *testing.T) {
},
false,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test9",
Namespace: "foo",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "other/v1beta1",
Kind: "Job",
Namespace: "foo",
@ -142,12 +142,12 @@ func TestValidateEvent(t *testing.T) {
},
true,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test10",
Namespace: metav1.NamespaceDefault,
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "extensions",
Kind: "Job",
Namespace: "foo",
@ -155,12 +155,12 @@ func TestValidateEvent(t *testing.T) {
},
false,
}, {
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test11",
Namespace: "foo",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
// must register in v1beta1 to be true
APIVersion: "extensions/v1beta1",
Kind: "Job",
@ -170,12 +170,12 @@ func TestValidateEvent(t *testing.T) {
true,
},
{
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test12",
Namespace: "foo",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "other/v1beta1",
Kind: "FooBar",
Namespace: "bar",
@ -184,12 +184,12 @@ func TestValidateEvent(t *testing.T) {
false,
},
{
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test13",
Namespace: "",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "other/v1beta1",
Kind: "FooBar",
Namespace: "bar",
@ -198,12 +198,12 @@ func TestValidateEvent(t *testing.T) {
false,
},
{
&api.Event{
&core.Event{
ObjectMeta: metav1.ObjectMeta{
Name: "test14",
Namespace: "foo",
},
InvolvedObject: api.ObjectReference{
InvolvedObject: core.ObjectReference{
APIVersion: "other/v1beta1",
Kind: "FooBar",
Namespace: "",

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -18,7 +18,7 @@ limitations under the License.
// This file was autogenerated by deepcopy-gen. Do not edit it manually!
package api
package core
import (
resource "k8s.io/apimachinery/pkg/api/resource"