pkg/apis/duck
Francesco Guardiani 192b0c9d6e
Add KReference.Group field and ResolveGroup function (#2127)
* Add Group field and ResolveGroup function

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Remove core special case

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Copyright

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Added validation code

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Fix comment

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Add omitempty

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Moved ResolveGroup code to kref
Made ResolveGroup a util method, more than an instance method

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* New type KReferenceResolver

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>

* Added +optional as suggested

Signed-off-by: Francesco Guardiani <francescoguard@gmail.com>
2021-06-15 02:27:20 -07:00
..
ducktypes Avoid importing apis/duck from apis/duck/<<version>> (#1388) 2020-07-10 17:49:37 -07:00
images Move duck typing document to markdown (#1184) 2020-04-07 07:59:00 -07:00
v1 Add KReference.Group field and ResolveGroup function (#2127) 2021-06-15 02:27:20 -07:00
v1alpha1 update boilerplate date (#2134) 2021-05-28 13:21:29 -07:00
v1beta1 update boilerplate date (#2134) 2021-05-28 13:21:29 -07:00
ABOUT.md Drop master references to knative repos (#2050) 2021-03-11 09:48:26 -08:00
OWNERS Update OWNERS_ALIASES to match autogen in community (#2078) 2021-04-08 07:42:51 -07:00
README.md Spelling (#1797) 2020-10-18 14:22:57 -07:00
cached.go bump to k8s 1.18 (#1428) 2020-09-11 07:54:00 -07:00
cached_test.go Fix a few more occurrences of divisive language (#1902) 2020-11-12 06:41:59 -08:00
const.go add ability to opt-out of bindings (#970) 2020-01-07 08:56:51 -08:00
doc.go Link to the doc on Duck Typing, which I missed adding before. (#105) 2018-09-28 16:33:22 -07:00
enqueue.go bump to k8s 1.18 (#1428) 2020-09-11 07:54:00 -07:00
enqueue_test.go Bump K8s libs to 1.19 (#1986) 2021-01-22 13:17:54 -08:00
interface.go bump to k8s 1.18 (#1428) 2020-09-11 07:54:00 -07:00
patch.go Bump assorted dependencies (#2140) 2021-06-02 02:50:30 -07:00
patch_test.go v2 (#1754) 2020-09-29 13:18:29 -07:00
register.go Fix revive related linting issues (#2131) 2021-05-26 01:10:28 -07:00
scale_test.go Align linters with serving (enables stylecheck and asciicheck) (#1738) 2020-09-23 07:37:40 -07:00
typed.go bump to k8s 1.18 (#1428) 2020-09-11 07:54:00 -07:00
typed_test.go bump k8s to v1.20.7 (#2145) 2021-06-10 06:56:43 -07:00
unstructured.go Implement a base library for implementing "Pod Spec"-able bindings. (#915) 2019-12-02 08:58:34 -08:00
unstructured_test.go Add errorlint and fix all existing issues (#1855) 2020-10-29 01:14:35 -07:00
verify.go Add errorlint and fix all existing issues (#1855) 2020-10-29 01:14:35 -07:00
verify_test.go Spelling (#1797) 2020-10-18 14:22:57 -07:00

README.md

Duck Types

Knative leverages duck-typing to interact with resources inside of Kubernetes without explicit knowledge of the full resource shape. knative/pkg defines three duck types that are used throughout Knative: Addressable, Binding, and Source.

For APIs leveraging ObjectReference, the context of the resource in question identifies the duck-type. To enable the case where no ObjectReference is used, we have labeled the Custom Resource Definition with the duck-type. Those labels are as follows:

Label Duck-Type
duck.knative.dev/addressable=true Addressable
duck.knative.dev/binding=true Binding
duck.knative.dev/source=true Source

Addressable Shape

Addressable is expected to be the following shape:

apiVersion: group/version
kind: Kind
status:
  address:
    url: http://host/path?query

Binding Shape

Binding is expected to be in the following shape:

(with direct subject)

apiVersion: group/version
kind: Kind
spec:
  subject:
    apiVersion: group/version
    kind: SomeKind
    namespace: the-namespace
    name: a-name

(with indirect subject)

apiVersion: group/version
kind: Kind
spec:
  subject:
    apiVersion: group/version
    kind: SomeKind
    namespace: the-namespace
    selector:
      matchLabels:
        key: value

Source Shape

Source is expected to be in the following shape:

(with ref sink)

apiVersion: group/version
kind: Kind
spec:
  sink:
    ref:
      apiVersion: group/version
      kind: AnAddressableKind
      name: a-name
  ceOverrides:
    extensions:
      key: value
status:
  observedGeneration: 1
  conditions:
    - type: Ready
      status: "True"
  sinkUri: http://host

(with uri sink)

apiVersion: group/version
kind: Kind
spec:
  sink:
    uri: http://host/path?query
  ceOverrides:
    extensions:
      key: value
status:
  observedGeneration: 1
  conditions:
    - type: Ready
      status: "True"
  sinkUri: http://host/path?query

(with ref and uri sink)

apiVersion: group/version
kind: Kind
spec:
  sink:
    ref:
      apiVersion: group/version
      kind: AnAddressableKind
      name: a-name
    uri: /path?query
  ceOverrides:
    extensions:
      key: value
status:
  observedGeneration: 1
  conditions:
    - type: Ready
      status: "True"
  sinkUri: http://host/path?query