Vendor serving and eventing at v0.17.0 (#984)

* Vendor serving and eventing at v0.17.0

* Update version commmand output

* Run latest release e2e tests against serving/eventing v0.17.0
This commit is contained in:
Navid Shaikh 2020-08-20 15:52:13 +05:30 committed by GitHub
parent e76e37eb86
commit c39025f7ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 179 additions and 656 deletions

6
go.mod
View File

@ -15,9 +15,9 @@ require (
k8s.io/cli-runtime v0.17.6
k8s.io/client-go v11.0.1-0.20190805182717-6502b5e7b1b5+incompatible
k8s.io/code-generator v0.18.6
knative.dev/eventing v0.16.1-0.20200811155813-951a8d0926d1
knative.dev/pkg v0.0.0-20200811165506-f6ed1766e8ee
knative.dev/serving v0.16.1-0.20200811173106-5388b6efad78
knative.dev/eventing v0.17.0
knative.dev/pkg v0.0.0-20200812224206-44c860147a87
knative.dev/serving v0.17.0
sigs.k8s.io/yaml v1.2.0
)

20
go.sum
View File

@ -1853,13 +1853,13 @@ k8s.io/utils v0.0.0-20200603063816-c1c6865ac451 h1:v8ud2Up6QK1lNOKFgiIVrZdMg7Mpm
k8s.io/utils v0.0.0-20200603063816-c1c6865ac451/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
knative.dev/caching v0.0.0-20190719140829-2032732871ff/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg=
knative.dev/caching v0.0.0-20200116200605-67bca2c83dfa/go.mod h1:dHXFU6CGlLlbzaWc32g80cR92iuBSpsslDNBWI8C7eg=
knative.dev/caching v0.0.0-20200810161831-4976ef375510/go.mod h1:/0MKr4+UqQKPCrLcXUm2sIFUAD6SKBfM0sMynDLgnoQ=
knative.dev/eventing v0.16.1-0.20200811155813-951a8d0926d1 h1:SpGKzaX0zB9PJM9OCOsQl4X73jWdlx1BKfxmR3ULhaw=
knative.dev/eventing v0.16.1-0.20200811155813-951a8d0926d1/go.mod h1:bB8MrLqK7QPCanzS/np1i/qqXC5moMBasMZlmfbJz/I=
knative.dev/caching v0.0.0-20200811171106-48c335fed9c8/go.mod h1:XonDcFC2DLSWP71f2y7oYnXUko5d5HsJRnZtkp0wY7g=
knative.dev/eventing v0.17.0 h1:yGJuwN+jWQPCf4XuL44vAjlemLHnbLTBKyhvRBmikpQ=
knative.dev/eventing v0.17.0/go.mod h1:9NwCSwLnMCKmgz3YQBNax18mSgBjud8CvfsUUVOZ1sA=
knative.dev/eventing-contrib v0.6.1-0.20190723221543-5ce18048c08b/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g=
knative.dev/eventing-contrib v0.11.2/go.mod h1:SnXZgSGgMSMLNFTwTnpaOH7hXDzTFtw0J8OmHflNx3g=
knative.dev/networking v0.0.0-20200811030306-fb582fa08c3b h1:+IadtQLbc28n38J38LFxxrvysSMKFAu6f5ank4Sx8Ig=
knative.dev/networking v0.0.0-20200811030306-fb582fa08c3b/go.mod h1:ZMWCs9BI1SO2nUvCbzIUu91NCFck4VxauwV1EoEV1u8=
knative.dev/networking v0.0.0-20200812200006-4d518e76538a h1:E1rnQR9IZvDcEAgoOXMW9LWqevaYFVTlMS2ndgoAO6Y=
knative.dev/networking v0.0.0-20200812200006-4d518e76538a/go.mod h1:ZewGJAElO4qPOeZTKuLIO3NQNGAkqcQVu64gHOSiPPg=
knative.dev/pkg v0.0.0-20191101194912-56c2594e4f11/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
knative.dev/pkg v0.0.0-20191111150521-6d806b998379/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
knative.dev/pkg v0.0.0-20200207155214-fef852970f43/go.mod h1:pgODObA1dTyhNoFxPZTTjNWfx6F0aKsKzn+vaT9XO/Q=
@ -1868,19 +1868,19 @@ knative.dev/pkg v0.0.0-20200505191044-3da93ebb24c2/go.mod h1:Q6sL35DdGs8hIQZKdaC
knative.dev/pkg v0.0.0-20200515002500-16d7b963416f/go.mod h1:tMOHGbxtRz8zYFGEGpV/bpoTEM1o89MwYFC4YJXl3GY=
knative.dev/pkg v0.0.0-20200528142800-1c6815d7e4c9/go.mod h1:QgNZTxnwpB/oSpNcfnLVlw+WpEwwyKAvJlvR3hgeltA=
knative.dev/pkg v0.0.0-20200711004937-22502028e31a/go.mod h1:AqAJV6rYi8IGikDjJ/9ZQd9qKdkXVlesVnVjwx62YB8=
knative.dev/pkg v0.0.0-20200810090030-095ff27da65c/go.mod h1:BU3J2SM/hsc0DdfZJpDPJCP5dVQrPQl84U1x8PN8o9I=
knative.dev/pkg v0.0.0-20200810223505-473bba04ee7f/go.mod h1:BU3J2SM/hsc0DdfZJpDPJCP5dVQrPQl84U1x8PN8o9I=
knative.dev/pkg v0.0.0-20200811165506-f6ed1766e8ee h1:2WJTEd8wANLXI1jXbWFePUUT0G2e93DZ5jsg3MkrDoM=
knative.dev/pkg v0.0.0-20200811165506-f6ed1766e8ee/go.mod h1:udIbxBS/SJCL4sqnCG8HZArez9HjWmeqJCaVJP/h32I=
knative.dev/serving v0.16.1-0.20200811173106-5388b6efad78 h1:lbKeS5pbMZZkcZL2D2vdSFYtXhUL33E2GIMEc4RVYyg=
knative.dev/serving v0.16.1-0.20200811173106-5388b6efad78/go.mod h1:b09jv+vwBjndutTOviNsFdY+QTekW9OIs7DnI8S0uNc=
knative.dev/pkg v0.0.0-20200812224206-44c860147a87 h1:argvd9DHJr2YeeV2pl1ogXPB3raIWnOqJivfBK/qsiM=
knative.dev/pkg v0.0.0-20200812224206-44c860147a87/go.mod h1:udIbxBS/SJCL4sqnCG8HZArez9HjWmeqJCaVJP/h32I=
knative.dev/serving v0.17.0 h1:WA7pGmdytiUj23vop0v7KEZ3w0Wf7Bpci3sREIQ60yk=
knative.dev/serving v0.17.0/go.mod h1:OSO+sfM0xgIhQ+aG6pmMY9SjYDOdghCkoJiAXDheun8=
knative.dev/test-infra v0.0.0-20200407185800-1b88cb3b45a5/go.mod h1:xcdUkMJrLlBswIZqL5zCuBFOC22WIPMQoVX1L35i0vQ=
knative.dev/test-infra v0.0.0-20200505052144-5ea2f705bb55/go.mod h1:WqF1Azka+FxPZ20keR2zCNtiQA1MP9ZB4BH4HuI+SIU=
knative.dev/test-infra v0.0.0-20200513011557-d03429a76034/go.mod h1:aMif0KXL4g19YCYwsy4Ocjjz5xgPlseYV+B95Oo4JGE=
knative.dev/test-infra v0.0.0-20200519015156-82551620b0a9/go.mod h1:A5b2OAXTOeHT3hHhVQm3dmtbuWvIDP7qzgtqxA3/2pE=
knative.dev/test-infra v0.0.0-20200707183444-aed09e56ddc7/go.mod h1:RjYAhXnZqeHw9+B0zsbqSPlae0lCvjekO/nw5ZMpLCs=
knative.dev/test-infra v0.0.0-20200806191129-68b7defbd189/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
knative.dev/test-infra v0.0.0-20200811030605-72f8c9f3e933/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
knative.dev/test-infra v0.0.0-20200813220834-388e55a496cf/go.mod h1:Pmg2c7Z7q7BGFUV/GOpU5BlrD3ePJft4MPqx8AYBplc=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=

View File

@ -31,11 +31,11 @@ var GitRevision string
// update this var as we add more deps
var apiVersions = map[string][]string{
"serving": {
"serving.knative.dev/v1 (knative-serving v0.16.1-0.20200715073232-81d40bfc82a6)",
"serving.knative.dev/v1 (knative-serving v0.17.0)",
},
"eventing": {
"sources.knative.dev/v1alpha2 (knative-eventing v0.16.1-0.20200715062032-28f9f61e6131)",
"eventing.knative.dev/v1beta1 (knative-eventing v0.16.1-0.20200715062032-28f9f61e6131)",
"sources.knative.dev/v1alpha2 (knative-eventing v0.17.0)",
"eventing.knative.dev/v1beta1 (knative-eventing v0.17.0)",
},
}

View File

@ -17,7 +17,7 @@
# This script is used in Knative/test-infra as a custom prow job to run the
# integration tests against Knative Serving / Eventing of a specific version.
export KNATIVE_SERVING_VERSION="0.16.0"
export KNATIVE_EVENTING_VERSION="0.16.0"
export KNATIVE_SERVING_VERSION="0.17.0"
export KNATIVE_EVENTING_VERSION="0.17.0"
$(dirname $0)/presubmit-tests.sh --integration-tests

View File

@ -33,7 +33,7 @@ import (
// Broker collects a pool of events that are consumable using Triggers. Brokers
// provide a well-known endpoint for event delivery that senders can use with
// minimal knowledge of the event routing strategy. Receivers use Triggers to
// minimal knowledge of the event routing strategy. Subscribers use Triggers to
// request delivery of events from a Broker's pool to a specific URL or
// Addressable endpoint.
type Broker struct {

View File

@ -41,7 +41,7 @@ const (
// +genreconciler
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// Trigger represents a request to have events delivered to a consumer from a
// Trigger represents a request to have events delivered to a subscriber from a
// Broker's event pool.
type Trigger struct {
metav1.TypeMeta `json:",inline"`
@ -75,8 +75,7 @@ var (
)
type TriggerSpec struct {
// Broker is the broker that this trigger receives events from. If not specified, will default
// to 'default'.
// Broker is the broker that this trigger receives events from.
Broker string `json:"broker,omitempty"`
// Filter is the filter to apply against all events from the Broker. Only events that pass this

View File

@ -29,6 +29,7 @@ import (
// +genreconciler
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// EventType represents a type of event that can be consumed from a Broker.
type EventType struct {
metav1.TypeMeta `json:",inline"`
// +optional

View File

@ -1,88 +0,0 @@
/*
Copyright 2020 The Knative 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 v1alpha1
import (
"context"
"fmt"
"reflect"
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
"knative.dev/pkg/apis"
duckv1 "knative.dev/pkg/apis/duck/v1"
)
// ConvertTo implements apis.Convertible.
// Converts source (from v1alpha1.PingSource) into v1alpha2.PingSource
func (source *PingSource) ConvertTo(ctx context.Context, obj apis.Convertible) error {
switch sink := obj.(type) {
case *v1alpha2.PingSource:
sink.ObjectMeta = source.ObjectMeta
sink.Spec = v1alpha2.PingSourceSpec{
Schedule: source.Spec.Schedule,
JsonData: source.Spec.Data,
}
sink.Status = v1alpha2.PingSourceStatus{
SourceStatus: duckv1.SourceStatus{
Status: source.Status.Status,
SinkURI: source.Status.SinkURI,
CloudEventAttributes: source.Status.CloudEventAttributes,
},
}
// Optionals
if source.Spec.Sink != nil {
sink.Spec.Sink = *source.Spec.Sink.DeepCopy()
}
if source.Spec.CloudEventOverrides != nil {
sink.Spec.CloudEventOverrides = source.Spec.CloudEventOverrides.DeepCopy()
}
if source.Status.SinkURI != nil {
sink.Status.SinkURI = source.Status.SinkURI.DeepCopy()
}
return nil
default:
return fmt.Errorf("Unknown conversion, got: %T", sink)
}
}
// ConvertFrom implements apis.Convertible.
// Converts obj from v1alpha2.PingSource into v1alpha1.PingSource
func (sink *PingSource) ConvertFrom(ctx context.Context, obj apis.Convertible) error {
switch source := obj.(type) {
case *v1alpha2.PingSource:
sink.ObjectMeta = source.ObjectMeta
sink.Spec = PingSourceSpec{
Schedule: source.Spec.Schedule,
Data: source.Spec.JsonData,
Sink: source.Spec.Sink.DeepCopy(),
CloudEventOverrides: source.Spec.CloudEventOverrides,
}
sink.Status = PingSourceStatus{
SourceStatus: duckv1.SourceStatus{
Status: source.Status.Status,
SinkURI: source.Status.SinkURI,
CloudEventAttributes: source.Status.CloudEventAttributes,
},
}
if reflect.DeepEqual(*sink.Spec.Sink, duckv1.Destination{}) {
sink.Spec.Sink = nil
}
return nil
default:
return fmt.Errorf("Unknown conversion, got: %T", source)
}
}

View File

@ -1,29 +0,0 @@
/*
Copyright 2020 The Knative 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 v1alpha1
import (
"context"
)
func (s *PingSource) SetDefaults(ctx context.Context) {
s.Spec.SetDefaults(ctx)
}
func (ss *PingSourceSpec) SetDefaults(ctx context.Context) {
// TODO anything?
}

View File

@ -1,147 +0,0 @@
/*
Copyright 2020 The Knative 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 v1alpha1
import (
"fmt"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/pkg/apis"
)
const (
// PingSourceConditionReady has status True when the PingSource is ready to send events.
PingSourceConditionReady = apis.ConditionReady
// PingSourceConditionValidSchedule has status True when the PingSource has been configured with a valid schedule.
PingSourceConditionValidSchedule apis.ConditionType = "ValidSchedule"
// PingSourceConditionSinkProvided has status True when the PingSource has been configured with a sink target.
PingSourceConditionSinkProvided apis.ConditionType = "SinkProvided"
// PingSourceConditionDeployed has status True when the PingSource has had it's receive adapter deployment created.
PingSourceConditionDeployed apis.ConditionType = "Deployed"
// PingSourceConditionResources is True when the resources listed for the PingSource have been properly
// parsed and match specified syntax for resource quantities
PingSourceConditionResources apis.ConditionType = "ResourcesCorrect"
)
var PingSourceCondSet = apis.NewLivingConditionSet(
PingSourceConditionValidSchedule,
PingSourceConditionSinkProvided,
PingSourceConditionDeployed)
const (
// PingSourceEventType is the default PingSource CloudEvent type.
PingSourceEventType = "dev.knative.sources.ping"
)
// PingSourceSource returns the PingSource CloudEvent source.
func PingSourceSource(namespace, name string) string {
return fmt.Sprintf("/apis/v1/namespaces/%s/pingsources/%s", namespace, name)
}
// GetUntypedSpec returns the spec of the PingSource.
func (s *PingSource) GetUntypedSpec() interface{} {
return s.Spec
}
// GetGroupVersionKind returns the GroupVersionKind.
func (s *PingSource) GetGroupVersionKind() schema.GroupVersionKind {
return SchemeGroupVersion.WithKind("PingSource")
}
// GetCondition returns the condition currently associated with the given type, or nil.
func (s *PingSourceStatus) GetCondition(t apis.ConditionType) *apis.Condition {
return PingSourceCondSet.Manage(s).GetCondition(t)
}
// GetTopLevelCondition returns the top level Condition.
func (ps *PingSourceStatus) GetTopLevelCondition() *apis.Condition {
return PingSourceCondSet.Manage(ps).GetTopLevelCondition()
}
// IsReady returns true if the resource is ready overall.
func (s *PingSourceStatus) IsReady() bool {
return PingSourceCondSet.Manage(s).IsHappy()
}
// InitializeConditions sets relevant unset conditions to Unknown state.
func (s *PingSourceStatus) InitializeConditions() {
PingSourceCondSet.Manage(s).InitializeConditions()
}
// TODO: this is a bad method name, change it.
// MarkSchedule sets the condition that the source has a valid schedule configured.
func (s *PingSourceStatus) MarkSchedule() {
PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionValidSchedule)
}
// MarkInvalidSchedule sets the condition that the source does not have a valid schedule configured.
func (s *PingSourceStatus) MarkInvalidSchedule(reason, messageFormat string, messageA ...interface{}) {
PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionValidSchedule, reason, messageFormat, messageA...)
}
// MarkSink sets the condition that the source has a sink configured.
func (s *PingSourceStatus) MarkSink(uri *apis.URL) {
// TODO: Update sources to use MarkSink(url.URL or apis.URI)
s.SinkURI = uri
if uri != nil {
PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionSinkProvided)
} else {
PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionSinkProvided, "SinkEmpty", "Sink has resolved to empty.")
}
}
// MarkNoSink sets the condition that the source does not have a sink configured.
func (s *PingSourceStatus) MarkNoSink(reason, messageFormat string, messageA ...interface{}) {
PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionSinkProvided, reason, messageFormat, messageA...)
}
// PropagateDeploymentAvailability uses the availability of the provided Deployment to determine if
// PingSourceConditionDeployed should be marked as true or false.
func (s *PingSourceStatus) PropagateDeploymentAvailability(d *appsv1.Deployment) {
deploymentAvailableFound := false
for _, cond := range d.Status.Conditions {
if cond.Type == appsv1.DeploymentAvailable {
deploymentAvailableFound = true
if cond.Status == corev1.ConditionTrue {
PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionDeployed)
} else if cond.Status == corev1.ConditionFalse {
PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionDeployed, cond.Reason, cond.Message)
} else if cond.Status == corev1.ConditionUnknown {
PingSourceCondSet.Manage(s).MarkUnknown(PingSourceConditionDeployed, cond.Reason, cond.Message)
}
}
}
if !deploymentAvailableFound {
PingSourceCondSet.Manage(s).MarkUnknown(PingSourceConditionDeployed, "DeploymentUnavailable", "The Deployment '%s' is unavailable.", d.Name)
}
}
// MarkResourcesCorrect sets the condition that the source resources are properly parsable quantities
func (s *PingSourceStatus) MarkResourcesCorrect() {
PingSourceCondSet.Manage(s).MarkTrue(PingSourceConditionResources)
}
// MarkResourcesIncorrect sets the condition that the source resources are not properly parsable quantities
func (s *PingSourceStatus) MarkResourcesIncorrect(reason, messageFormat string, messageA ...interface{}) {
PingSourceCondSet.Manage(s).MarkFalse(PingSourceConditionResources, reason, messageFormat, messageA...)
}

View File

@ -1,115 +0,0 @@
/*
Copyright 2020 The Knative 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 v1alpha1
import (
"knative.dev/pkg/apis"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
duckv1 "knative.dev/pkg/apis/duck/v1"
"knative.dev/pkg/kmeta"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:defaulter-gen=true
// PingSource is the Schema for the PingSources API.
type PingSource struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec PingSourceSpec `json:"spec,omitempty"`
Status PingSourceStatus `json:"status,omitempty"`
}
// TODO: Check that PingSource can be validated and can be defaulted.
var (
// Check that it is a runtime object.
_ runtime.Object = (*PingSource)(nil)
// Check that we can create OwnerReferences to a PingSource.
_ kmeta.OwnerRefable = (*PingSource)(nil)
// Check that PingSource can return its spec untyped.
_ apis.HasSpec = (*PingSource)(nil)
)
type PingRequestsSpec struct {
ResourceCPU string `json:"cpu,omitempty"`
ResourceMemory string `json:"memory,omitempty"`
}
type PingLimitsSpec struct {
ResourceCPU string `json:"cpu,omitempty"`
ResourceMemory string `json:"memory,omitempty"`
}
type PingResourceSpec struct {
Requests PingRequestsSpec `json:"requests,omitempty"`
Limits PingLimitsSpec `json:"limits,omitempty"`
}
// PingSourceSpec defines the desired state of the PingSource.
type PingSourceSpec struct {
// Schedule is the cronjob schedule.
// +required
Schedule string `json:"schedule"`
// Data is the data posted to the target function.
Data string `json:"data,omitempty"`
// Sink is a reference to an object that will resolve to a uri to use as the sink.
Sink *duckv1.Destination `json:"sink,omitempty"`
// CloudEventOverrides defines overrides to control the output format and
// modifications of the event sent to the sink.
// +optional
CloudEventOverrides *duckv1.CloudEventOverrides `json:"ceOverrides,omitempty"`
// ServiceAccoutName is the name of the ServiceAccount that will be used to run the Receive
// Adapter Deployment.
// Deprecated: v1beta1 drops this field.
ServiceAccountName string `json:"serviceAccountName,omitempty"`
// Resource limits and Request specifications of the Receive Adapter Deployment
// Deprecated: v1beta1 drops this field.
Resources PingResourceSpec `json:"resources,omitempty"`
}
// PingSourceStatus defines the observed state of PingSource.
type PingSourceStatus struct {
// inherits duck/v1 SourceStatus, which currently provides:
// * ObservedGeneration - the 'Generation' of the Service that was last
// processed by the controller.
// * Conditions - the latest available observations of a resource's current
// state.
// * SinkURI - the current active sink URI that has been configured for the
// Source.
duckv1.SourceStatus `json:",inline"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// PingSourceList contains a list of PingSources.
type PingSourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []PingSource `json:"items"`
}

View File

@ -1,48 +0,0 @@
/*
Copyright 2020 The Knative 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 v1alpha1
import (
"context"
"github.com/robfig/cron/v3"
"knative.dev/pkg/apis"
"knative.dev/eventing/pkg/apis/sources/v1alpha2"
)
func (c *PingSource) Validate(ctx context.Context) *apis.FieldError {
errs := c.Spec.Validate(ctx).ViaField("spec")
return v1alpha2.ValidateAnnotations(errs, c.Annotations)
}
func (cs *PingSourceSpec) Validate(ctx context.Context) *apis.FieldError {
var errs *apis.FieldError
if _, err := cron.ParseStandard(cs.Schedule); err != nil {
fe := apis.ErrInvalidValue(cs.Schedule, "schedule")
errs = errs.Also(fe)
}
if cs.Sink == nil {
fe := apis.ErrMissingField("sink")
errs = errs.Also(fe)
} else if fe := cs.Sink.Validate(ctx); fe != nil {
errs = errs.Also(fe.ViaField("sink"))
}
return errs
}

View File

@ -47,8 +47,6 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ApiServerSource{},
&ApiServerSourceList{},
&PingSource{},
&PingSourceList{},
&SinkBinding{},
&SinkBindingList{},
)

View File

@ -161,161 +161,6 @@ func (in *ApiServerSourceStatus) DeepCopy() *ApiServerSourceStatus {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingLimitsSpec) DeepCopyInto(out *PingLimitsSpec) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingLimitsSpec.
func (in *PingLimitsSpec) DeepCopy() *PingLimitsSpec {
if in == nil {
return nil
}
out := new(PingLimitsSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingRequestsSpec) DeepCopyInto(out *PingRequestsSpec) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingRequestsSpec.
func (in *PingRequestsSpec) DeepCopy() *PingRequestsSpec {
if in == nil {
return nil
}
out := new(PingRequestsSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingResourceSpec) DeepCopyInto(out *PingResourceSpec) {
*out = *in
out.Requests = in.Requests
out.Limits = in.Limits
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingResourceSpec.
func (in *PingResourceSpec) DeepCopy() *PingResourceSpec {
if in == nil {
return nil
}
out := new(PingResourceSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingSource) DeepCopyInto(out *PingSource) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingSource.
func (in *PingSource) DeepCopy() *PingSource {
if in == nil {
return nil
}
out := new(PingSource)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PingSource) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingSourceList) DeepCopyInto(out *PingSourceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]PingSource, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingSourceList.
func (in *PingSourceList) DeepCopy() *PingSourceList {
if in == nil {
return nil
}
out := new(PingSourceList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PingSourceList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingSourceSpec) DeepCopyInto(out *PingSourceSpec) {
*out = *in
if in.Sink != nil {
in, out := &in.Sink, &out.Sink
*out = new(v1.Destination)
(*in).DeepCopyInto(*out)
}
if in.CloudEventOverrides != nil {
in, out := &in.CloudEventOverrides, &out.CloudEventOverrides
*out = new(v1.CloudEventOverrides)
(*in).DeepCopyInto(*out)
}
out.Resources = in.Resources
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingSourceSpec.
func (in *PingSourceSpec) DeepCopy() *PingSourceSpec {
if in == nil {
return nil
}
out := new(PingSourceSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PingSourceStatus) DeepCopyInto(out *PingSourceStatus) {
*out = *in
in.SourceStatus.DeepCopyInto(&out.SourceStatus)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PingSourceStatus.
func (in *PingSourceStatus) DeepCopy() *PingSourceStatus {
if in == nil {
return nil
}
out := new(PingSourceStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SinkBinding) DeepCopyInto(out *SinkBinding) {
*out = *in

View File

@ -40,6 +40,11 @@ var PingSourceCondSet = apis.NewLivingConditionSet(
PingSourceConditionSinkProvided,
PingSourceConditionDeployed)
const (
// PingSourceEventType is the default PingSource CloudEvent type.
PingSourceEventType = "dev.knative.sources.ping"
)
// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*PingSource) GetConditionSet() apis.ConditionSet {
return PingSourceCondSet

View File

@ -47,6 +47,8 @@ func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&ApiServerSource{},
&ApiServerSourceList{},
&PingSource{},
&PingSourceList{},
&SinkBinding{},
&SinkBindingList{},
&ContainerSource{},

View File

@ -16,4 +16,6 @@ limitations under the License.
// +k8s:deepcopy-gen=package
// +groupName=autoscaling.internal.knative.dev
// Package v1alpha1 contains the Autoscaling v1alpha1 API types.
package v1alpha1

View File

@ -35,6 +35,7 @@ func defaultMetric(class string) string {
}
}
// SetDefaults sets the default values for the PodAutoscaler.
func (r *PodAutoscaler) SetDefaults(ctx context.Context) {
r.Spec.SetDefaults(apis.WithinSpec(ctx))
config := config.FromContextOrDefaults(ctx)
@ -51,4 +52,5 @@ func (r *PodAutoscaler) SetDefaults(ctx context.Context) {
}
}
// SetDefaults sets the default values for the PodAutoscalerSpec.
func (rs *PodAutoscalerSpec) SetDefaults(ctx context.Context) {}

View File

@ -32,7 +32,7 @@ import (
var podCondSet = apis.NewLivingConditionSet(
PodAutoscalerConditionActive,
PodAutoscalerConditionScaleTargetInitialized,
PodAutoscalerSKSReady,
PodAutoscalerConditionSKSReady,
)
// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
@ -102,8 +102,8 @@ func (pa *PodAutoscaler) Target() (float64, bool) {
return pa.annotationFloat64(autoscaling.TargetAnnotationKey)
}
// TargetUtilization returns the target capacity utilization as a fraction,
// if the corresponding annotation is set.
// TargetUtilization returns the target utilization percentage as a fraction, if
// the corresponding annotation is set.
func (pa *PodAutoscaler) TargetUtilization() (float64, bool) {
if tu, ok := pa.annotationFloat64(autoscaling.TargetUtilizationPercentageKey); ok {
return tu / 100, true
@ -111,8 +111,7 @@ func (pa *PodAutoscaler) TargetUtilization() (float64, bool) {
return 0, false
}
// TargetBC returns the target burst capacity,
// if the corresponding annotation is set.
// TargetBC returns the target burst capacity, if the corresponding annotation is set.
func (pa *PodAutoscaler) TargetBC() (float64, bool) {
// The value is validated in the webhook.
return pa.annotationFloat64(autoscaling.TargetBurstCapacityKey)
@ -126,25 +125,26 @@ func (pa *PodAutoscaler) annotationDuration(key string) (time.Duration, bool) {
return 0, false
}
// ScaleToZeroPodRetention returns the window annotation value or false if not present.
// ScaleToZeroPodRetention returns the ScaleToZeroPodRetention annotation value,
// or false if not present.
func (pa *PodAutoscaler) ScaleToZeroPodRetention() (time.Duration, bool) {
// The value is validated in the webhook.
return pa.annotationDuration(autoscaling.ScaleToZeroPodRetentionPeriodKey)
}
// Window returns the window annotation value or false if not present.
// Window returns the window annotation value, or false if not present.
func (pa *PodAutoscaler) Window() (time.Duration, bool) {
// The value is validated in the webhook.
return pa.annotationDuration(autoscaling.WindowAnnotationKey)
}
// PanicWindowPercentage returns panic window annotation value or false if not present.
// PanicWindowPercentage returns the panic window annotation value, or false if not present.
func (pa *PodAutoscaler) PanicWindowPercentage() (percentage float64, ok bool) {
// The value is validated in the webhook.
return pa.annotationFloat64(autoscaling.PanicWindowPercentageAnnotationKey)
}
// PanicThresholdPercentage return the panic target annotation value or false if not present.
// PanicThresholdPercentage returns the panic threshold annotation value, or false if not present.
func (pa *PodAutoscaler) PanicThresholdPercentage() (percentage float64, ok bool) {
// The value is validated in the webhook.
return pa.annotationFloat64(autoscaling.PanicThresholdPercentageAnnotationKey)
@ -164,7 +164,7 @@ func (pa *PodAutoscaler) IsReady() bool {
pas.GetCondition(PodAutoscalerConditionReady).IsTrue()
}
// IsActive returns true if the pod autoscaler is finished scaling.
// IsActive returns true if the pod autoscaler has finished scaling.
func (pas *PodAutoscalerStatus) IsActive() bool {
return pas.GetCondition(PodAutoscalerConditionActive).IsTrue()
}
@ -194,12 +194,12 @@ func (pas *PodAutoscalerStatus) MarkScaleTargetInitialized() {
// MarkSKSReady marks the PA condition denoting that SKS is ready.
func (pas *PodAutoscalerStatus) MarkSKSReady() {
podCondSet.Manage(pas).MarkTrue(PodAutoscalerSKSReady)
podCondSet.Manage(pas).MarkTrue(PodAutoscalerConditionSKSReady)
}
// MarkSKSNotReady marks the PA condation that SKS is not yet ready.
// MarkSKSNotReady marks the PA condition that denotes SKS is not yet ready.
func (pas *PodAutoscalerStatus) MarkSKSNotReady(mes string) {
podCondSet.Manage(pas).MarkUnknown(PodAutoscalerSKSReady, "NotReady", mes)
podCondSet.Manage(pas).MarkUnknown(PodAutoscalerConditionSKSReady, "NotReady", mes)
}
// GetCondition gets the condition `t`.
@ -212,7 +212,7 @@ func (pas *PodAutoscalerStatus) InitializeConditions() {
podCondSet.Manage(pas).InitializeConditions()
}
// MarkActive marks the PA active.
// MarkActive marks the PA as active.
func (pas *PodAutoscalerStatus) MarkActive() {
podCondSet.Manage(pas).MarkTrue(PodAutoscalerConditionActive)
}
@ -277,7 +277,7 @@ func (pas *PodAutoscalerStatus) GetDesiredScale() int32 {
return -1
}
// GetActualScale returns the desired scale if ever set, or -1.
// GetActualScale returns the actual scale if ever set, or -1.
func (pas *PodAutoscalerStatus) GetActualScale() int32 {
if pas.ActualScale != nil {
return *pas.ActualScale

View File

@ -99,7 +99,7 @@ type PodAutoscalerSpec struct {
// is responsible for quickly right-sizing.
ScaleTargetRef corev1.ObjectReference `json:"scaleTargetRef"`
// Reachable specifies whether or not the `ScaleTargetRef` can be reached (ie. has a route).
// Reachability specifies whether or not the `ScaleTargetRef` can be reached (ie. has a route).
// Defaults to `ReachabilityUnknown`
// +optional
Reachability ReachabilityType `json:"reachability,omitempty"`
@ -117,8 +117,8 @@ const (
PodAutoscalerConditionScaleTargetInitialized apis.ConditionType = "ScaleTargetInitialized"
// PodAutoscalerConditionActive is set when the PodAutoscaler's ScaleTargetRef is receiving traffic.
PodAutoscalerConditionActive apis.ConditionType = "Active"
// PodAutoscalerCondtionDependenciesReady is set when SKS is ready.
PodAutoscalerSKSReady = "SKSReady"
// PodAutoscalerConditionSKSReady is set when SKS is ready.
PodAutoscalerConditionSKSReady = "SKSReady"
)
// PodAutoscalerStatus communicates the observed state of the PodAutoscaler (from the controller).

View File

@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
}
var (
// SchemeBuilder registers the addKnownTypes function.
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
// AddToScheme applies all the stored functions to the scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
// Adds the list of known types to Scheme.

View File

@ -40,13 +40,14 @@ const (
func defaultFeaturesConfig() *Features {
return &Features{
MultiContainer: Enabled,
PodSpecAffinity: Disabled,
PodSpecFieldRef: Disabled,
PodSpecDryRun: Allowed,
PodSpecNodeSelector: Disabled,
PodSpecTolerations: Disabled,
ResponsiveRevisionGC: Disabled,
MultiContainer: Enabled,
PodSpecAffinity: Disabled,
PodSpecFieldRef: Disabled,
PodSpecDryRun: Allowed,
PodSpecNodeSelector: Disabled,
PodSpecSecurityContext: Disabled,
PodSpecTolerations: Disabled,
ResponsiveRevisionGC: Disabled,
}
}
@ -60,6 +61,7 @@ func NewFeaturesConfigFromMap(data map[string]string) (*Features, error) {
asFlag("kubernetes.podspec-fieldref", &nc.PodSpecFieldRef),
asFlag("kubernetes.podspec-dryrun", &nc.PodSpecDryRun),
asFlag("kubernetes.podspec-nodeselector", &nc.PodSpecNodeSelector),
asFlag("kubernetes.podspec-securitycontext", &nc.PodSpecSecurityContext),
asFlag("kubernetes.podspec-tolerations", &nc.PodSpecTolerations),
asFlag("responsive-revision-gc", &nc.ResponsiveRevisionGC)); err != nil {
return nil, err
@ -74,13 +76,14 @@ func NewFeaturesConfigFromConfigMap(config *corev1.ConfigMap) (*Features, error)
// Features specifies which features are allowed by the webhook.
type Features struct {
MultiContainer Flag
PodSpecAffinity Flag
PodSpecFieldRef Flag
PodSpecDryRun Flag
PodSpecNodeSelector Flag
PodSpecTolerations Flag
ResponsiveRevisionGC Flag
MultiContainer Flag
PodSpecAffinity Flag
PodSpecFieldRef Flag
PodSpecDryRun Flag
PodSpecNodeSelector Flag
PodSpecTolerations Flag
PodSpecSecurityContext Flag
ResponsiveRevisionGC Flag
}
// asFlag parses the value at key as a Flag into the target, if it exists.

View File

@ -101,9 +101,15 @@ func (s *Store) ToContext(ctx context.Context) context.Context {
// Load creates a Config from the current config state of the Store.
func (s *Store) Load() *Config {
return &Config{
Defaults: s.UntypedLoad(DefaultsConfigName).(*Defaults).DeepCopy(),
Features: s.UntypedLoad(FeaturesConfigName).(*Features).DeepCopy(),
Autoscaler: s.UntypedLoad(autoscalerconfig.ConfigName).(*autoscalerconfig.Config).DeepCopy(),
cfg := &Config{}
if def, ok := s.UntypedLoad(DefaultsConfigName).(*Defaults); ok {
cfg.Defaults = def.DeepCopy()
}
if feat, ok := s.UntypedLoad(FeaturesConfigName).(*Features); ok {
cfg.Features = feat.DeepCopy()
}
if as, ok := s.UntypedLoad(autoscalerconfig.ConfigName).(*autoscalerconfig.Config); ok {
cfg.Autoscaler = as.DeepCopy()
}
return cfg
}

View File

@ -164,6 +164,9 @@ func PodSpecMask(ctx context.Context, in *corev1.PodSpec) *corev1.PodSpec {
if cfg.Features.PodSpecTolerations != config.Disabled {
out.Tolerations = in.Tolerations
}
if cfg.Features.PodSpecSecurityContext != config.Disabled {
out.SecurityContext = in.SecurityContext
}
// Disallowed fields
// This list is unnecessary, but added here for clarity
@ -178,7 +181,6 @@ func PodSpecMask(ctx context.Context, in *corev1.PodSpec) *corev1.PodSpec {
out.HostPID = false
out.HostIPC = false
out.ShareProcessNamespace = nil
out.SecurityContext = nil
out.Hostname = ""
out.Subdomain = ""
out.SchedulerName = ""
@ -528,10 +530,39 @@ func ResourceRequirementsMask(in *corev1.ResourceRequirements) *corev1.ResourceR
}
// PodSecurityContextMask performs a _shallow_ copy of the Kubernetes PodSecurityContext object into a new
// Kubernetes PodSecurityContext object bringing over only the fields allowed in the Knative API. This
// does not validate the contents or bounds of the provided fields.
func PodSecurityContextMask(ctx context.Context, in *corev1.PodSecurityContext) *corev1.PodSecurityContext {
if in == nil {
return nil
}
out := new(corev1.PodSecurityContext)
if config.FromContextOrDefaults(ctx).Features.PodSpecSecurityContext == config.Disabled {
return out
}
out.RunAsUser = in.RunAsUser
out.RunAsGroup = in.RunAsGroup
out.RunAsNonRoot = in.RunAsNonRoot
out.FSGroup = in.FSGroup
out.SupplementalGroups = in.SupplementalGroups
// Disallowed
// This list is unnecessary, but added here for clarity
out.SELinuxOptions = nil
out.WindowsOptions = nil
out.Sysctls = nil
return out
}
// SecurityContextMask performs a _shallow_ copy of the Kubernetes SecurityContext object to a new
// Kubernetes SecurityContext object bringing over only the fields allowed in the Knative API. This
// does not validate the contents or the bounds of the provided fields.
func SecurityContextMask(in *corev1.SecurityContext) *corev1.SecurityContext {
func SecurityContextMask(ctx context.Context, in *corev1.SecurityContext) *corev1.SecurityContext {
if in == nil {
return nil
}
@ -541,13 +572,15 @@ func SecurityContextMask(in *corev1.SecurityContext) *corev1.SecurityContext {
// Allowed fields
out.RunAsUser = in.RunAsUser
if config.FromContextOrDefaults(ctx).Features.PodSpecSecurityContext != config.Disabled {
out.RunAsGroup = in.RunAsGroup
out.RunAsNonRoot = in.RunAsNonRoot
}
// Disallowed
// This list is unnecessary, but added here for clarity
out.Capabilities = nil
out.Privileged = nil
out.SELinuxOptions = nil
out.RunAsGroup = nil
out.RunAsNonRoot = nil
out.ReadOnlyRootFilesystem = nil
out.AllowPrivilegeEscalation = nil
out.ProcMount = nil

View File

@ -35,8 +35,8 @@ import (
)
const (
minUserID = 0
maxUserID = math.MaxInt32
minUserID, maxUserID = 0, math.MaxInt32
minGroupID, maxGroupID = 0, math.MaxInt32
)
var (
@ -273,6 +273,8 @@ func ValidatePodSpec(ctx context.Context, ps corev1.PodSpec) *apis.FieldError {
errs := apis.CheckDisallowedFields(ps, *PodSpecMask(ctx, &ps))
errs = errs.Also(ValidatePodSecurityContext(ctx, ps.SecurityContext).ViaField("securityContext"))
volumes, err := ValidateVolumes(ps.Volumes, AllMountedVolumes(ps.Containers))
if err != nil {
errs = errs.Also(err.ViaField("volumes"))
@ -415,7 +417,7 @@ func validate(ctx context.Context, container corev1.Container, volumes sets.Stri
// Resources
errs = errs.Also(validateResources(&container.Resources).ViaField("resources"))
// SecurityContext
errs = errs.Also(validateSecurityContext(container.SecurityContext).ViaField("securityContext"))
errs = errs.Also(validateSecurityContext(ctx, container.SecurityContext).ViaField("securityContext"))
// TerminationMessagePolicy
switch container.TerminationMessagePolicy {
case corev1.TerminationMessageReadFile, corev1.TerminationMessageFallbackToLogsOnError, "":
@ -435,11 +437,11 @@ func validateResources(resources *corev1.ResourceRequirements) *apis.FieldError
return apis.CheckDisallowedFields(*resources, *ResourceRequirementsMask(resources))
}
func validateSecurityContext(sc *corev1.SecurityContext) *apis.FieldError {
func validateSecurityContext(ctx context.Context, sc *corev1.SecurityContext) *apis.FieldError {
if sc == nil {
return nil
}
errs := apis.CheckDisallowedFields(*sc, *SecurityContextMask(sc))
errs := apis.CheckDisallowedFields(*sc, *SecurityContextMask(ctx, sc))
if sc.RunAsUser != nil {
uid := *sc.RunAsUser
@ -447,6 +449,13 @@ func validateSecurityContext(sc *corev1.SecurityContext) *apis.FieldError {
errs = errs.Also(apis.ErrOutOfBoundsValue(uid, minUserID, maxUserID, "runAsUser"))
}
}
if sc.RunAsGroup != nil {
gid := *sc.RunAsGroup
if gid < minGroupID || gid > maxGroupID {
errs = errs.Also(apis.ErrOutOfBoundsValue(gid, minGroupID, maxGroupID, "runAsGroup"))
}
}
return errs
}
@ -633,6 +642,49 @@ func ValidateNamespacedObjectReference(p *corev1.ObjectReference) *apis.FieldErr
return errs
}
// ValidatePodSecurityContext validates the PodSecurityContext struct. All fields are disallowed
// unless the 'PodSpecSecurityContext' feature flag is enabled
//
// See the allowed properties in the `PodSecurityContextMask`
func ValidatePodSecurityContext(ctx context.Context, sc *corev1.PodSecurityContext) *apis.FieldError {
if sc == nil {
return nil
}
errs := apis.CheckDisallowedFields(*sc, *PodSecurityContextMask(ctx, sc))
if sc.RunAsUser != nil {
uid := *sc.RunAsUser
if uid < minUserID || uid > maxUserID {
errs = errs.Also(apis.ErrOutOfBoundsValue(uid, minUserID, maxUserID, "runAsUser"))
}
}
if sc.RunAsGroup != nil {
gid := *sc.RunAsGroup
if gid < minGroupID || gid > maxGroupID {
errs = errs.Also(apis.ErrOutOfBoundsValue(gid, minGroupID, maxGroupID, "runAsGroup"))
}
}
if sc.FSGroup != nil {
gid := *sc.FSGroup
if gid < minGroupID || gid > maxGroupID {
errs = errs.Also(apis.ErrOutOfBoundsValue(gid, minGroupID, maxGroupID, "fsGroup"))
}
}
for i, gid := range sc.SupplementalGroups {
if gid < minGroupID || gid > maxGroupID {
err := apis.ErrOutOfBoundsValue(gid, minGroupID, maxGroupID, "").
ViaFieldIndex("supplementalGroups", i)
errs = errs.Also(err)
}
}
return errs
}
// This is attached to contexts as they are passed down through a user container
// being validated.
type userContainer struct{}

8
vendor/modules.txt vendored
View File

@ -609,7 +609,7 @@ k8s.io/kube-openapi/pkg/util/sets
k8s.io/utils/buffer
k8s.io/utils/integer
k8s.io/utils/trace
# knative.dev/eventing v0.16.1-0.20200811155813-951a8d0926d1
# knative.dev/eventing v0.17.0
## explicit
knative.dev/eventing/pkg/apis/config
knative.dev/eventing/pkg/apis/configs
@ -637,10 +637,10 @@ knative.dev/eventing/pkg/client/clientset/versioned/typed/eventing/v1beta1/fake
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2
knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1alpha2/fake
knative.dev/eventing/pkg/logging
# knative.dev/networking v0.0.0-20200811030306-fb582fa08c3b
# knative.dev/networking v0.0.0-20200812200006-4d518e76538a
knative.dev/networking/pkg/apis/networking
knative.dev/networking/pkg/apis/networking/v1alpha1
# knative.dev/pkg v0.0.0-20200811165506-f6ed1766e8ee
# knative.dev/pkg v0.0.0-20200812224206-44c860147a87
## explicit
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
@ -658,7 +658,7 @@ knative.dev/pkg/logging/logkey
knative.dev/pkg/profiling
knative.dev/pkg/ptr
knative.dev/pkg/tracker
# knative.dev/serving v0.16.1-0.20200811173106-5388b6efad78
# knative.dev/serving v0.17.0
## explicit
knative.dev/serving/pkg/apis/autoscaling
knative.dev/serving/pkg/apis/autoscaling/v1alpha1