130 lines
4.1 KiB
Protocol Buffer
130 lines
4.1 KiB
Protocol Buffer
/*
|
|
Copyright 2022 The Crossplane 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.
|
|
*/
|
|
|
|
// TODO(negz): Add a make target such that `make lint` runs `buf lint`.
|
|
|
|
syntax = "proto3";
|
|
|
|
import "google/protobuf/duration.proto";
|
|
|
|
package apiextensions.fn.proto.v1alpha1;
|
|
|
|
option go_package = "github.com/crossplane/crossplane/apis/apiextensions/fn/proto/v1alpha1";
|
|
|
|
// A ContainerizedFunctionRunnerService runs containerized Composition Functions.
|
|
service ContainerizedFunctionRunnerService {
|
|
// RunFunction runs a containerized function.
|
|
rpc RunFunction(RunFunctionRequest) returns (RunFunctionResponse) {}
|
|
}
|
|
|
|
// ImagePullPolicy specifies when a Composition Function container should be
|
|
// pulled from a remote OCI registry.
|
|
enum ImagePullPolicy {
|
|
IMAGE_PULL_POLICY_UNSPECIFIED = 0;
|
|
IMAGE_PULL_POLICY_IF_NOT_PRESENT = 1;
|
|
IMAGE_PULL_POLICY_ALWAYS = 2;
|
|
IMAGE_PULL_POLICY_NEVER = 3;
|
|
}
|
|
|
|
// ImagePullAuth configures authentication to a remote OCI registry.
|
|
// It corresponds to go-containerregistry's AuthConfig type.
|
|
// https://pkg.go.dev/github.com/google/go-containerregistry@v0.11.0/pkg/authn#AuthConfig
|
|
message ImagePullAuth {
|
|
string username = 1;
|
|
string password = 2;
|
|
string auth = 3;
|
|
string identity_token = 4;
|
|
string registry_token = 5;
|
|
}
|
|
|
|
// ImagePullConfig configures how a Composition Function container should be
|
|
// pulled from a remote OCI registry.
|
|
message ImagePullConfig {
|
|
ImagePullPolicy pull_policy = 1;
|
|
ImagePullAuth auth = 2;
|
|
}
|
|
|
|
// NetworkPolicy configures whether a container is isolated from the network.
|
|
enum NetworkPolicy {
|
|
NETWORK_POLICY_UNSPECIFIED = 0;
|
|
|
|
// Run the container without network access. The default.
|
|
NETWORK_POLICY_ISOLATED = 1;
|
|
|
|
// Allow the container to access the same network as the function runner.
|
|
NETWORK_POLICY_RUNNER = 2;
|
|
}
|
|
|
|
// NetworkConfig configures whether and how a Composition Function container may
|
|
// access the network.
|
|
message NetworkConfig {
|
|
// Whether or not the container can access the network.
|
|
NetworkPolicy policy = 1;
|
|
}
|
|
|
|
// Resources configures what compute resources should be available to a
|
|
// Composition Function container.
|
|
message ResourceConfig {
|
|
ResourceLimits limits = 1;
|
|
}
|
|
|
|
// ResourceLimits configures the maximum compute resources that will be
|
|
// available to a Composition Function container.
|
|
message ResourceLimits {
|
|
// CPU, in cores. (500m = .5 cores)
|
|
// Specified in Kubernetes-style resource.Quantity form.
|
|
string memory = 1;
|
|
|
|
// Memory, in bytes. (500Gi = 500GiB = 500 * 1024 * 1024 * 1024)
|
|
// Specified in Kubernetes-style resource.Quantity form.
|
|
string cpu = 2;
|
|
}
|
|
|
|
// RunFunctionConfig configures how a Composition Function container is run.
|
|
message RunFunctionConfig {
|
|
// Resources available to the container.
|
|
ResourceConfig resources = 1;
|
|
|
|
// Network configuration for the container.
|
|
NetworkConfig network = 2;
|
|
|
|
// Timeout after which the container will be killed.
|
|
google.protobuf.Duration timeout = 3;
|
|
}
|
|
|
|
// A RunFunctionRequest requests that a Composition Function be run.
|
|
message RunFunctionRequest {
|
|
// OCI image of the Composition Function.
|
|
string image = 1;
|
|
|
|
// A FunctionIO serialized as YAML.
|
|
bytes input = 2;
|
|
|
|
// Configures how the function image is pulled.
|
|
ImagePullConfig image_pull_config = 3;
|
|
|
|
// Configures how the function container is run.
|
|
RunFunctionConfig run_function_config = 4;
|
|
}
|
|
|
|
// A RunFunctionResponse contains the response from a Composition Function run.
|
|
// The output FunctionIO is returned as opaque bytes. Errors encountered while
|
|
// running a function (as opposed to errors returned _by_ a function) will be
|
|
// encapsulated as gRPC errors.
|
|
message RunFunctionResponse {
|
|
bytes output = 1;
|
|
}
|