Skip to content

Commit bc5f742

Browse files
committed
Upgrade ClusterImagePolicy and ImagePolicy to v1
Upgrade ClusterImagePolicy and ImagePolicy under SigstoreVerification featuregate to v1. will workon upgrade controller code to use v1 API and promote the featuregate to default as next step. Signed-off-by: Qi Wang <[email protected]>
1 parent 7152b1b commit bc5f742

18 files changed

+6291
-42
lines changed
+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package v1
2+
3+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4+
5+
// +genclient
6+
// +genclient:nonNamespaced
7+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
8+
9+
// ClusterImagePolicy holds cluster-wide configuration for image signature verification
10+
//
11+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
12+
// +kubebuilder:object:root=true
13+
// +kubebuilder:resource:path=clusterimagepolicies,scope=Cluster
14+
// +kubebuilder:subresource:status
15+
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2310
16+
// +openshift:file-pattern=cvoRunLevel=0000_10,operatorName=config-operator,operatorOrdering=01
17+
// +openshift:enable:FeatureGate=SigstoreImageVerification
18+
// +openshift:compatibility-gen:level=1
19+
type ClusterImagePolicy struct {
20+
metav1.TypeMeta `json:",inline"`
21+
22+
// metadata is the standard object's metadata.
23+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
24+
metav1.ObjectMeta `json:"metadata,omitempty"`
25+
26+
// spec contains the configuration for the cluster image policy.
27+
// +required
28+
Spec ClusterImagePolicySpec `json:"spec"`
29+
// status contains the observed state of the resource.
30+
// +optional
31+
Status ClusterImagePolicyStatus `json:"status,omitempty"`
32+
}
33+
34+
// CLusterImagePolicySpec is the specification of the ClusterImagePolicy custom resource.
35+
type ClusterImagePolicySpec struct {
36+
// scopes defines the list of image identities assigned to a policy. Each item refers to a scope in a registry implementing the "Docker Registry HTTP API V2".
37+
// Scopes matching individual images are named Docker references in the fully expanded form, either using a tag or digest. For example, docker.io/library/busybox:latest (not busybox:latest).
38+
// More general scopes are prefixes of individual-image scopes, and specify a repository (by omitting the tag or digest), a repository
39+
// namespace, or a registry host (by only specifying the host name and possibly a port number) or a wildcard expression starting with `*.`, for matching all subdomains (not including a port number).
40+
// Wildcards are only supported for subdomain matching, and may not be used in the middle of the host, i.e. *.example.com is a valid case, but example*.*.com is not.
41+
// If multiple scopes match a given image, only the policy requirements for the most specific scope apply. The policy requirements for more general scopes are ignored.
42+
// In addition to setting a policy appropriate for your own deployed applications, make sure that a policy on the OpenShift image repositories
43+
// quay.io/openshift-release-dev/ocp-release, quay.io/openshift-release-dev/ocp-v4.0-art-dev (or on a more general scope) allows deployment of the OpenShift images required for cluster operation.
44+
// If a scope is configured in both the ClusterImagePolicy and the ImagePolicy, or if the scope in ImagePolicy is nested under one of the scopes from the ClusterImagePolicy, only the policy from the ClusterImagePolicy will be applied.
45+
// For additional details about the format, please refer to the document explaining the docker transport field,
46+
// which can be found at: https://github.com/containers/image/blob/main/docs/containers-policy.json.5.md#docker
47+
// +required
48+
// +kubebuilder:validation:MaxItems=256
49+
// +listType=set
50+
Scopes []ImageScope `json:"scopes"`
51+
// policy contains configuration to allow scopes to be verified, and defines how
52+
// images not matching the verification policy will be treated.
53+
// +required
54+
Policy Policy `json:"policy"`
55+
}
56+
57+
// +k8s:deepcopy-gen=true
58+
type ClusterImagePolicyStatus struct {
59+
// conditions provide details on the status of this API Resource.
60+
// +listType=map
61+
// +listMapKey=type
62+
// +optional
63+
Conditions []metav1.Condition `json:"conditions,omitempty"`
64+
}
65+
66+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
67+
68+
// ClusterImagePolicyList is a list of ClusterImagePolicy resources
69+
//
70+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
71+
// +openshift:compatibility-gen:level=1
72+
type ClusterImagePolicyList struct {
73+
metav1.TypeMeta `json:",inline"`
74+
75+
// metadata is the standard list's metadata.
76+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
77+
metav1.ListMeta `json:"metadata"`
78+
79+
Items []ClusterImagePolicy `json:"items"`
80+
}

0 commit comments

Comments
 (0)