Skip to content

Commit

Permalink
Add Interceptor CRD type
Browse files Browse the repository at this point in the history
This commit adds the Interceptor CRD type as defined in TEP.
The `spec` currently only contains a URL field to locate where the interceptor
is running. Other fields will be added as they are implemented in follow ups.

Part of tektoncd#868

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
  • Loading branch information
dibyom committed Jan 26, 2021
1 parent 69557ae commit 9b78c21
Show file tree
Hide file tree
Showing 16 changed files with 748 additions and 0 deletions.
54 changes: 54 additions & 0 deletions config/300-interceptor.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2019 The Tekton 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
#
# https://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.

apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: interceptors.triggers.tekton.dev
labels:
app.kubernetes.io/instance: default
app.kubernetes.io/part-of: tekton-triggers
triggers.tekton.dev/release: "devel"
version: "devel"
spec:
group: triggers.tekton.dev
scope: Cluster
names:
kind: Interceptor
plural: interceptors
singular: interceptor
shortNames:
- i
categories:
- tekton
- tekton-triggers
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
# One can use x-kubernetes-preserve-unknown-fields: true
# at the root of the schema (and inside any properties, additionalProperties)
# to get the traditional CRD behaviour that nothing is pruned, despite
# setting spec.preserveUnknownProperties: false.
#
# See https://kubernetes.io/blog/2019/06/20/crd-structural-schema/
# See issue: https://github.com/knative/serving/issues/912
x-kubernetes-preserve-unknown-fields: true
# Opt into the status subresource so metadata.generation
# starts to increment
subresources:
status: {}
File renamed without changes.
35 changes: 35 additions & 0 deletions pkg/apis/triggers/v1alpha1/interceptor_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,43 @@ import (
"strings"

"google.golang.org/grpc/codes"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"knative.dev/pkg/apis"
)

// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:openapi-gen=true
// Interceptor describes a interceptor's configuration such as the fields it accepts
// and its deployment address
type Interceptor struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec InterceptorSpec `json:"spec"`
}

type InterceptorSpec struct {
ClientConfig ClientConfig `json:"clientConfig"`
}

// ClientConfig describes how a client can communicate with the Interceptor
type ClientConfig struct {
URL *apis.URL `json:"url,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// InterceptorList contains a list of InterceptorConfigurations.
// We don't use this but it's required for certain codegen features.
type InterceptorList struct {
metav1.TypeMeta `json:",inline"`
// +optional
metav1.ListMeta `json:"metadata,omitempty"`
Items []Interceptor `json:"items"`
}

type InterceptorInterface interface {
// Process executes the given InterceptorRequest. Simply getting a non-nil InterceptorResponse back is not sufficient
// to determine if the interceptor processing was successful. Instead use the InterceptorResponse.Status.Continue to
Expand Down
99 changes: 99 additions & 0 deletions pkg/apis/triggers/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9b78c21

Please sign in to comment.