Follow kubernetes APIs directory structure (#1497)

This commit is contained in:
Ta-Ching Chen
2020-01-20 17:06:46 +08:00
committed by GitHub
parent bb3e6d6907
commit 11f9ef1045
160 changed files with 542 additions and 541 deletions
+146
View File
@@ -0,0 +1,146 @@
/*
Copyright 2018 The Fission 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
const (
EXECUTOR_INSTANCEID_LABEL string = "executorInstanceId"
DEFAULT_FUNCTION_TIMEOUT int = 60
)
const (
// ResourceVersionCount env variable is used for updating configmaps and secrets in pods
ResourceVersionCount string = "RESOURCE_VERSION_COUNT"
)
const (
ChecksumTypeSHA256 ChecksumType = "sha256"
)
const (
// ArchiveTypeLiteral means the package contents are specified in the Literal field of
// resource itself.
ArchiveTypeLiteral ArchiveType = "literal"
// ArchiveTypeUrl means the package contents are at the specified URL.
ArchiveTypeUrl ArchiveType = "url"
)
const (
BuildStatusPending = "pending"
BuildStatusRunning = "running"
BuildStatusSucceeded = "succeeded"
BuildStatusFailed = "failed"
BuildStatusNone = "none"
)
const (
AllowedFunctionsPerContainerSingle = "single"
AllowedFunctionsPerContainerInfinite = "infinite"
)
const (
ExecutorTypePoolmgr ExecutorType = "poolmgr"
ExecutorTypeNewdeploy ExecutorType = "newdeploy"
)
const (
StrategyTypeExecution = "execution"
)
const (
SharedVolumeUserfunc = "userfunc"
SharedVolumePackages = "packages"
SharedVolumeSecrets = "secrets"
SharedVolumeConfigmaps = "configmaps"
)
const (
MessageQueueTypeNats = "nats-streaming"
MessageQueueTypeASQ = "azure-storage-queue"
MessageQueueTypeKafka = "kafka"
)
const (
// FunctionReferenceFunctionName means that the function
// reference is simply by function name.
FunctionReferenceTypeFunctionName = "name"
FunctionReferenceTypeFunctionWeights = "function-weights"
// Other function reference types we'd like to support:
// Versioned function, latest version
// Versioned function. by semver "latest compatible"
// Set of function references (recursively), by percentage of traffic
)
const (
// failure type currently supported is http status code. This could be extended
// in the future.
FailureTypeStatusCode FailureType = "status-code"
// Status of canary config can be one of the following
CanaryConfigStatusPending = "pending"
CanaryConfigStatusSucceeded = "succeeded"
CanaryConfigStatusFailed = "failed"
CanaryConfigStatusAborted = "aborted"
// set a max number for iterations to prevent infinite processing of canary config
MaxIterationsForCanaryConfig = 10
)
const (
DefaultSpecializationTimeOut = 120
)
const (
FETCH_SOURCE = iota
FETCH_DEPLOYMENT
FETCH_URL
)
// executor kubernetes object label key
const (
ENVIRONMENT_NAMESPACE = "environmentNamespace"
ENVIRONMENT_NAME = "environmentName"
ENVIRONMENT_UID = "environmentUid"
FUNCTION_NAMESPACE = "functionNamespace"
FUNCTION_NAME = "functionName"
FUNCTION_UID = "functionUid"
FUNCTION_RESOURCE_VERSION = "functionResourceVersion"
EXECUTOR_TYPE = "executorType"
)
const (
ANNOTATION_SVC_HOST = "svcHost"
)
const (
ArchiveLiteralSizeLimit int64 = 256 * 1024
)
const (
FissionBuilderSA = "fission-builder"
FissionFetcherSA = "fission-fetcher"
SecretConfigMapGetterCR = "secret-configmap-getter"
SecretConfigMapGetterRB = "secret-configmap-getter-binding"
PackageGetterCR = "package-getter"
PackageGetterRB = "package-getter-binding"
ClusterRole = "ClusterRole"
)
+34
View File
@@ -0,0 +1,34 @@
/*
Copyright 2018 The Fission 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.
*/
// This file tells deepcopy-gen to generate deepcopy methods for all structs in the package.
// For more details, please visit https://blog.openshift.com/kubernetes-deep-dive-code-generation-customresources/
// +k8s:deepcopy-gen=package
// +k8s:defaulter-gen=TypeMeta
// +groupName=fission.io
// +groupGoName=core
//
// In order not to break the backward compatibility, keep coreV1 types stay
// at "fission.io" group instead of moving them to "core.fission.io".
// If the value of group is different from the one we register, the
// CRD client will not be able to get anything from the API server.
package v1
const (
CRD_VERSION = "fission.io/v1"
CRD_NAME_ENVIRONMENT = "Environment"
)
+74
View File
@@ -0,0 +1,74 @@
/*
Copyright 2019 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.
*/
// The file comes from Kubernetes code-generator repo with custom modification.
// https://github.com/kubernetes/code-generator/blob/0826954c61ed88ac5d75e771ade6aae646ca5268/_examples/HyphenGroup/apis/example/v1/register.go
package v1
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)
// In order not to break the backward compatibility, keep coreV1 types stay
// at "fission.io" group instead of moving them to "core.fission.io".
// If the value of group is different from the one we register, the
// CRD client will not be able to get anything from the API server.
var SchemeGroupVersion = schema.GroupVersion{Group: "fission.io", Version: "v1"}
var (
// TODO: move SchemeBuilder with zz_generated.deepcopy.go to k8s.io/api.
// localSchemeBuilder and AddToScheme will stay in k8s.io/kubernetes.
SchemeBuilder runtime.SchemeBuilder
localSchemeBuilder = &SchemeBuilder
AddToScheme = localSchemeBuilder.AddToScheme
)
func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes)
}
// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}
// Adds the list of known types to the given scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(
SchemeGroupVersion,
&Function{},
&FunctionList{},
&Environment{},
&EnvironmentList{},
&HTTPTrigger{},
&HTTPTriggerList{},
&KubernetesWatchTrigger{},
&KubernetesWatchTriggerList{},
&TimeTrigger{},
&TimeTriggerList{},
&MessageQueueTrigger{},
&MessageQueueTriggerList{},
&Package{},
&PackageList{},
&CanaryConfig{},
&CanaryConfigList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
+7
View File
@@ -0,0 +1,7 @@
# How to update swagger (OpenAPI) struct description
Run `update-generated-swagger-docs.sh` and it will parse all comments in `types.go`.
```bash
./update-generated-swagger-docs.sh
```
@@ -0,0 +1,15 @@
/*
Copyright 2019 The Fission 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.
*/
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env bash
# 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.
#
# Please refer https://github.com/kubernetes/kubernetes/tree/master/hack for original file
#
# Contains swagger related util functions.
#
set -o errexit
set -o nounset
set -o pipefail
# Generates types_swagger_doc_generated file for the given group version.
# $1: Name of the group version
# $2: Path to the directory where types.go for that group version exists. This
# is the directory where the file will be generated.
kube::swagger::gen_types_swagger_doc() {
local group_version=$1
local gv_dir=$2
local TMPFILE
TMPFILE="${TMPDIR:-/tmp}/types_swagger_doc_generated.$(date +%s).go"
echo "Generating swagger type docs for ${group_version} at ${gv_dir}"
{
echo -e "$(cat boilerplate.generatego.txt)\n"
echo "package ${group_version##*/}"
cat <<EOF
// 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. DO NOT EDIT.
EOF
} > "${TMPFILE}"
go run ./swagger_type_docs.go -s \
"${gv_dir}/types.go" \
-f - \
>> "${TMPFILE}"
echo "// AUTO-GENERATED FUNCTIONS END HERE" >> "${TMPFILE}"
gofmt -w -s "${TMPFILE}"
mv "${TMPFILE}" "${gv_dir}/types_swagger_doc_generated.go"
}
@@ -0,0 +1,75 @@
/*
Copyright 2015 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.
*/
//
// Please refer https://github.com/kubernetes/kubernetes/blob/master/cmd/genswaggertypedocs/swagger_type_docs.go for original file
//
package main
import (
"fmt"
"io"
"os"
kruntime "k8s.io/apimachinery/pkg/runtime"
flag "github.com/spf13/pflag"
"k8s.io/klog"
)
var (
functionDest = flag.StringP("func-dest", "f", "-", "Output for swagger functions; '-' means stdout (default)")
typeSrc = flag.StringP("type-src", "s", "", "From where we are going to read the types")
verify = flag.BoolP("verify", "v", false, "Verifies if the given type-src file has documentation for every type")
)
func main() {
flag.Parse()
if *typeSrc == "" {
klog.Fatalf("Please define -s flag as it is the source file")
}
var funcOut io.Writer
if *functionDest == "-" {
funcOut = os.Stdout
} else {
file, err := os.Create(*functionDest)
if err != nil {
klog.Fatalf("Couldn't open %v: %v", *functionDest, err)
}
defer file.Close()
funcOut = file
}
docsForTypes := kruntime.ParseDocumentationFrom(*typeSrc)
if *verify {
rc, err := kruntime.VerifySwaggerDocsExist(docsForTypes, funcOut)
if err != nil {
fmt.Fprintf(os.Stderr, "Error in verification process: %s\n", err)
}
os.Exit(rc)
}
if len(docsForTypes) > 0 {
if err := kruntime.WriteSwaggerDocFunc(docsForTypes, funcOut); err != nil {
fmt.Fprintf(os.Stderr, "Error when writing swagger documentation functions: %s\n", err)
os.Exit(-1)
}
}
}
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# Copyright 2015 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.
# Generates `types_swagger_doc_generated.go` files for API group
# versions. That file contains functions on API structs that return
# the comments that should be surfaced for the corresponding API type
# in our API docs.
#
# Please refer https://github.com/kubernetes/kubernetes/tree/master/hack for original file
#
set -o errexit
set -o nounset
set -o pipefail
FISSION_CRD_VERSION=v1
source "swagger.sh"
# To avoid compile errors, remove the currently existing files.
for group_version in "${FISSION_CRD_VERSION}"; do
kube::swagger::gen_types_swagger_doc "${group_version}" ../../${FISSION_CRD_VERSION}
done
+678
View File
@@ -0,0 +1,678 @@
/*
Copyright 2018 The Fission 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 (
apiv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
//
// To add a Fission CRD type:
// 1. Create a "spec" type, for everything in the type except metadata
// 2. Create the type with metadata + the spec
// 3. Create a list type (for example see FunctionList and Function, below)
// 4. Add methods at the bottom of this file for satisfying Object and List interfaces
// 5. Add the type to configureClient in fission/crd/client.go
// 6. Add the type to EnsureFissionCRDs in fission/crd/crd.go
// 7. Add tests to fission/crd/crd_test.go
// 8. Add a CRUD Interface type (analogous to FunctionInterface in fission/crd/function.go)
// 9. Add a getter method for your interface type to FissionClient in fission/crd/client.go
// 10. Follow the instruction in README.md to regenerate CRD type deepcopy methods
//
type (
// Packages. Think of these as function-level images.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Package struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec PackageSpec `json:"spec"`
// Status indicates the build status of package.
Status PackageStatus `json:"status"`
}
// PackageList is a list of Packages.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
PackageList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Package `json:"items"`
}
// Function is function runs within environment runtime with given package and secrets/configmaps.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Function struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec FunctionSpec `json:"spec"`
}
// FunctionList is a list of Functions.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
FunctionList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Function `json:"items"`
}
// Environment is environment for building and running user functions.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Environment struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec EnvironmentSpec `json:"spec"`
}
// EnvironmentList is a list of Environments.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
EnvironmentList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []Environment `json:"items"`
}
// HTTPTrigger is the trigger invokes user functions when receiving HTTP requests.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
HTTPTrigger struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec HTTPTriggerSpec `json:"spec"`
}
// HTTPTriggerList is a list of HTTPTriggers
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
HTTPTriggerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []HTTPTrigger `json:"items"`
}
// KubernetesWatchTrigger watches kubernetes resource events and invokes functions.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
KubernetesWatchTrigger struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec KubernetesWatchTriggerSpec `json:"spec"`
}
// KubernetesWatchTriggerList is a list of KubernetesWatchTriggers
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
KubernetesWatchTriggerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []KubernetesWatchTrigger `json:"items"`
}
// TimeTrigger invokes functions based on given cron schedule.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
TimeTrigger struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec TimeTriggerSpec `json:"spec"`
}
// TimeTriggerList is a list of TimeTriggers.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
TimeTriggerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []TimeTrigger `json:"items"`
}
// MessageQueueTrigger invokes functions when messages arrive to certain topic that trigger subscribes to.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
MessageQueueTrigger struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec MessageQueueTriggerSpec `json:"spec"`
}
// MessageQueueTriggerList is a list of MessageQueueTriggers.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
MessageQueueTriggerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []MessageQueueTrigger `json:"items"`
}
// CanaryConfig is for canary deployment of two functions.
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
CanaryConfig struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`
Spec CanaryConfigSpec `json:"spec"`
Status CanaryConfigStatus `json:"status"`
}
// CanaryConfigList is a list of CanaryConfigs.
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
CanaryConfigList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`
Items []CanaryConfig `json:"items"`
}
//
// Functions and packages
//
// ChecksumType specifies the checksum algorithm, such as
// sha256, used for a checksum.
ChecksumType string
// Checksum of package contents when the contents are stored
// outside the Package struct. Type is the checksum algorithm;
// "sha256" is the only currently supported one. Sum is hex
// encoded.
Checksum struct {
Type ChecksumType `json:"type,omitempty"`
Sum string `json:"sum,omitempty"`
}
// ArchiveType is either literal or URL, indicating whether
// the package is specified in the Archive struct or
// externally.
ArchiveType string
// Package contains or references a collection of source or
// binary files.
Archive struct {
// Type defines how the package is specified: literal or URL.
// Available value:
// - literal
// - url
Type ArchiveType `json:"type,omitempty"`
// Literal contents of the package. Can be used for
// encoding packages below TODO (256KB?) size.
Literal []byte `json:"literal,omitempty"`
// URL references a package.
URL string `json:"url,omitempty"`
// Checksum ensures the integrity of packages
// refereced by URL. Ignored for literals.
Checksum Checksum `json:"checksum,omitempty"`
}
// EnvironmentReference is a reference to a environment.
EnvironmentReference struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}
// SecretReference is a reference to a kubernetes secret.
SecretReference struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}
// ConfigMapReference is a reference to a kubernetes configmap.
ConfigMapReference struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
}
// BuildStatus indicates the current build status of a package.
BuildStatus string
// PackageSpec includes source/deploy archives and the reference of environment to build the package.
PackageSpec struct {
// Environment is a reference to the environment for building source archive.
Environment EnvironmentReference `json:"environment"`
// Source is the archive contains source code and dependencies file.
// If the package status is in PENDING state, builder manager will then
// notify builder to compile source and save the result as deployable archive.
Source Archive `json:"source,omitempty"`
// Deployment is the deployable archive that environment runtime used to run user function.
Deployment Archive `json:"deployment,omitempty"`
// BuildCommand is a custom build command that builder used to build the source archive.
BuildCommand string `json:"buildcmd,omitempty"`
// In the future, we can have a debug build here too
}
// PackageStatus contains the build status of a package also the build log for examination.
PackageStatus struct {
// BuildStatus is the package build status.
BuildStatus BuildStatus `json:"buildstatus,omitempty"`
// BuildLog stores build log during the compilation.
BuildLog string `json:"buildlog,omitempty"` // output of the build (errors etc)
// LastUpdateTimestamp will store the timestamp the package was last updated
// metav1.Time is a wrapper around time.Time which supports correct marshaling to YAML and JSON.
// https://github.com/kubernetes/apimachinery/blob/44bd77c24ef93cd3a5eb6fef64e514025d10d44e/pkg/apis/meta/v1/time.go#L26-L35
LastUpdateTimestamp metav1.Time `json:"lastUpdateTimestamp,omitempty"`
}
// PackageRef is a reference to the package.
PackageRef struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
// Including resource version in the reference forces the function to be updated on
// package update, making it possible to cache the function based on its metadata.
ResourceVersion string `json:"resourceversion,omitempty"`
}
// FunctionPackageRef includes the reference to the package also the entrypoint of package.
FunctionPackageRef struct {
// Package reference
PackageRef PackageRef `json:"packageref"`
// FunctionName specifies a specific function within the package. This allows
// functions to share packages, by having different functions within the same
// package.
//
// Fission itself does not interpret this path. It is passed verbatim to
// build and runtime environments.
//
// This is optional: if unspecified, the environment has a default name.
FunctionName string `json:"functionName,omitempty"`
}
// ExecutorType is the primary executor for an environment
ExecutorType string
// StrategyType is the strategy to be used for function execution
StrategyType string
// FunctionSpec describes the contents of the function.
FunctionSpec struct {
// Environment is the build and runtime environment that this function is
// associated with. An Environment with this name should exist, otherwise the
// function cannot be invoked.
Environment EnvironmentReference `json:"environment"`
// Reference to a package containing deployment and optionally the source.
Package FunctionPackageRef `json:"package"`
// Reference to a list of secrets.
Secrets []SecretReference `json:"secrets"`
// Reference to a list of configmaps.
ConfigMaps []ConfigMapReference `json:"configmaps"`
// cpu and memory resources as per K8S standards
// This is only for newdeploy to set up resource limitation
// when creating deployment for a function.
Resources apiv1.ResourceRequirements `json:"resources"`
// InvokeStrategy is a set of controls which affect how function executes
InvokeStrategy InvokeStrategy
// FunctionTimeout provides a maximum amount of duration within which a request for
// a particular function execution should be complete.
// This is optional. If not specified default value will be taken as 60s
FunctionTimeout int `json:"functionTimeout,omitempty"`
}
// InvokeStrategy is a set of controls over how the function executes.
// It affects the performance and resource usage of the function.
//
// An InvokeStrategy is of one of two types: ExecutionStrategy, which controls low-level
// parameters such as which ExecutorType to use, when to autoscale, minimum and maximum
// number of running instances, etc. A higher-level AbstractInvokeStrategy will also be
// supported; this strategy would specify the target request rate of the function,
// the target latency statistics, and the target cost (in terms of compute resources).
InvokeStrategy struct {
// ExecutionStrategy specifies low-level parameters for function execution,
// such as the number of instances.
ExecutionStrategy ExecutionStrategy
// StrategyType is the strategy type of a function.
// Now it only supports 'execution'.
StrategyType StrategyType
}
// ExecutionStrategy specifies low-level parameters for function execution,
// such as the number of instances.
//
// MinScale affects the cold start behaviour for a function. If MinScale is 0 then the
// deployment is created on first invocation of function and is good for requests of
// asynchronous nature. If MinScale is greater than 0 then MinScale number of pods are
// created at the time of creation of function. This ensures faster response during first
// invocation at the cost of consuming resources.
//
// MaxScale is the maximum number of pods that function will scale to based on TargetCPUPercent
// and resources allocated to the function pod.
ExecutionStrategy struct {
// ExecutorType is the executor type of a function used. Defaults to "poolmgr".
//
// Available value:
// - poolmgr
// - newdeploy
ExecutorType ExecutorType
// This is only for newdeploy to set up minimum replicas of deployment.
MinScale int
// This is only for newdeploy to set up maximum replicas of deployment.
MaxScale int
// This is only for newdeploy to set up target CPU utilization of HPA.
TargetCPUPercent int
// This is the timeout setting for executor to wait for pod specialization.
SpecializationTimeout int
}
FunctionReferenceType string
FunctionReference struct {
// Type indicates whether this function reference is by name or selector. For now,
// the only supported reference type is by "name". Future reference types:
// * Function by label or annotation
// * Branch or tag of a versioned function
// * A "rolling upgrade" from one version of a function to another
// Available value:
// - name
// - function-weights
Type FunctionReferenceType `json:"type"`
// Name of the function.
Name string `json:"name"`
// Function Reference by weight. this map contains function name as key and its weight
// as the value. This is for canary upgrade purpose.
FunctionWeights map[string]int `json:"functionweights"`
}
//
// Environments
//
// Runtime is the setting for environment runtime.
Runtime struct {
// Image for containing the language runtime.
Image string `json:"image"`
// NOT USED NOW
// LoadEndpointPort defines the port on which the
// server listens for function load
// requests. Optional; default 8888.
LoadEndpointPort int32 `json:"-"` // `json:"loadendpointport"`
// NOT USED NOW
// LoadEndpointPath defines the relative URL on which
// the server listens for function load
// requests. Optional; default "/specialize".
LoadEndpointPath string `json:"-"` // `json:"loadendpointpath"`
// NOT USED NOW
// FunctionEndpointPort defines the port on which the
// server listens for function requests. Optional;
// default 8888.
FunctionEndpointPort int32 `json:"-"` // `json:"functionendpointport"`
// (Optional) Container allows the modification of the deployed runtime
// container using the Kubernetes Container spec. Fission overrides
// the following fields:
// - Name
// - Image; set to the Runtime.Image
// - TerminationMessagePath
// - ImagePullPolicy
//
// You can set either PodSpec or Container, but not both.
Container *apiv1.Container `json:"container,omitempty"`
// (Optional) Podspec allows modification of deployed runtime pod with Kubernetes PodSpec
// The merging logic is briefly described below and detailed MergePodSpec function
// - Volumes mounts and env variables for function and fetcher container are appended
// - All additional containers and init containers are appended
// - Volume definitions are appended
// - Lists such as tolerations, ImagePullSecrets, HostAliases are appended
// - Structs are merged and variables from pod spec take precedence
//
// You can set either PodSpec or Container, but not both.
PodSpec *apiv1.PodSpec `json:"podspec,omitempty"`
}
// Builder is the setting for environment builder.
Builder struct {
// Image for containing the language compilation environment.
Image string `json:"image,omitempty"`
// (Optional) Default build command to run for this build environment.
Command string `json:"command,omitempty"`
// (Optional) Container allows the modification of the deployed builder
// container using the Kubernetes Container spec. Fission overrides
// the following fields:
// - Name
// - Image; set to the Builder.Image
// - Command; set to the Builder.Command
// - TerminationMessagePath
// - ImagePullPolicy
// - ReadinessProbe
Container *apiv1.Container `json:"container,omitempty"`
// PodSpec will store the spec of the pod that will be applied to the pod created for the builder
PodSpec *apiv1.PodSpec `json:"podspec,omitempty"`
}
// EnvironmentSpec contains with builder, runtime and some other related environment settings.
EnvironmentSpec struct {
// Version is the Environment API version
//
// Version "1" allows user to run code snippet in a file and
// it's supported by most of environments except tensorflow-serving.
//
// Version "2" supports downloading and compiling user function if source archive is not empty.
//
// Version "3" is almost the same with v2, but you're able to control the size of pre-warm pool of the environment.
Version int `json:"version"`
// Runtime is configuration for running function, like container image etc.
Runtime Runtime `json:"runtime"`
// (Optional) Builder is configuration for builder manager to launch environment builder to build source code into
// deployable binary.
Builder Builder `json:"builder"`
// NOT USED NOW.
// (Optional) Strongly encouraged. Used to populate links from UI, CLI, etc.
DocumentationURL string `json:"-"` // `json:"documentationurl,omitempty"`
// (Optional) defaults to 'single'. Fission workflow uses
// 'infinite' to load multiple functions in one function pod.
// Available value:
// - single
// - infinite
AllowedFunctionsPerContainer AllowedFunctionsPerContainer `json:"allowedFunctionsPerContainer,omitempty"`
// Istio default blocks all egress traffic for safety.
// To enable accessibility of external network for builder/function pod, set to 'true'.
// (Optional) defaults to 'false'
AllowAccessToExternalNetwork bool `json:"allowAccessToExternalNetwork,omitempty"`
// The request and limit CPU/MEM resource setting for poolmanager to set up pods in the pre-warm pool.
// (Optional) defaults to no limitation.
Resources apiv1.ResourceRequirements `json:"resources"`
// The initial pool size for environment
Poolsize int `json:"poolsize,omitempty"`
// The grace time for pod to perform connection draining before termination. The unit is in seconds.
// (Optional) defaults to 360 seconds
TerminationGracePeriod int64 `json:"terminationGracePeriod,omitempty"`
// KeepArchive is used by fetcher to determine if the extracted archive
// or unarchived file should be placed, which is then used by specialize handler.
// (This is mainly for the JVM environment because .jar is one kind of zip archive.)
KeepArchive bool `json:"keeparchive"`
// ImagePullSecret is the secret for Kubernetes to pull an image from a
// private registry.
ImagePullSecret string `json:"imagepullsecret"`
}
AllowedFunctionsPerContainer string
//
// Triggers
//
// HTTPTriggerSpec is for router to expose user functions at the given URL path.
HTTPTriggerSpec struct {
// TODO: remove this field since we have IngressConfig already
// Deprecated: the original idea of this field is not for setting Ingress.
// Since we have IngressConfig now, remove Host after couple releases.
Host string `json:"host"`
// RelativeURL is the exposed URL for external client to access a function with.
RelativeURL string `json:"relativeurl"`
// HTTP method to access a function.
Method string `json:"method"`
// FunctionReference is a reference to the target function.
FunctionReference FunctionReference `json:"functionref"`
// If CreateIngress is true, router will create a ingress definition.
CreateIngress bool `json:"createingress"`
// TODO: make IngressConfig a independent Fission resource
// IngressConfig for router to set up Ingress.
IngressConfig IngressConfig `json:"ingressconfig"`
}
// IngressConfig is for router to set up Ingress.
IngressConfig struct {
// Annotations will be add to metadata when creating Ingress.
Annotations map[string]string `json:"annotations"`
// Path is for path matching. The format of path
// depends on what ingress controller you used.
Path string `json:"path"`
// Host is for ingress controller to apply rules. If
// host is empty or "*", the rule applies to all
// inbound HTTP traffic.
Host string `json:"host"`
// TLS is for user to specify a Secret that contains
// TLS key and certificate. The domain name in the
// key and crt must match the value of Host field.
TLS string `json:"tls"`
}
// KubernetesWatchTriggerSpec
KubernetesWatchTriggerSpec struct {
Namespace string `json:"namespace"`
// Type of resource to watch (Pod, Service, etc.)
Type string `json:"type"`
// Resource labels
LabelSelector map[string]string `json:"labelselector"`
// The reference to a function for kubewatcher to invoke with
// when receiving events.
FunctionReference FunctionReference `json:"functionref"`
}
// Type of message queue
MessageQueueType string
// MessageQueueTriggerSpec defines a binding from a topic in a
// message queue to a function.
MessageQueueTriggerSpec struct {
// The reference to a function for message queue trigger to invoke with
// when receiving messages from subscribed topic.
FunctionReference FunctionReference `json:"functionref"`
// Type of message queue (NATS, Kafka, AzureQueue)
MessageQueueType MessageQueueType `json:"messageQueueType"`
// Subscribed topic
Topic string `json:"topic"`
// Topic for message queue trigger to sent response from function.
ResponseTopic string `json:"respTopic,omitempty"`
// Topic to collect error response sent from function
ErrorTopic string `json:"errorTopic"`
// Maximum times for message queue trigger to retry
MaxRetries int `json:"maxRetries"`
// Content type of payload
ContentType string `json:"contentType"`
}
// TimeTrigger invokes the specific function at a time or
// times specified by a cron string.
TimeTriggerSpec struct {
// Cron schedule
Cron string `json:"cron"`
// The reference to function
FunctionReference `json:"functionref"`
}
FailureType string
// Canary Config Spec
CanaryConfigSpec struct {
// HTTP trigger that this config references
Trigger string `json:"trigger"`
// New version of the function
NewFunction string `json:"newfunction"`
// Old stable version of the function
OldFunction string `json:"oldfunction"`
// Weight increment step for function
WeightIncrement int `json:"weightincrement"`
// Weight increment interval, string representation of time.Duration, ex : 1m, 2h, 2d (default: "2m")
WeightIncrementDuration string `json:"duration"`
// Threshold in percentage beyond which the new version of the function is considered unstable
FailureThreshold int `json:"failurethreshold"`
FailureType FailureType `json:"failureType"`
}
// CanaryConfig Status
CanaryConfigStatus struct {
Status string `json:"status"`
}
)
+691
View File
@@ -0,0 +1,691 @@
/*
Copyright 2018 The Fission 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 (
"fmt"
"net/http"
"regexp"
"strings"
"github.com/hashicorp/go-multierror"
nsUtil "github.com/nats-io/nats-streaming-server/util"
"github.com/robfig/cron"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation"
)
const (
ErrorUnsupportedType = iota
ErrorInvalidValue
ErrorInvalidObject
totalAnnotationSizeLimitB int = 256 * (1 << 10) // 256 kB
)
var (
validAzureQueueName = regexp.MustCompile(`^[a-z0-9][a-z0-9\\-]*[a-z0-9]$`)
// Need to use raw string to support escape sequence for - & . chars
validKafkaTopicName = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9\-\._]*[a-zA-Z0-9]$`)
)
type (
ValidationErrorType int
// ValidationError is a custom error type for resource validation.
// It indicate which field is invalid or illegal in the fission resource.
// Also, it shows what kind of error type, bad value and detail error messages.
ValidationError struct {
// Type of validation error.
// It indicates what kind of error of field in error output.
Type ValidationErrorType
// Name of error field.
// Example: FunctionReference.Name
Field string
// Error field value.
BadValue string
// Detail error message
Detail string
}
)
func (e ValidationError) Error() string {
// Example error message
// Failed to create HTTP trigger: Invalid fission HTTPTrigger object:
// * FunctionReference.Name: Invalid value: findped.ts: [...]
errMsg := fmt.Sprintf("%v: ", e.Field)
switch e.Type {
case ErrorUnsupportedType:
errMsg += fmt.Sprintf("Unsupported type: %v", e.BadValue)
case ErrorInvalidValue:
errMsg += fmt.Sprintf("Invalid value: %v", e.BadValue)
case ErrorInvalidObject:
errMsg += fmt.Sprintf("Invalid object: %v", e.BadValue)
default:
errMsg += fmt.Sprintf("Unknown error type: %v", e.BadValue)
}
if len(e.Detail) > 0 {
errMsg += fmt.Sprintf(": %v", e.Detail)
}
return errMsg
}
func AggregateValidationErrors(objName string, err error) error {
result := &multierror.Error{}
result = multierror.Append(result, err)
result.ErrorFormat = func(errs []error) string {
errMsg := fmt.Sprintf("Invalid fission %v object:\n", objName)
for _, err := range errs {
errMsg += fmt.Sprintf("* %v\n", err.Error())
}
return errMsg
}
return result.ErrorOrNil()
}
func MakeValidationErr(errType ValidationErrorType, field string, val interface{}, detail ...string) ValidationError {
return ValidationError{
Type: errType,
Field: field,
BadValue: fmt.Sprintf("%v", val),
Detail: fmt.Sprintf("%v", detail),
}
}
func ValidateKubeLabel(field string, labels map[string]string) error {
result := &multierror.Error{}
for k, v := range labels {
// Example: XXX -> YYY
// KubernetesWatchTriggerSpec.LabelSelector.Key: Invalid value: XXX
// KubernetesWatchTriggerSpec.LabelSelector.Value: Invalid value: YYY
result = multierror.Append(result,
MakeValidationErr(ErrorInvalidValue, fmt.Sprintf("%v.Key", field), k, validation.IsQualifiedName(k)...),
MakeValidationErr(ErrorInvalidValue, fmt.Sprintf("%v.Value", field), v, validation.IsValidLabelValue(v)...))
}
return result.ErrorOrNil()
}
func ValidateKubePort(field string, port int) error {
result := &multierror.Error{}
e := validation.IsValidPortNum(port)
if len(e) > 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, field, port, e...))
}
return result.ErrorOrNil()
}
func ValidateKubeName(field string, val string) error {
result := &multierror.Error{}
e := validation.IsDNS1123Label(val)
if len(e) > 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, field, val, e...))
}
return result.ErrorOrNil()
}
func ValidateKubeReference(refName string, name string, namespace string) error {
result := &multierror.Error{}
result = multierror.Append(result,
ValidateKubeName(fmt.Sprintf("%v.Name", refName), name),
ValidateKubeName(fmt.Sprintf("%v.Namespace", refName), namespace))
return result.ErrorOrNil()
}
func IsTopicValid(mqType MessageQueueType, topic string) bool {
switch mqType {
case MessageQueueTypeNats:
return nsUtil.IsChannelNameValid(topic, false)
case MessageQueueTypeASQ:
return len(topic) >= 3 && len(topic) <= 63 && validAzureQueueName.MatchString(topic)
case MessageQueueTypeKafka:
return IsValidKafkaTopic(topic)
}
return false
}
// The validation is based on Kafka's internal implementation: https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/common/internals/Topic.java
func IsValidKafkaTopic(topic string) bool {
if len(topic) == 0 {
return false
}
if topic == "." || topic == ".." {
return false
}
if len(topic) > 249 {
return false
}
if !validKafkaTopicName.MatchString(topic) {
return false
}
return true
}
func IsValidCronSpec(spec string) error {
_, err := cron.Parse(spec)
return err
}
/* Resource validation function */
func (checksum Checksum) Validate() error {
result := &multierror.Error{}
switch checksum.Type {
case ChecksumTypeSHA256: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "Checksum.Type", checksum.Type, "not a valid checksum type"))
}
return result.ErrorOrNil()
}
func (archive Archive) Validate() error {
result := &multierror.Error{}
if len(archive.Type) > 0 {
switch archive.Type {
case ArchiveTypeLiteral, ArchiveTypeUrl: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "Archive.Type", archive.Type, "not a valid archive type"))
}
}
if archive.Checksum != (Checksum{}) {
result = multierror.Append(result, archive.Checksum.Validate())
}
return result.ErrorOrNil()
}
func (ref EnvironmentReference) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, ValidateKubeReference("EnvironmentReference", ref.Name, ref.Namespace))
return result.ErrorOrNil()
}
func (ref SecretReference) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, ValidateKubeReference("SecretReference", ref.Name, ref.Namespace))
return result.ErrorOrNil()
}
func (ref ConfigMapReference) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, ValidateKubeReference("ConfigMapReference", ref.Name, ref.Namespace))
return result.ErrorOrNil()
}
func (spec PackageSpec) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, spec.Environment.Validate())
for _, r := range []Archive{spec.Source, spec.Deployment} {
if len(r.URL) > 0 || len(r.Literal) > 0 {
result = multierror.Append(result, r.Validate())
}
}
return result.ErrorOrNil()
}
func (sts PackageStatus) Validate() error {
result := &multierror.Error{}
switch sts.BuildStatus {
case BuildStatusPending, BuildStatusRunning, BuildStatusSucceeded, BuildStatusFailed, BuildStatusNone: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "PackageStatus.BuildStatus", sts.BuildStatus, "not a valid build status"))
}
return result.ErrorOrNil()
}
func (ref PackageRef) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, ValidateKubeReference("PackageRef", ref.Name, ref.Namespace))
return result.ErrorOrNil()
}
func (ref FunctionPackageRef) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, ref.PackageRef.Validate())
return result.ErrorOrNil()
}
func (spec FunctionSpec) Validate() error {
result := &multierror.Error{}
if spec.Environment != (EnvironmentReference{}) {
result = multierror.Append(result, spec.Environment.Validate())
}
if spec.Package != (FunctionPackageRef{}) {
result = multierror.Append(result, spec.Package.Validate())
}
for _, s := range spec.Secrets {
result = multierror.Append(result, s.Validate())
}
for _, c := range spec.ConfigMaps {
result = multierror.Append(result, c.Validate())
}
if spec.InvokeStrategy != (InvokeStrategy{}) {
result = multierror.Append(result, spec.InvokeStrategy.Validate())
}
// TODO Add below validation warning
/*if spec.FunctionTimeout <= 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "FunctionTimeout value", spec.FunctionTimeout, "not a valid value. Should always be more than 0"))
}*/
return result.ErrorOrNil()
}
func (is InvokeStrategy) Validate() error {
result := &multierror.Error{}
switch is.StrategyType {
case StrategyTypeExecution: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "InvokeStrategy.StrategyType", is.StrategyType, "not a valid valid strategy"))
}
result = multierror.Append(result, is.ExecutionStrategy.Validate())
return result.ErrorOrNil()
}
func (es ExecutionStrategy) Validate() error {
result := &multierror.Error{}
switch es.ExecutorType {
case ExecutorTypeNewdeploy, ExecutorTypePoolmgr: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "ExecutionStrategy.ExecutorType", es.ExecutorType, "not a valid executor type"))
}
if es.ExecutorType == ExecutorTypeNewdeploy {
if es.MinScale < 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MinScale", es.MinScale, "minimum scale must be greater than or equal to 0"))
}
if es.MaxScale <= 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MaxScale", es.MaxScale, "maximum scale must be greater than 0"))
}
if es.MaxScale < es.MinScale {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MaxScale", es.MaxScale, "maximum scale must be greater than or equal to minimum scale"))
}
if es.TargetCPUPercent <= 0 || es.TargetCPUPercent > 100 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.TargetCPUPercent", es.TargetCPUPercent, "TargetCPUPercent must be a value between 1 - 100"))
}
// TODO Add validation warning
//if es.SpecializationTimeout < 120 {
// result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.SpecializationTimeout", es.SpecializationTimeout, "SpecializationTimeout must be a value equal to or greater than 120"))
//}
}
return result.ErrorOrNil()
}
func (ref FunctionReference) Validate() error {
result := &multierror.Error{}
switch ref.Type {
case FunctionReferenceTypeFunctionName: // no op
case FunctionReferenceTypeFunctionWeights: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "FunctionReference.Type", ref.Type, "not a valid function reference type"))
}
if ref.Type == FunctionReferenceTypeFunctionName {
result = multierror.Append(result, ValidateKubeName("FunctionReference.Name", ref.Name))
}
return result.ErrorOrNil()
}
func (runtime Runtime) Validate() error {
result := &multierror.Error{}
if runtime.LoadEndpointPort > 0 {
result = multierror.Append(result, ValidateKubePort("Runtime.LoadEndpointPort", int(runtime.LoadEndpointPort)))
}
if runtime.FunctionEndpointPort > 0 {
result = multierror.Append(result, ValidateKubePort("Runtime.FunctionEndpointPort", int(runtime.FunctionEndpointPort)))
}
return result.ErrorOrNil()
}
func (builder Builder) Validate() error {
// do nothing for now
return nil
}
func (spec EnvironmentSpec) Validate() error {
result := &multierror.Error{}
if spec.Version < 1 || spec.Version > 3 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.Version", spec.Version, "not a valid environment version"))
}
result = multierror.Append(result, spec.Runtime.Validate())
if spec.Builder != (Builder{}) {
result = multierror.Append(result, spec.Builder.Validate())
}
if len(spec.AllowedFunctionsPerContainer) > 0 {
switch spec.AllowedFunctionsPerContainer {
case AllowedFunctionsPerContainerSingle, AllowedFunctionsPerContainerInfinite: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "EnvironmentSpec.AllowedFunctionsPerContainer", spec.AllowedFunctionsPerContainer, "not a valid value"))
}
}
if spec.Poolsize < 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.Poolsize", spec.Poolsize, "must be greater than or equal to 0"))
}
if spec.TerminationGracePeriod < 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.TerminationGracePeriod", spec.TerminationGracePeriod, "must be greater than or equal to 0"))
}
return result.ErrorOrNil()
}
func (spec HTTPTriggerSpec) Validate() error {
result := &multierror.Error{}
switch spec.Method {
case http.MethodGet, http.MethodHead, http.MethodPost, http.MethodPut, http.MethodPatch,
http.MethodDelete, http.MethodConnect, http.MethodOptions, http.MethodTrace: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "HTTPTriggerSpec.Method", spec.Method, "not a valid HTTP method"))
}
result = multierror.Append(result, spec.FunctionReference.Validate())
if len(spec.Host) > 0 {
e := validation.IsDNS1123Subdomain(spec.Host)
if len(e) > 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.Host", spec.Host, e...))
}
}
result = multierror.Append(result, spec.IngressConfig.Validate())
return result.ErrorOrNil()
}
func (config IngressConfig) Validate() error {
result := &multierror.Error{}
// Details for how to validate Ingress host rule,
// see https://github.com/kubernetes/kubernetes/blob/release-1.16/pkg/apis/networking/validation/validation.go
if len(config.Path) > 0 {
if !strings.HasPrefix(config.Path, "/") {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.IngressConfig.IngressRule.Path", config.Path, "must be an absolute path"))
}
_, err := regexp.CompilePOSIX(config.Path)
if err != nil {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.IngressConfig.IngressRule.Path", config.Path, "must be a valid regex"))
}
}
// In Ingress, to accept requests from all host, the host field will
// be an empty string instead of "*" shown in kubectl. The router replaces
// the asterisk with "" when creating/updateing the Ingress, so here we
// skip the check if the Host is equal to "*".
if len(config.Host) > 0 && config.Host != "*" {
if strings.Contains(config.Host, "*") {
for _, msg := range validation.IsWildcardDNS1123Subdomain(config.Host) {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.IngressConfig.IngressRule.Host", config.Host, msg))
}
}
for _, msg := range validation.IsDNS1123Subdomain(config.Host) {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.IngressConfig.IngressRule.Host", config.Host, msg))
}
}
// Details for how to validate annotations,
// see https://github.com/kubernetes/kubernetes/blob/512eccac1f1d72d6d1cb304bc565c50d1f2e295e/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go#L46
var totalSize int64
for k, v := range config.Annotations {
for _, msg := range validation.IsQualifiedName(strings.ToLower(k)) {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.IngressConfig.Annotations.key", k, msg))
}
totalSize += (int64)(len(k)) + (int64)(len(v))
}
if totalSize > (int64)(totalAnnotationSizeLimitB) {
msg := fmt.Sprintf("must have at most %v characters", totalSize)
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "HTTPTriggerSpec.IngressConfig.Annotations.value", totalAnnotationSizeLimitB, msg))
}
return result.ErrorOrNil()
}
func (spec KubernetesWatchTriggerSpec) Validate() error {
result := &multierror.Error{}
switch strings.ToUpper(spec.Type) {
case "POD", "SERVICE", "REPLICATIONCONTROLLER", "JOB":
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "KubernetesWatchTriggerSpec.Type", spec.Type, "not a valid supported type"))
}
result = multierror.Append(result,
ValidateKubeName("KubernetesWatchTriggerSpec.Namespace", spec.Namespace),
ValidateKubeLabel("KubernetesWatchTriggerSpec.LabelSelector", spec.LabelSelector),
spec.FunctionReference.Validate())
return result.ErrorOrNil()
}
func (spec MessageQueueTriggerSpec) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result, spec.FunctionReference.Validate())
switch spec.MessageQueueType {
case MessageQueueTypeNats, MessageQueueTypeASQ, MessageQueueTypeKafka: // no op
default:
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "MessageQueueTriggerSpec.MessageQueueType", spec.MessageQueueType, "not a supported message queue type"))
}
if !IsTopicValid(spec.MessageQueueType, spec.Topic) {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "MessageQueueTriggerSpec.Topic", spec.Topic, "not a valid topic"))
}
if len(spec.ResponseTopic) > 0 && !IsTopicValid(spec.MessageQueueType, spec.ResponseTopic) {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "MessageQueueTriggerSpec.ResponseTopic", spec.ResponseTopic, "not a valid topic"))
}
return result.ErrorOrNil()
}
func (spec TimeTriggerSpec) Validate() error {
result := &multierror.Error{}
err := IsValidCronSpec(spec.Cron)
if err != nil {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "TimeTriggerSpec.Cron", spec.Cron, "not a valid cron spec"))
}
result = multierror.Append(result, spec.FunctionReference.Validate())
return result.ErrorOrNil()
}
func validateMetadata(field string, m metav1.ObjectMeta) error {
return ValidateKubeReference(field, m.Name, m.Namespace)
}
func (p *Package) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("Package", p.ObjectMeta),
p.Spec.Validate(),
p.Status.Validate())
return result.ErrorOrNil()
}
func (pl *PackageList) Validate() error {
result := &multierror.Error{}
// not validate ListMeta
for _, p := range pl.Items {
result = multierror.Append(result, p.Validate())
}
return result.ErrorOrNil()
}
func (f *Function) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("Function", f.ObjectMeta),
f.Spec.Validate())
return result.ErrorOrNil()
}
func (fl *FunctionList) Validate() error {
result := &multierror.Error{}
for _, f := range fl.Items {
result = multierror.Append(result, f.Validate())
}
return result.ErrorOrNil()
}
func (e *Environment) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("Environment", e.ObjectMeta),
e.Spec.Validate())
return result.ErrorOrNil()
}
func (el *EnvironmentList) Validate() error {
result := &multierror.Error{}
for _, e := range el.Items {
result = multierror.Append(result, e.Validate())
}
return result.ErrorOrNil()
}
func (h *HTTPTrigger) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("HTTPTrigger", h.ObjectMeta),
h.Spec.Validate())
return result.ErrorOrNil()
}
func (hl *HTTPTriggerList) Validate() error {
result := &multierror.Error{}
for _, h := range hl.Items {
result = multierror.Append(result, h.Validate())
}
return result.ErrorOrNil()
}
func (k *KubernetesWatchTrigger) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("KubernetesWatchTrigger", k.ObjectMeta),
k.Spec.Validate())
return result.ErrorOrNil()
}
func (kl *KubernetesWatchTriggerList) Validate() error {
result := &multierror.Error{}
for _, k := range kl.Items {
result = multierror.Append(result, k.Validate())
}
return result
}
func (t *TimeTrigger) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("TimeTrigger", t.ObjectMeta),
t.Spec.Validate())
return result.ErrorOrNil()
}
func (tl *TimeTriggerList) Validate() error {
result := &multierror.Error{}
for _, t := range tl.Items {
result = multierror.Append(result, t.Validate())
}
return result.ErrorOrNil()
}
func (m *MessageQueueTrigger) Validate() error {
result := &multierror.Error{}
result = multierror.Append(result,
validateMetadata("MessageQueueTrigger", m.ObjectMeta),
m.Spec.Validate())
return result.ErrorOrNil()
}
func (ml *MessageQueueTriggerList) Validate() error {
result := &multierror.Error{}
for _, m := range ml.Items {
result = multierror.Append(result, m.Validate())
}
return result.ErrorOrNil()
}
+967
View File
@@ -0,0 +1,967 @@
// +build !ignore_autogenerated
/*
Copyright The Fission 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.
*/
// Code generated by deepcopy-gen. DO NOT EDIT.
package v1
import (
corev1 "k8s.io/api/core/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Archive) DeepCopyInto(out *Archive) {
*out = *in
if in.Literal != nil {
in, out := &in.Literal, &out.Literal
*out = make([]byte, len(*in))
copy(*out, *in)
}
out.Checksum = in.Checksum
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Archive.
func (in *Archive) DeepCopy() *Archive {
if in == nil {
return nil
}
out := new(Archive)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Builder) DeepCopyInto(out *Builder) {
*out = *in
if in.Container != nil {
in, out := &in.Container, &out.Container
*out = new(corev1.Container)
(*in).DeepCopyInto(*out)
}
if in.PodSpec != nil {
in, out := &in.PodSpec, &out.PodSpec
*out = new(corev1.PodSpec)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Builder.
func (in *Builder) DeepCopy() *Builder {
if in == nil {
return nil
}
out := new(Builder)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CanaryConfig) DeepCopyInto(out *CanaryConfig) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
out.Status = in.Status
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryConfig.
func (in *CanaryConfig) DeepCopy() *CanaryConfig {
if in == nil {
return nil
}
out := new(CanaryConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *CanaryConfig) 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 *CanaryConfigList) DeepCopyInto(out *CanaryConfigList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]CanaryConfig, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryConfigList.
func (in *CanaryConfigList) DeepCopy() *CanaryConfigList {
if in == nil {
return nil
}
out := new(CanaryConfigList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *CanaryConfigList) 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 *CanaryConfigSpec) DeepCopyInto(out *CanaryConfigSpec) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryConfigSpec.
func (in *CanaryConfigSpec) DeepCopy() *CanaryConfigSpec {
if in == nil {
return nil
}
out := new(CanaryConfigSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *CanaryConfigStatus) DeepCopyInto(out *CanaryConfigStatus) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryConfigStatus.
func (in *CanaryConfigStatus) DeepCopy() *CanaryConfigStatus {
if in == nil {
return nil
}
out := new(CanaryConfigStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Checksum) DeepCopyInto(out *Checksum) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Checksum.
func (in *Checksum) DeepCopy() *Checksum {
if in == nil {
return nil
}
out := new(Checksum)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ConfigMapReference) DeepCopyInto(out *ConfigMapReference) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ConfigMapReference.
func (in *ConfigMapReference) DeepCopy() *ConfigMapReference {
if in == nil {
return nil
}
out := new(ConfigMapReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Environment) DeepCopyInto(out *Environment) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Environment.
func (in *Environment) DeepCopy() *Environment {
if in == nil {
return nil
}
out := new(Environment)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Environment) 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 *EnvironmentList) DeepCopyInto(out *EnvironmentList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Environment, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentList.
func (in *EnvironmentList) DeepCopy() *EnvironmentList {
if in == nil {
return nil
}
out := new(EnvironmentList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *EnvironmentList) 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 *EnvironmentReference) DeepCopyInto(out *EnvironmentReference) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentReference.
func (in *EnvironmentReference) DeepCopy() *EnvironmentReference {
if in == nil {
return nil
}
out := new(EnvironmentReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *EnvironmentSpec) DeepCopyInto(out *EnvironmentSpec) {
*out = *in
in.Runtime.DeepCopyInto(&out.Runtime)
in.Builder.DeepCopyInto(&out.Builder)
in.Resources.DeepCopyInto(&out.Resources)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new EnvironmentSpec.
func (in *EnvironmentSpec) DeepCopy() *EnvironmentSpec {
if in == nil {
return nil
}
out := new(EnvironmentSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ExecutionStrategy) DeepCopyInto(out *ExecutionStrategy) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExecutionStrategy.
func (in *ExecutionStrategy) DeepCopy() *ExecutionStrategy {
if in == nil {
return nil
}
out := new(ExecutionStrategy)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Function) DeepCopyInto(out *Function) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Function.
func (in *Function) DeepCopy() *Function {
if in == nil {
return nil
}
out := new(Function)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Function) 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 *FunctionList) DeepCopyInto(out *FunctionList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Function, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionList.
func (in *FunctionList) DeepCopy() *FunctionList {
if in == nil {
return nil
}
out := new(FunctionList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *FunctionList) 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 *FunctionPackageRef) DeepCopyInto(out *FunctionPackageRef) {
*out = *in
out.PackageRef = in.PackageRef
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionPackageRef.
func (in *FunctionPackageRef) DeepCopy() *FunctionPackageRef {
if in == nil {
return nil
}
out := new(FunctionPackageRef)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FunctionReference) DeepCopyInto(out *FunctionReference) {
*out = *in
if in.FunctionWeights != nil {
in, out := &in.FunctionWeights, &out.FunctionWeights
*out = make(map[string]int, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionReference.
func (in *FunctionReference) DeepCopy() *FunctionReference {
if in == nil {
return nil
}
out := new(FunctionReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *FunctionSpec) DeepCopyInto(out *FunctionSpec) {
*out = *in
out.Environment = in.Environment
out.Package = in.Package
if in.Secrets != nil {
in, out := &in.Secrets, &out.Secrets
*out = make([]SecretReference, len(*in))
copy(*out, *in)
}
if in.ConfigMaps != nil {
in, out := &in.ConfigMaps, &out.ConfigMaps
*out = make([]ConfigMapReference, len(*in))
copy(*out, *in)
}
in.Resources.DeepCopyInto(&out.Resources)
out.InvokeStrategy = in.InvokeStrategy
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FunctionSpec.
func (in *FunctionSpec) DeepCopy() *FunctionSpec {
if in == nil {
return nil
}
out := new(FunctionSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HTTPTrigger) DeepCopyInto(out *HTTPTrigger) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPTrigger.
func (in *HTTPTrigger) DeepCopy() *HTTPTrigger {
if in == nil {
return nil
}
out := new(HTTPTrigger)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HTTPTrigger) 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 *HTTPTriggerList) DeepCopyInto(out *HTTPTriggerList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]HTTPTrigger, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPTriggerList.
func (in *HTTPTriggerList) DeepCopy() *HTTPTriggerList {
if in == nil {
return nil
}
out := new(HTTPTriggerList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *HTTPTriggerList) 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 *HTTPTriggerSpec) DeepCopyInto(out *HTTPTriggerSpec) {
*out = *in
in.FunctionReference.DeepCopyInto(&out.FunctionReference)
in.IngressConfig.DeepCopyInto(&out.IngressConfig)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTPTriggerSpec.
func (in *HTTPTriggerSpec) DeepCopy() *HTTPTriggerSpec {
if in == nil {
return nil
}
out := new(HTTPTriggerSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IngressConfig) DeepCopyInto(out *IngressConfig) {
*out = *in
if in.Annotations != nil {
in, out := &in.Annotations, &out.Annotations
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IngressConfig.
func (in *IngressConfig) DeepCopy() *IngressConfig {
if in == nil {
return nil
}
out := new(IngressConfig)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *InvokeStrategy) DeepCopyInto(out *InvokeStrategy) {
*out = *in
out.ExecutionStrategy = in.ExecutionStrategy
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new InvokeStrategy.
func (in *InvokeStrategy) DeepCopy() *InvokeStrategy {
if in == nil {
return nil
}
out := new(InvokeStrategy)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *KubernetesWatchTrigger) DeepCopyInto(out *KubernetesWatchTrigger) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesWatchTrigger.
func (in *KubernetesWatchTrigger) DeepCopy() *KubernetesWatchTrigger {
if in == nil {
return nil
}
out := new(KubernetesWatchTrigger)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *KubernetesWatchTrigger) 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 *KubernetesWatchTriggerList) DeepCopyInto(out *KubernetesWatchTriggerList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]KubernetesWatchTrigger, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesWatchTriggerList.
func (in *KubernetesWatchTriggerList) DeepCopy() *KubernetesWatchTriggerList {
if in == nil {
return nil
}
out := new(KubernetesWatchTriggerList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *KubernetesWatchTriggerList) 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 *KubernetesWatchTriggerSpec) DeepCopyInto(out *KubernetesWatchTriggerSpec) {
*out = *in
if in.LabelSelector != nil {
in, out := &in.LabelSelector, &out.LabelSelector
*out = make(map[string]string, len(*in))
for key, val := range *in {
(*out)[key] = val
}
}
in.FunctionReference.DeepCopyInto(&out.FunctionReference)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesWatchTriggerSpec.
func (in *KubernetesWatchTriggerSpec) DeepCopy() *KubernetesWatchTriggerSpec {
if in == nil {
return nil
}
out := new(KubernetesWatchTriggerSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *MessageQueueTrigger) DeepCopyInto(out *MessageQueueTrigger) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MessageQueueTrigger.
func (in *MessageQueueTrigger) DeepCopy() *MessageQueueTrigger {
if in == nil {
return nil
}
out := new(MessageQueueTrigger)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MessageQueueTrigger) 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 *MessageQueueTriggerList) DeepCopyInto(out *MessageQueueTriggerList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]MessageQueueTrigger, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MessageQueueTriggerList.
func (in *MessageQueueTriggerList) DeepCopy() *MessageQueueTriggerList {
if in == nil {
return nil
}
out := new(MessageQueueTriggerList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *MessageQueueTriggerList) 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 *MessageQueueTriggerSpec) DeepCopyInto(out *MessageQueueTriggerSpec) {
*out = *in
in.FunctionReference.DeepCopyInto(&out.FunctionReference)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MessageQueueTriggerSpec.
func (in *MessageQueueTriggerSpec) DeepCopy() *MessageQueueTriggerSpec {
if in == nil {
return nil
}
out := new(MessageQueueTriggerSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Package) DeepCopyInto(out *Package) {
*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 Package.
func (in *Package) DeepCopy() *Package {
if in == nil {
return nil
}
out := new(Package)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *Package) 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 *PackageList) DeepCopyInto(out *PackageList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]Package, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageList.
func (in *PackageList) DeepCopy() *PackageList {
if in == nil {
return nil
}
out := new(PackageList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *PackageList) 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 *PackageRef) DeepCopyInto(out *PackageRef) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageRef.
func (in *PackageRef) DeepCopy() *PackageRef {
if in == nil {
return nil
}
out := new(PackageRef)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PackageSpec) DeepCopyInto(out *PackageSpec) {
*out = *in
out.Environment = in.Environment
in.Source.DeepCopyInto(&out.Source)
in.Deployment.DeepCopyInto(&out.Deployment)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageSpec.
func (in *PackageSpec) DeepCopy() *PackageSpec {
if in == nil {
return nil
}
out := new(PackageSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PackageStatus) DeepCopyInto(out *PackageStatus) {
*out = *in
in.LastUpdateTimestamp.DeepCopyInto(&out.LastUpdateTimestamp)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PackageStatus.
func (in *PackageStatus) DeepCopy() *PackageStatus {
if in == nil {
return nil
}
out := new(PackageStatus)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *Runtime) DeepCopyInto(out *Runtime) {
*out = *in
if in.Container != nil {
in, out := &in.Container, &out.Container
*out = new(corev1.Container)
(*in).DeepCopyInto(*out)
}
if in.PodSpec != nil {
in, out := &in.PodSpec, &out.PodSpec
*out = new(corev1.PodSpec)
(*in).DeepCopyInto(*out)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Runtime.
func (in *Runtime) DeepCopy() *Runtime {
if in == nil {
return nil
}
out := new(Runtime)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *SecretReference) DeepCopyInto(out *SecretReference) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretReference.
func (in *SecretReference) DeepCopy() *SecretReference {
if in == nil {
return nil
}
out := new(SecretReference)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *TimeTrigger) DeepCopyInto(out *TimeTrigger) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimeTrigger.
func (in *TimeTrigger) DeepCopy() *TimeTrigger {
if in == nil {
return nil
}
out := new(TimeTrigger)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TimeTrigger) 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 *TimeTriggerList) DeepCopyInto(out *TimeTriggerList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]TimeTrigger, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimeTriggerList.
func (in *TimeTriggerList) DeepCopy() *TimeTriggerList {
if in == nil {
return nil
}
out := new(TimeTriggerList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *TimeTriggerList) 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 *TimeTriggerSpec) DeepCopyInto(out *TimeTriggerSpec) {
*out = *in
in.FunctionReference.DeepCopyInto(&out.FunctionReference)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TimeTriggerSpec.
func (in *TimeTriggerSpec) DeepCopy() *TimeTriggerSpec {
if in == nil {
return nil
}
out := new(TimeTriggerSpec)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ValidationError) DeepCopyInto(out *ValidationError) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ValidationError.
func (in *ValidationError) DeepCopy() *ValidationError {
if in == nil {
return nil
}
out := new(ValidationError)
in.DeepCopyInto(out)
return out
}