Run copy.sh to update client-go for pvcs

pull/6/head
Matthew Wong 2016-09-02 10:48:39 -04:00
parent dfccabe22f
commit 19ee7d4c6b
10 changed files with 453 additions and 9 deletions

View File

@ -33,6 +33,7 @@ type CoreInterface interface {
NamespacesGetter
NodesGetter
PersistentVolumesGetter
PersistentVolumeClaimsGetter
PodsGetter
PodTemplatesGetter
ReplicationControllersGetter
@ -79,6 +80,10 @@ func (c *CoreClient) PersistentVolumes() PersistentVolumeInterface {
return newPersistentVolumes(c)
}
func (c *CoreClient) PersistentVolumeClaims(namespace string) PersistentVolumeClaimInterface {
return newPersistentVolumeClaims(c, namespace)
}
func (c *CoreClient) Pods(namespace string) PodInterface {
return newPods(c, namespace)
}

View File

@ -58,6 +58,10 @@ func (c *FakeCore) PersistentVolumes() v1.PersistentVolumeInterface {
return &FakePersistentVolumes{c}
}
func (c *FakeCore) PersistentVolumeClaims(namespace string) v1.PersistentVolumeClaimInterface {
return &FakePersistentVolumeClaims{c, namespace}
}
func (c *FakeCore) Pods(namespace string) v1.PodInterface {
return &FakePods{c, namespace}
}

View File

@ -0,0 +1,127 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package fake
import (
api "k8s.io/client-go/1.4/pkg/api"
unversioned "k8s.io/client-go/1.4/pkg/api/unversioned"
v1 "k8s.io/client-go/1.4/pkg/api/v1"
labels "k8s.io/client-go/1.4/pkg/labels"
watch "k8s.io/client-go/1.4/pkg/watch"
testing "k8s.io/client-go/1.4/testing"
)
// FakePersistentVolumeClaims implements PersistentVolumeClaimInterface
type FakePersistentVolumeClaims struct {
Fake *FakeCore
ns string
}
var persistentvolumeclaimsResource = unversioned.GroupVersionResource{Group: "", Version: "v1", Resource: "persistentvolumeclaims"}
func (c *FakePersistentVolumeClaims) Create(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(persistentvolumeclaimsResource, c.ns, persistentVolumeClaim), &v1.PersistentVolumeClaim{})
if obj == nil {
return nil, err
}
return obj.(*v1.PersistentVolumeClaim), err
}
func (c *FakePersistentVolumeClaims) Update(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(persistentvolumeclaimsResource, c.ns, persistentVolumeClaim), &v1.PersistentVolumeClaim{})
if obj == nil {
return nil, err
}
return obj.(*v1.PersistentVolumeClaim), err
}
func (c *FakePersistentVolumeClaims) UpdateStatus(persistentVolumeClaim *v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateSubresourceAction(persistentvolumeclaimsResource, "status", c.ns, persistentVolumeClaim), &v1.PersistentVolumeClaim{})
if obj == nil {
return nil, err
}
return obj.(*v1.PersistentVolumeClaim), err
}
func (c *FakePersistentVolumeClaims) Delete(name string, options *api.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteAction(persistentvolumeclaimsResource, c.ns, name), &v1.PersistentVolumeClaim{})
return err
}
func (c *FakePersistentVolumeClaims) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
action := testing.NewDeleteCollectionAction(persistentvolumeclaimsResource, c.ns, listOptions)
_, err := c.Fake.Invokes(action, &v1.PersistentVolumeClaimList{})
return err
}
func (c *FakePersistentVolumeClaims) Get(name string) (result *v1.PersistentVolumeClaim, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(persistentvolumeclaimsResource, c.ns, name), &v1.PersistentVolumeClaim{})
if obj == nil {
return nil, err
}
return obj.(*v1.PersistentVolumeClaim), err
}
func (c *FakePersistentVolumeClaims) List(opts api.ListOptions) (result *v1.PersistentVolumeClaimList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(persistentvolumeclaimsResource, c.ns, opts), &v1.PersistentVolumeClaimList{})
if obj == nil {
return nil, err
}
label := opts.LabelSelector
if label == nil {
label = labels.Everything()
}
list := &v1.PersistentVolumeClaimList{}
for _, item := range obj.(*v1.PersistentVolumeClaimList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested persistentVolumeClaims.
func (c *FakePersistentVolumeClaims) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(persistentvolumeclaimsResource, c.ns, opts))
}
// Patch applies the patch and returns the patched persistentVolumeClaim.
func (c *FakePersistentVolumeClaims) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolumeClaim, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(persistentvolumeclaimsResource, c.ns, name, data, subresources...), &v1.PersistentVolumeClaim{})
if obj == nil {
return nil, err
}
return obj.(*v1.PersistentVolumeClaim), err
}

