-
Notifications
You must be signed in to change notification settings - Fork 617
MON: rename remote write SafeAuthorization to Authorization #2901
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1552,7 +1552,7 @@ type RemoteWriteSpec struct { | |
| Name string `json:"name,omitempty"` | ||
| // authorization defines the authorization method for the remote write endpoint. | ||
| // When omitted, no authorization is performed. | ||
| // When set, type must be one of BearerToken, BasicAuth, OAuth2, SigV4, SafeAuthorization, or ServiceAccount; the corresponding nested config must be set (ServiceAccount has no config). | ||
| // When set, type must be one of Authorization, BasicAuth, OAuth2, SigV4, or ServiceAccount; the corresponding nested config must be set (ServiceAccount has no config). | ||
| // +optional | ||
| AuthorizationConfig RemoteWriteAuthorization `json:"authorization,omitzero"` | ||
| // headers specifies the custom HTTP headers to be sent along with each remote write request. | ||
|
|
@@ -1654,62 +1654,53 @@ type BasicAuth struct { | |
| } | ||
|
|
||
| // RemoteWriteAuthorizationType defines the authorization method for remote write endpoints. | ||
| // +kubebuilder:validation:Enum=BearerToken;BasicAuth;OAuth2;SigV4;SafeAuthorization;ServiceAccount | ||
| // +kubebuilder:validation:Enum=Authorization;BasicAuth;OAuth2;SigV4;ServiceAccount | ||
| type RemoteWriteAuthorizationType string | ||
|
|
||
| const ( | ||
| // RemoteWriteAuthorizationTypeBearerToken indicates bearer token from a secret. | ||
| RemoteWriteAuthorizationTypeBearerToken RemoteWriteAuthorizationType = "BearerToken" | ||
| // RemoteWriteAuthorizationTypeAuthorization indicates authorization credentials from a secret. | ||
| // The secret key contains the credentials (e.g. a Bearer token). Use the credentials field. | ||
| RemoteWriteAuthorizationTypeAuthorization RemoteWriteAuthorizationType = "Authorization" | ||
| // RemoteWriteAuthorizationTypeBasicAuth indicates HTTP basic authentication. | ||
| RemoteWriteAuthorizationTypeBasicAuth RemoteWriteAuthorizationType = "BasicAuth" | ||
| // RemoteWriteAuthorizationTypeOAuth2 indicates OAuth2 client credentials. | ||
| RemoteWriteAuthorizationTypeOAuth2 RemoteWriteAuthorizationType = "OAuth2" | ||
| // RemoteWriteAuthorizationTypeSigV4 indicates AWS Signature Version 4. | ||
| RemoteWriteAuthorizationTypeSigV4 RemoteWriteAuthorizationType = "SigV4" | ||
| // RemoteWriteAuthorizationTypeSafeAuthorization indicates authorization from a secret (Prometheus SafeAuthorization pattern). | ||
| // The secret key contains the credentials (e.g. a Bearer token). Use the safeAuthorization field. | ||
| RemoteWriteAuthorizationTypeSafeAuthorization RemoteWriteAuthorizationType = "SafeAuthorization" | ||
| // RemoteWriteAuthorizationTypeServiceAccount indicates use of the pod's service account token for machine identity. | ||
| // No additional field is required; the operator configures the token path. | ||
| RemoteWriteAuthorizationTypeServiceAccount RemoteWriteAuthorizationType = "ServiceAccount" | ||
| ) | ||
|
|
||
| // RemoteWriteAuthorization defines the authorization method for a remote write endpoint. | ||
| // Exactly one of the nested configs must be set according to the type discriminator. | ||
| // +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'BearerToken' ? has(self.bearerToken) : !has(self.bearerToken)",message="bearerToken is required when type is BearerToken, and forbidden otherwise" | ||
| // +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'Authorization' ? has(self.credentials) : !has(self.credentials)",message="credentials is required when type is Authorization, and forbidden otherwise" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| // +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'BasicAuth' ? has(self.basicAuth) : !has(self.basicAuth)",message="basicAuth is required when type is BasicAuth, and forbidden otherwise" | ||
| // +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'OAuth2' ? has(self.oauth2) : !has(self.oauth2)",message="oauth2 is required when type is OAuth2, and forbidden otherwise" | ||
| // +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'SigV4' ? has(self.sigv4) : !has(self.sigv4)",message="sigv4 is required when type is SigV4, and forbidden otherwise" | ||
| // +kubebuilder:validation:XValidation:rule="has(self.type) && self.type == 'SafeAuthorization' ? has(self.safeAuthorization) : !has(self.safeAuthorization)",message="safeAuthorization is required when type is SafeAuthorization, and forbidden otherwise" | ||
| // +union | ||
| type RemoteWriteAuthorization struct { | ||
| // type specifies the authorization method to use. | ||
| // Allowed values are BearerToken, BasicAuth, OAuth2, SigV4, SafeAuthorization, ServiceAccount. | ||
| // Allowed values are Authorization, BasicAuth, OAuth2, SigV4, ServiceAccount. | ||
| // | ||
| // When set to BearerToken, the bearer token is read from a Secret referenced by the bearerToken field. | ||
| // When set to Authorization, credentials are read from a single Secret key. The secret key typically contains a Bearer token. Use the credentials field. | ||
| // | ||
| // When set to BasicAuth, HTTP basic authentication is used; the basicAuth field (username and password from Secrets) must be set. | ||
| // | ||
| // When set to OAuth2, OAuth2 client credentials flow is used; the oauth2 field (clientId, clientSecret, tokenUrl) must be set. | ||
| // | ||
| // When set to SigV4, AWS Signature Version 4 is used for authentication; the sigv4 field must be set. | ||
| // | ||
| // When set to SafeAuthorization, credentials are read from a single Secret key (Prometheus SafeAuthorization pattern). The secret key typically contains a Bearer token. Use the safeAuthorization field. | ||
| // | ||
| // When set to ServiceAccount, the pod's service account token is used for machine identity. No additional field is required; the operator configures the token path. | ||
| // +unionDiscriminator | ||
| // +required | ||
| Type RemoteWriteAuthorizationType `json:"type,omitempty"` | ||
| // safeAuthorization defines the secret reference containing the credentials for authentication (e.g. Bearer token). | ||
| // Required when type is "SafeAuthorization", and forbidden otherwise. Maps to Prometheus SafeAuthorization. The secret must exist in the openshift-monitoring namespace. | ||
| // +unionMember | ||
| // +optional | ||
| SafeAuthorization *v1.SecretKeySelector `json:"safeAuthorization,omitempty"` | ||
| // bearerToken defines the secret reference containing the bearer token. | ||
| // Required when type is "BearerToken", and forbidden otherwise. | ||
| // +unionMember | ||
| // credentials defines the secret reference containing the authorization credentials (e.g. Bearer token). | ||
| // Required when type is "Authorization", and forbidden otherwise. | ||
| // The secret must exist in the openshift-monitoring namespace. | ||
| // +unionMember=Authorization | ||
| // +optional | ||
| BearerToken SecretKeySelector `json:"bearerToken,omitempty,omitzero"` | ||
|
Comment on lines
-1703
to
-1712
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The removed fields must be tombstoned so we never add them back in the future for this api version. |
||
| Credentials SecretKeySelector `json:"credentials,omitempty,omitzero"` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following discriminated union patterns, this field name would need to be |
||
| // basicAuth defines HTTP basic authentication credentials. | ||
| // Required when type is "BasicAuth", and forbidden otherwise. | ||
| // +unionMember | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removed constants need to be tombstoned so we do not add these options back as valid options in the future.