|
| 1 | +/* |
| 2 | +Copyright The ORC Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package v1alpha1 |
| 18 | + |
| 19 | +import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 20 | + |
| 21 | +// +kubebuilder:validation:Enum:=CONNECT;DELETE;GET;HEAD;OPTIONS;PATCH;POST;PUT;TRACE |
| 22 | +type HTTPMethod string |
| 23 | + |
| 24 | +const ( |
| 25 | + HTTPMethodCONNECT HTTPMethod = "CONNECT" |
| 26 | + HTTPMethodDELETE HTTPMethod = "DELETE" |
| 27 | + HTTPMethodGET HTTPMethod = "GET" |
| 28 | + HTTPMethodHEAD HTTPMethod = "HEAD" |
| 29 | + HTTPMethodOPTIONS HTTPMethod = "OPTIONS" |
| 30 | + HTTPMethodPATCH HTTPMethod = "PATCH" |
| 31 | + HTTPMethodPOST HTTPMethod = "POST" |
| 32 | + HTTPMethodPUT HTTPMethod = "PUT" |
| 33 | + HTTPMethodTRACE HTTPMethod = "TRACE" |
| 34 | +) |
| 35 | + |
| 36 | +// ApplicationCredentialAccessRule defines an access rule |
| 37 | +// +kubebuilder:validation:MinProperties:=1 |
| 38 | +type ApplicationCredentialAccessRule struct { |
| 39 | + // path that the application credential is permitted to access |
| 40 | + // +kubebuilder:validation:MaxLength=1024 |
| 41 | + // +optional |
| 42 | + Path *string `json:"path,omitempty"` |
| 43 | + |
| 44 | + // method that the application credential is permitted to use for a given API endpoint |
| 45 | + // +optional |
| 46 | + Method *HTTPMethod `json:"method,omitempty"` |
| 47 | + |
| 48 | + // serviceRef identifier for the service that the application credential is permitted to access |
| 49 | + // +optional |
| 50 | + ServiceRef *KubernetesNameRef `json:"serviceRef,omitempty"` |
| 51 | +} |
| 52 | + |
| 53 | +// ApplicationCredentialResourceSpec contains the desired state of the resource. |
| 54 | +// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ApplicationCredentialResourceSpec is immutable" |
| 55 | +type ApplicationCredentialResourceSpec struct { |
| 56 | + // name will be the name of the created resource. If not specified, the |
| 57 | + // name of the ORC object will be used. |
| 58 | + // +optional |
| 59 | + Name *OpenStackName `json:"name,omitempty"` |
| 60 | + |
| 61 | + // description is a human-readable description for the resource. |
| 62 | + // +kubebuilder:validation:MinLength:=1 |
| 63 | + // +kubebuilder:validation:MaxLength:=255 |
| 64 | + // +optional |
| 65 | + Description *string `json:"description,omitempty"` |
| 66 | + |
| 67 | + // userRef is a reference to the ORC User which this resource is associated with. |
| 68 | + // Note: Due to the nature of the OpenStack API, managing application credentials for a user different than the one ORC is authenticated against can be computationally expensive. In the worst case, all application credentials of all users have to be queried. |
| 69 | + // +required |
| 70 | + UserRef KubernetesNameRef `json:"userRef,omitempty"` |
| 71 | + |
| 72 | + // unrestricted is a flag indicating whether the application credential may be used for creation or destruction of other application credentials or trusts |
| 73 | + // +optional |
| 74 | + Unrestricted *bool `json:"unrestricted,omitempty"` |
| 75 | + |
| 76 | + // secretRef is a reference to a Secret containing the application credential secret |
| 77 | + // +required |
| 78 | + SecretRef KubernetesNameRef `json:"secretRef,omitempty"` |
| 79 | + |
| 80 | + // roleRefs may only contain roles that the user has assigned on the project. If not provided, the roles assigned to the application credential will be the same as the roles in the current token. |
| 81 | + // +kubebuilder:validation:MaxItems:=256 |
| 82 | + // +listType=atomic |
| 83 | + // +optional |
| 84 | + RoleRefs []KubernetesNameRef `json:"roleRefs,omitempty"` |
| 85 | + |
| 86 | + // accessRules is a list of fine grained access control rules |
| 87 | + // +kubebuilder:validation:MaxItems:=256 |
| 88 | + // +listType=atomic |
| 89 | + // +optional |
| 90 | + AccessRules []ApplicationCredentialAccessRule `json:"accessRules,omitempty"` |
| 91 | + |
| 92 | + // expiresAt is the time of expiration for the application credential. If unset, the application credential does not expire. |
| 93 | + // +optional |
| 94 | + ExpiresAt *metav1.Time `json:"expiresAt,omitempty"` |
| 95 | +} |
| 96 | + |
| 97 | +// ApplicationCredentialFilter defines an existing resource by its properties |
| 98 | +// +kubebuilder:validation:MinProperties:=2 |
| 99 | +type ApplicationCredentialFilter struct { |
| 100 | + // userRef is a reference to the ORC User which this resource is associated with. |
| 101 | + // Note: Due to the nature of the OpenStack API, managing application credentials for a user different than the one ORC is authenticated against can be computationally expensive. In the worst case, all application credentials of all users have to be queried. |
| 102 | + // +required |
| 103 | + UserRef KubernetesNameRef `json:"userRef,omitempty"` |
| 104 | + |
| 105 | + // name of the existing resource |
| 106 | + // +optional |
| 107 | + Name *OpenStackName `json:"name,omitempty"` |
| 108 | + |
| 109 | + // description of the existing resource |
| 110 | + // +kubebuilder:validation:MaxLength:=1024 |
| 111 | + // +optional |
| 112 | + Description *string `json:"description,omitempty"` |
| 113 | +} |
| 114 | + |
| 115 | +type ApplicationCredentialRoleStatus struct { |
| 116 | + // name of an existing role |
| 117 | + // +kubebuilder:validation:MaxLength:=1024 |
| 118 | + // +optional |
| 119 | + Name *string `json:"name,omitempty"` |
| 120 | + |
| 121 | + // id is the ID of a role |
| 122 | + // +kubebuilder:validation:MaxLength:=1024 |
| 123 | + // +optional |
| 124 | + ID *string `json:"id,omitempty"` |
| 125 | + |
| 126 | + // domainID of the domain of this role |
| 127 | + // +kubebuilder:validation:MaxLength:=1024 |
| 128 | + // +optional |
| 129 | + DomainID *string `json:"domainID,omitempty"` |
| 130 | +} |
| 131 | + |
| 132 | +type ApplicationCredentialAccessRuleStatus struct { |
| 133 | + // id is the ID of this access rule |
| 134 | + // +kubebuilder:validation:MaxLength:=1024 |
| 135 | + // +optional |
| 136 | + ID *string `json:"id,omitempty"` |
| 137 | + |
| 138 | + // path that the application credential is permitted to access |
| 139 | + // +kubebuilder:validation:MaxLength:=1024 |
| 140 | + // +optional |
| 141 | + Path *string `json:"path,omitempty"` |
| 142 | + |
| 143 | + // method that the application credential is permitted to use for a given API endpoint |
| 144 | + // +kubebuilder:validation:MaxLength=32 |
| 145 | + // +optional |
| 146 | + Method *string `json:"method,omitempty"` |
| 147 | + |
| 148 | + // service type identifier for the service that the application credential is permitted to access |
| 149 | + // +kubebuilder:validation:MaxLength:=1024 |
| 150 | + // +optional |
| 151 | + Service *string `json:"service,omitempty"` |
| 152 | +} |
| 153 | + |
| 154 | +// ApplicationCredentialResourceStatus represents the observed state of the resource. |
| 155 | +type ApplicationCredentialResourceStatus struct { |
| 156 | + // name is a Human-readable name for the resource. Might not be unique. |
| 157 | + // +kubebuilder:validation:MaxLength=1024 |
| 158 | + // +optional |
| 159 | + Name string `json:"name,omitempty"` |
| 160 | + |
| 161 | + // description is a human-readable description for the resource. |
| 162 | + // +kubebuilder:validation:MaxLength=1024 |
| 163 | + // +optional |
| 164 | + Description string `json:"description,omitempty"` |
| 165 | + |
| 166 | + // unrestricted is a flag indicating whether the application credential may be used for creation or destruction of other application credentials or trusts |
| 167 | + // +optional |
| 168 | + Unrestricted bool `json:"unrestricted,omitempty"` |
| 169 | + |
| 170 | + // projectID of the project the application credential was created for and that authentication requests using this application credential will be scoped to. |
| 171 | + // +kubebuilder:validation:MaxLength=1024 |
| 172 | + // +optional |
| 173 | + ProjectID string `json:"projectID,omitempty"` |
| 174 | + |
| 175 | + // roles is a list of role objects may only contain roles that the user has assigned on the project |
| 176 | + // +kubebuilder:validation:MaxItems:=64 |
| 177 | + // +listType=atomic |
| 178 | + // +optional |
| 179 | + Roles []ApplicationCredentialRoleStatus `json:"roles"` |
| 180 | + |
| 181 | + // expiresAt is the time of expiration for the application credential. If unset, the application credential does not expire. |
| 182 | + // +optional |
| 183 | + ExpiresAt *metav1.Time `json:"expiresAt"` |
| 184 | + |
| 185 | + // accessRules is a list of fine grained access control rules |
| 186 | + // +kubebuilder:validation:MaxItems:=64 |
| 187 | + // +listType=atomic |
| 188 | + // +optional |
| 189 | + AccessRules []ApplicationCredentialAccessRuleStatus `json:"accessRules,omitempty"` |
| 190 | +} |
0 commit comments