View File

@ -28,6 +28,8 @@ type NodeExpansion interface{}
type PersistentVolumeExpansion interface{}
type PersistentVolumeClaimExpansion interface{}
type PodTemplateExpansion interface{}
type ReplicationControllerExpansion interface{}

View File

@ -0,0 +1,165 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1
import (
api "k8s.io/client-go/1.4/pkg/api"
v1 "k8s.io/client-go/1.4/pkg/api/v1"
watch "k8s.io/client-go/1.4/pkg/watch"
)
// PersistentVolumeClaimsGetter has a method to return a PersistentVolumeClaimInterface.
// A group's client should implement this interface.
type PersistentVolumeClaimsGetter interface {
PersistentVolumeClaims(namespace string) PersistentVolumeClaimInterface
}
// PersistentVolumeClaimInterface has methods to work with PersistentVolumeClaim resources.
type PersistentVolumeClaimInterface interface {
Create(*v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
Update(*v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
UpdateStatus(*v1.PersistentVolumeClaim) (*v1.PersistentVolumeClaim, error)
Delete(name string, options *api.DeleteOptions) error
DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error
Get(name string) (*v1.PersistentVolumeClaim, error)
List(opts api.ListOptions) (*v1.PersistentVolumeClaimList, error)
Watch(opts api.ListOptions) (watch.Interface, error)
Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolumeClaim, err error)
PersistentVolumeClaimExpansion
}
// persistentVolumeClaims implements PersistentVolumeClaimInterface
type persistentVolumeClaims struct {
client *CoreClient
ns string
}
// newPersistentVolumeClaims returns a PersistentVolumeClaims
func newPersistentVolumeClaims(c *CoreClient, namespace string) *persistentVolumeClaims {
return &persistentVolumeClaims{
client: c,
ns: namespace,
}
}
// Create takes the representation of a persistentVolumeClaim and creates it. Returns the server's representation of the persistentVolumeClaim, and an error, if there is any.
func (c *persistentVolumeClaims) Create(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Post().
Namespace(c.ns).
Resource("persistentvolumeclaims").
Body(persistentVolumeClaim).
Do().
Into(result)
return
}
// Update takes the representation of a persistentVolumeClaim and updates it. Returns the server's representation of the persistentVolumeClaim, and an error, if there is any.
func (c *persistentVolumeClaims) Update(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Put().
Namespace(c.ns).
Resource("persistentvolumeclaims").
Name(persistentVolumeClaim.Name).
Body(persistentVolumeClaim).
Do().
Into(result)
return
}
func (c *persistentVolumeClaims) UpdateStatus(persistentVolumeClaim *v1.PersistentVolumeClaim) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Put().
Namespace(c.ns).
Resource("persistentvolumeclaims").
Name(persistentVolumeClaim.Name).
SubResource("status").
Body(persistentVolumeClaim).
Do().
Into(result)
return
}
// Delete takes name of the persistentVolumeClaim and deletes it. Returns an error if one occurs.
func (c *persistentVolumeClaims) Delete(name string, options *api.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("persistentvolumeclaims").
Name(name).
Body(options).
Do().
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *persistentVolumeClaims) DeleteCollection(options *api.DeleteOptions, listOptions api.ListOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("persistentvolumeclaims").
VersionedParams(&listOptions, api.ParameterCodec).
Body(options).
Do().
Error()
}
// Get takes name of the persistentVolumeClaim, and returns the corresponding persistentVolumeClaim object, and an error if there is any.
func (c *persistentVolumeClaims) Get(name string) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Get().
Namespace(c.ns).
Resource("persistentvolumeclaims").
Name(name).
Do().
Into(result)
return
}
// List takes label and field selectors, and returns the list of PersistentVolumeClaims that match those selectors.
func (c *persistentVolumeClaims) List(opts api.ListOptions) (result *v1.PersistentVolumeClaimList, err error) {
result = &v1.PersistentVolumeClaimList{}
err = c.client.Get().
Namespace(c.ns).
Resource("persistentvolumeclaims").
VersionedParams(&opts, api.ParameterCodec).
Do().
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested persistentVolumeClaims.
func (c *persistentVolumeClaims) Watch(opts api.ListOptions) (watch.Interface, error) {
return c.client.Get().
Prefix("watch").
Namespace(c.ns).
Resource("persistentvolumeclaims").
VersionedParams(&opts, api.ParameterCodec).
Watch()
}
// Patch applies the patch and returns the patched persistentVolumeClaim.
func (c *persistentVolumeClaims) Patch(name string, pt api.PatchType, data []byte, subresources ...string) (result *v1.PersistentVolumeClaim, err error) {
result = &v1.PersistentVolumeClaim{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("persistentvolumeclaims").
SubResource(subresources...).
Name(name).
Body(data).
Do().
Into(result)
return
}

View File

@ -325,7 +325,7 @@ func NewGenericServerResponse(code int, verb string, qualifiedResource unversion
default:
if code >= 500 {
reason = unversioned.StatusReasonInternalError
message = "an error on the server has prevented the request from succeeding"
message = fmt.Sprintf("an error on the server (%q) has prevented the request from succeeding", serverMessage)
}
}
switch {

View File

@ -434,6 +434,8 @@ type PersistentVolumeList struct {
Items []PersistentVolume `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// +genclient=true
// PersistentVolumeClaim is a user's request for and claim to a persistent volume
type PersistentVolumeClaim struct {
unversioned.TypeMeta `json:",inline"`

View File

@ -3358,17 +3358,50 @@ func ValidateNamespaceFinalizeUpdate(newNamespace, oldNamespace *api.Namespace)
return allErrs
}
// Construct lookup map of old subset IPs to NodeNames.
func updateEpAddrToNodeNameMap(ipToNodeName map[string]string, addresses []api.EndpointAddress) {
for n := range addresses {
if addresses[n].NodeName == nil {
continue
}
ipToNodeName[addresses[n].IP] = *addresses[n].NodeName
}
}
// Build a map across all subsets of IP -> NodeName
func buildEndpointAddressNodeNameMap(subsets []api.EndpointSubset) map[string]string {
ipToNodeName := make(map[string]string)
for i := range subsets {
updateEpAddrToNodeNameMap(ipToNodeName, subsets[i].Addresses)
updateEpAddrToNodeNameMap(ipToNodeName, subsets[i].NotReadyAddresses)
}
return ipToNodeName
}
func validateEpAddrNodeNameTransition(addr *api.EndpointAddress, ipToNodeName map[string]string, fldPath *field.Path) field.ErrorList {
errList := field.ErrorList{}
existingNodeName, found := ipToNodeName[addr.IP]
if !found {
return errList
}
if addr.NodeName == nil || *addr.NodeName == existingNodeName {
return errList
}
// NodeName entry found for this endpoint IP, but user is attempting to change NodeName
return append(errList, field.Forbidden(fldPath, fmt.Sprintf("Cannot change NodeName for %s to %s", addr.IP, *addr.NodeName)))
}
// ValidateEndpoints tests if required fields are set.
func ValidateEndpoints(endpoints *api.Endpoints) field.ErrorList {
allErrs := ValidateObjectMeta(&endpoints.ObjectMeta, true, ValidateEndpointsName, field.NewPath("metadata"))
allErrs = append(allErrs, ValidateEndpointsSpecificAnnotations(endpoints.Annotations, field.NewPath("annotations"))...)
allErrs = append(allErrs, validateEndpointSubsets(endpoints.Subsets, field.NewPath("subsets"))...)
allErrs = append(allErrs, validateEndpointSubsets(endpoints.Subsets, []api.EndpointSubset{}, field.NewPath("subsets"))...)
return allErrs
}
func validateEndpointSubsets(subsets []api.EndpointSubset, fldPath *field.Path) field.ErrorList {
func validateEndpointSubsets(subsets []api.EndpointSubset, oldSubsets []api.EndpointSubset, fldPath *field.Path) field.ErrorList {
allErrs := field.ErrorList{}
ipToNodeName := buildEndpointAddressNodeNameMap(oldSubsets)
for i := range subsets {
ss := &subsets[i]
idxPath := fldPath.Index(i)
@ -3381,10 +3414,10 @@ func validateEndpointSubsets(subsets []api.EndpointSubset, fldPath *field.Path)
allErrs = append(allErrs, field.Required(idxPath.Child("ports"), ""))
}
for addr := range ss.Addresses {
allErrs = append(allErrs, validateEndpointAddress(&ss.Addresses[addr], idxPath.Child("addresses").Index(addr))...)
allErrs = append(allErrs, validateEndpointAddress(&ss.Addresses[addr], idxPath.Child("addresses").Index(addr), ipToNodeName)...)
}
for addr := range ss.NotReadyAddresses {
allErrs = append(allErrs, validateEndpointAddress(&ss.NotReadyAddresses[addr], idxPath.Child("notReadyAddresses").Index(addr))...)
allErrs = append(allErrs, validateEndpointAddress(&ss.NotReadyAddresses[addr], idxPath.Child("notReadyAddresses").Index(addr), ipToNodeName)...)
}
for port := range ss.Ports {
allErrs = append(allErrs, validateEndpointPort(&ss.Ports[port], len(ss.Ports) > 1, idxPath.Child("ports").Index(port))...)
@ -3394,7 +3427,7 @@ func validateEndpointSubsets(subsets []api.EndpointSubset, fldPath *field.Path)
return allErrs
}
func validateEndpointAddress(address *api.EndpointAddress, fldPath *field.Path) field.ErrorList {
func validateEndpointAddress(address *api.EndpointAddress, fldPath *field.Path, ipToNodeName map[string]string) field.ErrorList {
allErrs := field.ErrorList{}
for _, msg := range validation.IsValidIP(address.IP) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("ip"), address.IP, msg))
@ -3402,6 +3435,11 @@ func validateEndpointAddress(address *api.EndpointAddress, fldPath *field.Path)
if len(address.Hostname) > 0 {
allErrs = append(allErrs, ValidateDNS1123Label(address.Hostname, fldPath.Child("hostname"))...)
}
// During endpoint update, validate NodeName is DNS1123 compliant and transition rules allow the update
if address.NodeName != nil {
allErrs = append(allErrs, ValidateDNS1123Label(*address.NodeName, fldPath.Child("nodeName"))...)
}
allErrs = append(allErrs, validateEpAddrNodeNameTransition(address, ipToNodeName, fldPath.Child("nodeName"))...)
if len(allErrs) > 0 {
return allErrs
}
@ -3456,7 +3494,7 @@ func validateEndpointPort(port *api.EndpointPort, requireName bool, fldPath *fie
// ValidateEndpointsUpdate tests to make sure an endpoints update can be applied.
func ValidateEndpointsUpdate(newEndpoints, oldEndpoints *api.Endpoints) field.ErrorList {
allErrs := ValidateObjectMetaUpdate(&newEndpoints.ObjectMeta, &oldEndpoints.ObjectMeta, field.NewPath("metadata"))
allErrs = append(allErrs, validateEndpointSubsets(newEndpoints.Subsets, field.NewPath("subsets"))...)
allErrs = append(allErrs, validateEndpointSubsets(newEndpoints.Subsets, oldEndpoints.Subsets, field.NewPath("subsets"))...)
allErrs = append(allErrs, ValidateEndpointsSpecificAnnotations(newEndpoints.Annotations, field.NewPath("annotations"))...)
return allErrs
}

View File

@ -0,0 +1,96 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
// This file contains a collection of methods that can be used from go-restful to
// generate Swagger API documentation for its models. Please read this PR for more
// information on the implementation: https://github.com/emicklei/go-restful/pull/215
//
// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if
// they are on one line! For multiple line or blocks that you want to ignore use ---.
// Any context after a --- is ignored.
//
// Those methods can be generated by using hack/update-generated-swagger-docs.sh
// AUTO-GENERATED FUNCTIONS START HERE
var map_Cluster = map[string]string{
"": "Information about a registered cluster in a federated kubernetes setup. Clusters are not namespaced and have unique names in the federation.",
"metadata": "Standard object's metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata",
"spec": "Spec defines the behavior of the Cluster.",
"status": "Status describes the current status of a Cluster",
}
func (Cluster) SwaggerDoc() map[string]string {
return map_Cluster
}
var map_ClusterCondition = map[string]string{
"": "ClusterCondition describes current state of a cluster.",
"type": "Type of cluster condition, Complete or Failed.",
"status": "Status of the condition, one of True, False, Unknown.",
"lastProbeTime": "Last time the condition was checked.",
"lastTransitionTime": "Last time the condition transit from one status to another.",
"reason": "(brief) reason for the condition's last transition.",
"message": "Human readable message indicating details about last transition.",
}
func (ClusterCondition) SwaggerDoc() map[string]string {
return map_ClusterCondition
}
var map_ClusterList = map[string]string{
"": "A list of all the kubernetes clusters registered to the federation",
"metadata": "Standard list metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#types-kinds",
"items": "List of Cluster objects.",
}
func (ClusterList) SwaggerDoc() map[string]string {
return map_ClusterList
}
var map_ClusterSpec = map[string]string{
"": "ClusterSpec describes the attributes of a kubernetes cluster.",
"serverAddressByClientCIDRs": "A map of client CIDR to server address. This is to help clients reach servers in the most network-efficient way possible. Clients can use the appropriate server address as per the CIDR that they match. In case of multiple matches, clients should use the longest matching CIDR.",
"secretRef": "Name of the secret containing kubeconfig to access this cluster. The secret is read from the kubernetes cluster that is hosting federation control plane. Admin needs to ensure that the required secret exists. Secret should be in the same namespace where federation control plane is hosted and it should have kubeconfig in its data with key \"kubeconfig\". This will later be changed to a reference to secret in federation control plane when the federation control plane supports secrets. This can be left empty if the cluster allows insecure access.",
}
func (ClusterSpec) SwaggerDoc() map[string]string {
return map_ClusterSpec
}
var map_ClusterStatus = map[string]string{
"": "ClusterStatus is information about the current status of a cluster updated by cluster controller peridocally.",
"conditions": "Conditions is an array of current cluster conditions.",
"zones": "Zones is the list of avaliability zones in which the nodes of the cluster exist, e.g. 'us-east1-a'. These will always be in the same region.",
"region": "Region is the name of the region in which all of the nodes in the cluster exist. e.g. 'us-east1'.",
}
func (ClusterStatus) SwaggerDoc() map[string]string {
return map_ClusterStatus
}
var map_ServerAddressByClientCIDR = map[string]string{
"": "ServerAddressByClientCIDR helps the client to determine the server address that they should use, depending on the clientCIDR that they match.",
"clientCIDR": "The CIDR with which clients can match their IP to figure out the server address that they should use.",
"serverAddress": "Address of this server, suitable for a client that matches the above CIDR. This can be a hostname, hostname:port, IP or IP:port.",
}
func (ServerAddressByClientCIDR) SwaggerDoc() map[string]string {
return map_ServerAddressByClientCIDR
}
// AUTO-GENERATED FUNCTIONS END HERE

View File

@ -37,6 +37,7 @@ var isDisabledBuild bool
// Interface for validating that a pod with with an AppArmor profile can be run by a Node.
type Validator interface {
Validate(pod *api.Pod) error
ValidateHost() error
}
func NewValidator(runtime string) Validator {
@ -64,7 +65,7 @@ func (v *validator) Validate(pod *api.Pod) error {
return nil
}
if v.validateHostErr != nil {
if v.ValidateHost() != nil {
return v.validateHostErr
}
@ -87,6 +88,10 @@ func (v *validator) Validate(pod *api.Pod) error {
return nil
}
func (v *validator) ValidateHost() error {
return v.validateHostErr
}
// Verify that the host and runtime is capable of enforcing AppArmor profiles.
func validateHost(runtime string) error {
// Check feature-gates