Skip to content

Commit 5dbd297

Browse files
authored
feat: Add authentication and gatewayconfig resource (#2564)
* support token creation for service account * updated doc strings etc. * address review comments * feat: Add authentication and gatewayconfig resource * Address tox failure
1 parent fdf878f commit 5dbd297

5 files changed

Lines changed: 254 additions & 1 deletion

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.33.2
1+
v1.33.5
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import Resource
6+
7+
8+
class Authentication(Resource):
9+
"""
10+
Authentication specifies cluster-wide settings for authentication (like OAuth and
11+
webhook token authenticators). The canonical name of an instance is `cluster`.
12+
13+
Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
14+
"""
15+
16+
api_group: str = Resource.ApiGroup.CONFIG_OPENSHIFT_IO
17+
18+
def __init__(
19+
self,
20+
oauth_metadata: dict[str, Any] | None = None,
21+
oidc_providers: list[Any] | None = None,
22+
service_account_issuer: str | None = None,
23+
type: str | None = None,
24+
webhook_token_authenticator: dict[str, Any] | None = None,
25+
webhook_token_authenticators: list[Any] | None = None,
26+
**kwargs: Any,
27+
) -> None:
28+
r"""
29+
Args:
30+
oauth_metadata (dict[str, Any]): oauthMetadata contains the discovery endpoint data for OAuth 2.0
31+
Authorization Server Metadata for an external OAuth server. This
32+
discovery document can be viewed from its served location: oc get
33+
--raw '/.well-known/oauth-authorization-server' For further
34+
details, see the IETF Draft: https://tools.ietf.org/html/draft-
35+
ietf-oauth-discovery-04#section-2 If oauthMetadata.name is non-
36+
empty, this value has precedence over any metadata reference
37+
stored in status. The key "oauthMetadata" is used to locate the
38+
data. If specified and the config map or expected key is not
39+
found, no metadata is served. If the specified metadata is not
40+
valid, no metadata is served. The namespace for this config map is
41+
openshift-config.
42+
43+
oidc_providers (list[Any]): oidcProviders are OIDC identity providers that can issue tokens for
44+
this cluster Can only be set if "Type" is set to "OIDC". At most
45+
one provider can be configured.
46+
47+
service_account_issuer (str): serviceAccountIssuer is the identifier of the bound service account
48+
token issuer. The default is https://kubernetes.default.svc
49+
WARNING: Updating this field will not result in immediate
50+
invalidation of all bound tokens with the previous issuer value.
51+
Instead, the tokens issued by previous service account issuer will
52+
continue to be trusted for a time period chosen by the platform
53+
(currently set to 24h). This time period is subject to change over
54+
time. This allows internal components to transition to use new
55+
service account issuer without service distruption.
56+
57+
type (str): type identifies the cluster managed, user facing authentication mode
58+
in use. Specifically, it manages the component that responds to
59+
login attempts. The default is IntegratedOAuth.
60+
61+
webhook_token_authenticator (dict[str, Any]): webhookTokenAuthenticator configures a remote token reviewer. These
62+
remote authentication webhooks can be used to verify bearer tokens
63+
via the tokenreviews.authentication.k8s.io REST API. This is
64+
required to honor bearer tokens that are provisioned by an
65+
external authentication service. Can only be set if "Type" is set
66+
to "None".
67+
68+
webhook_token_authenticators (list[Any]): webhookTokenAuthenticators is DEPRECATED, setting it has no effect.
69+
70+
"""
71+
super().__init__(**kwargs)
72+
73+
self.oauth_metadata = oauth_metadata
74+
self.oidc_providers = oidc_providers
75+
self.service_account_issuer = service_account_issuer
76+
self.type = type
77+
self.webhook_token_authenticator = webhook_token_authenticator
78+
self.webhook_token_authenticators = webhook_token_authenticators
79+
80+
def to_dict(self) -> None:
81+
super().to_dict()
82+
83+
if not self.kind_dict and not self.yaml_file:
84+
self.res["spec"] = {}
85+
_spec = self.res["spec"]
86+
87+
if self.oauth_metadata is not None:
88+
_spec["oauthMetadata"] = self.oauth_metadata
89+
90+
if self.oidc_providers is not None:
91+
_spec["oidcProviders"] = self.oidc_providers
92+
93+
if self.service_account_issuer is not None:
94+
_spec["serviceAccountIssuer"] = self.service_account_issuer
95+
96+
if self.type is not None:
97+
_spec["type"] = self.type
98+
99+
if self.webhook_token_authenticator is not None:
100+
_spec["webhookTokenAuthenticator"] = self.webhook_token_authenticator
101+
102+
if self.webhook_token_authenticators is not None:
103+
_spec["webhookTokenAuthenticators"] = self.webhook_token_authenticators
104+
105+
# End of generated code
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import Resource
6+
7+
8+
class Authentication(Resource):
9+
"""
10+
Authentication provides information to configure an operator to manage authentication.
11+
12+
Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
13+
"""
14+
15+
api_group: str = Resource.ApiGroup.OPERATOR_OPENSHIFT_IO
16+
17+
def __init__(
18+
self,
19+
log_level: str | None = None,
20+
management_state: str | None = None,
21+
observed_config: dict[str, Any] | None = None,
22+
operator_log_level: str | None = None,
23+
unsupported_config_overrides: dict[str, Any] | None = None,
24+
**kwargs: Any,
25+
) -> None:
26+
r"""
27+
Args:
28+
log_level (str): logLevel is an intent based logging for an overall component. It does
29+
not give fine grained control, but it is a simple way to manage
30+
coarse grained logging choices that operators have to interpret
31+
for their operands. Valid values are: "Normal", "Debug", "Trace",
32+
"TraceAll". Defaults to "Normal".
33+
34+
management_state (str): managementState indicates whether and how the operator should manage
35+
the component
36+
37+
observed_config (dict[str, Any]): observedConfig holds a sparse config that controller has observed from
38+
the cluster state. It exists in spec because it is an input to
39+
the level for the operator
40+
41+
operator_log_level (str): operatorLogLevel is an intent based logging for the operator itself.
42+
It does not give fine grained control, but it is a simple way to
43+
manage coarse grained logging choices that operators have to
44+
interpret for themselves. Valid values are: "Normal", "Debug",
45+
"Trace", "TraceAll". Defaults to "Normal".
46+
47+
unsupported_config_overrides (dict[str, Any]): unsupportedConfigOverrides overrides the final configuration that was
48+
computed by the operator. Red Hat does not support the use of this
49+
field. Misuse of this field could lead to unexpected behavior or
50+
conflict with other configuration options. Seek guidance from the
51+
Red Hat support before using this field. Use of this property
52+
blocks cluster upgrades, it must be removed before upgrading your
53+
cluster.
54+
55+
"""
56+
super().__init__(**kwargs)
57+
58+
self.log_level = log_level
59+
self.management_state = management_state
60+
self.observed_config = observed_config
61+
self.operator_log_level = operator_log_level
62+
self.unsupported_config_overrides = unsupported_config_overrides
63+
64+
def to_dict(self) -> None:
65+
super().to_dict()
66+
67+
if not self.kind_dict and not self.yaml_file:
68+
self.res["spec"] = {}
69+
_spec = self.res["spec"]
70+
71+
if self.log_level is not None:
72+
_spec["logLevel"] = self.log_level
73+
74+
if self.management_state is not None:
75+
_spec["managementState"] = self.management_state
76+
77+
if self.observed_config is not None:
78+
_spec["observedConfig"] = self.observed_config
79+
80+
if self.operator_log_level is not None:
81+
_spec["operatorLogLevel"] = self.operator_log_level
82+
83+
if self.unsupported_config_overrides is not None:
84+
_spec["unsupportedConfigOverrides"] = self.unsupported_config_overrides
85+
86+
# End of generated code

ocp_resources/gateway_config.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Generated using https://github.com/RedHatQE/openshift-python-wrapper/blob/main/scripts/resource/README.md
2+
3+
4+
from typing import Any
5+
from ocp_resources.resource import Resource
6+
7+
8+
class GatewayConfig(Resource):
9+
"""
10+
GatewayConfig is the Schema for the gatewayconfigs API
11+
"""
12+
13+
api_group: str = Resource.ApiGroup.SERVICES_PLATFORM_OPENDATAHUB_IO
14+
15+
def __init__(
16+
self,
17+
certificate: dict[str, Any] | None = None,
18+
cookie: dict[str, Any] | None = None,
19+
domain: str | None = None,
20+
oidc: dict[str, Any] | None = None,
21+
**kwargs: Any,
22+
) -> None:
23+
r"""
24+
Args:
25+
certificate (dict[str, Any]): Certificate management
26+
27+
cookie (dict[str, Any]): Cookie configuration for OAuth2 proxy (applies to both OIDC and
28+
OpenShift OAuth)
29+
30+
domain (str): Domain configuration for the GatewayConfig Example: apps.example.com
31+
32+
oidc (dict[str, Any]): OIDC configuration (used when cluster is in OIDC authentication mode)
33+
34+
"""
35+
super().__init__(**kwargs)
36+
37+
self.certificate = certificate
38+
self.cookie = cookie
39+
self.domain = domain
40+
self.oidc = oidc
41+
42+
def to_dict(self) -> None:
43+
super().to_dict()
44+
45+
if not self.kind_dict and not self.yaml_file:
46+
self.res["spec"] = {}
47+
_spec = self.res["spec"]
48+
49+
if self.certificate is not None:
50+
_spec["certificate"] = self.certificate
51+
52+
if self.cookie is not None:
53+
_spec["cookie"] = self.cookie
54+
55+
if self.domain is not None:
56+
_spec["domain"] = self.domain
57+
58+
if self.oidc is not None:
59+
_spec["oidc"] = self.oidc
60+
61+
# End of generated code

ocp_resources/resource.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ class ApiGroup:
556556
SECURITY_ISTIO_IO: str = "security.istio.io"
557557
SECURITY_OPENSHIFT_IO: str = "security.openshift.io"
558558
SELF_NODE_REMEDIATION_MEDIK8S_IO: str = "self-node-remediation.medik8s.io"
559+
SERVICES_PLATFORM_OPENDATAHUB_IO: str = "services.platform.opendatahub.io"
559560
SERVING_KNATIVE_DEV: str = "serving.knative.dev"
560561
SERVING_KSERVE_IO: str = "serving.kserve.io"
561562
SNAPSHOT_KUBEVIRT_IO: str = "snapshot.kubevirt.io"

0 commit comments

Comments
 (0)