v1beta1 NetworkPolicy API definition and client support

This commit is contained in:
Casey Davenport
2016-05-18 10:16:33 -07:00
parent 1a64ae88b7
commit 47248f3698
26 changed files with 6768 additions and 45 deletions

View File

@@ -17,6 +17,7 @@ limitations under the License.
package v1beta1
import (
"k8s.io/kubernetes/pkg/api/v1"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util/intstr"
)
@@ -28,6 +29,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) {
SetDefaults_Job,
SetDefaults_HorizontalPodAutoscaler,
SetDefaults_ReplicaSet,
SetDefaults_NetworkPolicy,
)
}
@@ -150,3 +152,16 @@ func SetDefaults_ReplicaSet(obj *ReplicaSet) {
*obj.Spec.Replicas = 1
}
}
func SetDefaults_NetworkPolicy(obj *NetworkPolicy) {
// Default any undefined Protocol fields to TCP.
for _, i := range obj.Spec.Ingress {
// TODO: Update Ports to be a pointer to slice as soon as auto-generation supports it.
for _, p := range i.Ports {
if p.Protocol == nil {
proto := v1.ProtocolTCP
p.Protocol = &proto
}
}
}
}