blob: a245f1e858f486d2618363bc7c5566cfd463e13b [file] [log] [blame]
sslobodrd046be82019-01-16 10:02:22 -05001/*
2Copyright 2017 The Kubernetes Authors.
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16
17package v1alpha1
18
19import (
20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21)
22
23// +genclient
24// +genclient:nonNamespaced
25// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
26
27// InitializerConfiguration describes the configuration of initializers.
28type InitializerConfiguration struct {
29 metav1.TypeMeta `json:",inline"`
30 // Standard object metadata; More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata.
31 // +optional
32 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
33
34 // Initializers is a list of resources and their default initializers
35 // Order-sensitive.
36 // When merging multiple InitializerConfigurations, we sort the initializers
37 // from different InitializerConfigurations by the name of the
38 // InitializerConfigurations; the order of the initializers from the same
39 // InitializerConfiguration is preserved.
40 // +patchMergeKey=name
41 // +patchStrategy=merge
42 // +optional
43 Initializers []Initializer `json:"initializers,omitempty" patchStrategy:"merge" patchMergeKey:"name" protobuf:"bytes,2,rep,name=initializers"`
44}
45
46// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
47
48// InitializerConfigurationList is a list of InitializerConfiguration.
49type InitializerConfigurationList struct {
50 metav1.TypeMeta `json:",inline"`
51 // Standard list metadata.
52 // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds
53 // +optional
54 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
55
56 // List of InitializerConfiguration.
57 Items []InitializerConfiguration `json:"items" protobuf:"bytes,2,rep,name=items"`
58}
59
60// Initializer describes the name and the failure policy of an initializer, and
61// what resources it applies to.
62type Initializer struct {
63 // Name is the identifier of the initializer. It will be added to the
64 // object that needs to be initialized.
65 // Name should be fully qualified, e.g., alwayspullimages.kubernetes.io, where
66 // "alwayspullimages" is the name of the webhook, and kubernetes.io is the name
67 // of the organization.
68 // Required
69 Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
70
71 // Rules describes what resources/subresources the initializer cares about.
72 // The initializer cares about an operation if it matches _any_ Rule.
73 // Rule.Resources must not include subresources.
74 Rules []Rule `json:"rules,omitempty" protobuf:"bytes,2,rep,name=rules"`
75}
76
77// Rule is a tuple of APIGroups, APIVersion, and Resources.It is recommended
78// to make sure that all the tuple expansions are valid.
79type Rule struct {
80 // APIGroups is the API groups the resources belong to. '*' is all groups.
81 // If '*' is present, the length of the slice must be one.
82 // Required.
83 APIGroups []string `json:"apiGroups,omitempty" protobuf:"bytes,1,rep,name=apiGroups"`
84
85 // APIVersions is the API versions the resources belong to. '*' is all versions.
86 // If '*' is present, the length of the slice must be one.
87 // Required.
88 APIVersions []string `json:"apiVersions,omitempty" protobuf:"bytes,2,rep,name=apiVersions"`
89
90 // Resources is a list of resources this rule applies to.
91 //
92 // For example:
93 // 'pods' means pods.
94 // 'pods/log' means the log subresource of pods.
95 // '*' means all resources, but not subresources.
96 // 'pods/*' means all subresources of pods.
97 // '*/scale' means all scale subresources.
98 // '*/*' means all resources and their subresources.
99 //
100 // If wildcard is present, the validation rule will ensure resources do not
101 // overlap with each other.
102 //
103 // Depending on the enclosing object, subresources might not be allowed.
104 // Required.
105 Resources []string `json:"resources,omitempty" protobuf:"bytes,3,rep,name=resources"`
106}