mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-09 23:40:05 +00:00
Fix External Account Json Schema Issue (#15671)
This commit is contained in:
parent
039d66390b
commit
00677a1e1b
@ -26,7 +26,7 @@ from metadata.generated.schema.security.credentials.gcpCredentials import (
|
|||||||
GcpCredentialsPath,
|
GcpCredentialsPath,
|
||||||
)
|
)
|
||||||
from metadata.generated.schema.security.credentials.gcpExternalAccount import (
|
from metadata.generated.schema.security.credentials.gcpExternalAccount import (
|
||||||
GcpCredentialsValuesExternalAccount,
|
GcpExternalAccount,
|
||||||
)
|
)
|
||||||
from metadata.generated.schema.security.credentials.gcpValues import (
|
from metadata.generated.schema.security.credentials.gcpValues import (
|
||||||
GcpCredentialsValues,
|
GcpCredentialsValues,
|
||||||
@ -89,7 +89,7 @@ def create_credential_tmp_file(credentials: dict) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def build_google_credentials_dict(
|
def build_google_credentials_dict(
|
||||||
gcp_values: Union[GcpCredentialsValues, GcpCredentialsValuesExternalAccount]
|
gcp_values: Union[GcpCredentialsValues, GcpExternalAccount]
|
||||||
) -> Dict[str, str]:
|
) -> Dict[str, str]:
|
||||||
"""
|
"""
|
||||||
Given GcPCredentialsValues, build a dictionary as the JSON file
|
Given GcPCredentialsValues, build a dictionary as the JSON file
|
||||||
@ -97,7 +97,7 @@ def build_google_credentials_dict(
|
|||||||
:param gcp_values: GCP credentials
|
:param gcp_values: GCP credentials
|
||||||
:return: Dictionary with credentials
|
:return: Dictionary with credentials
|
||||||
"""
|
"""
|
||||||
if gcp_values.type == "service_account":
|
if isinstance(gcp_values, GcpCredentialsValues):
|
||||||
private_key_str = gcp_values.privateKey.get_secret_value()
|
private_key_str = gcp_values.privateKey.get_secret_value()
|
||||||
# adding the replace string here to escape line break if passed from env
|
# adding the replace string here to escape line break if passed from env
|
||||||
private_key_str = private_key_str.replace("\\n", "\n")
|
private_key_str = private_key_str.replace("\\n", "\n")
|
||||||
@ -115,17 +115,16 @@ def build_google_credentials_dict(
|
|||||||
"auth_provider_x509_cert_url": str(gcp_values.authProviderX509CertUrl),
|
"auth_provider_x509_cert_url": str(gcp_values.authProviderX509CertUrl),
|
||||||
"client_x509_cert_url": str(gcp_values.clientX509CertUrl),
|
"client_x509_cert_url": str(gcp_values.clientX509CertUrl),
|
||||||
}
|
}
|
||||||
if gcp_values.type == "external_account":
|
if isinstance(gcp_values, GcpExternalAccount):
|
||||||
return {
|
return {
|
||||||
"type": gcp_values.type,
|
"type": gcp_values.externalType,
|
||||||
"audience": gcp_values.audience,
|
"audience": gcp_values.audience,
|
||||||
"subject_token_type": gcp_values.subjectTokenType,
|
"subject_token_type": gcp_values.subjectTokenType,
|
||||||
"token_url": gcp_values.tokenURL,
|
"token_url": gcp_values.tokenURL,
|
||||||
"credential_source": gcp_values.credentialSource,
|
"credential_source": gcp_values.credentialSource,
|
||||||
}
|
}
|
||||||
|
|
||||||
raise InvalidGcpConfigException(
|
raise InvalidGcpConfigException(
|
||||||
f"Error not support credential type {gcp_values.type}"
|
f"Error trying to build GCP credentials dict due to Invalid GCP config {type(gcp_values)}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ from unittest import TestCase
|
|||||||
from pydantic import SecretStr
|
from pydantic import SecretStr
|
||||||
|
|
||||||
from metadata.generated.schema.security.credentials.gcpExternalAccount import (
|
from metadata.generated.schema.security.credentials.gcpExternalAccount import (
|
||||||
GcpCredentialsValuesExternalAccount,
|
GcpExternalAccount,
|
||||||
)
|
)
|
||||||
from metadata.generated.schema.security.credentials.gcpValues import (
|
from metadata.generated.schema.security.credentials.gcpValues import (
|
||||||
GcpCredentialsValues,
|
GcpCredentialsValues,
|
||||||
@ -90,8 +90,8 @@ VEhPQF0i0tUU7Fl071hcYaiQoZx4nIjN+NG6p5QKbl6k
|
|||||||
"""
|
"""
|
||||||
Check how we can validate GCS values
|
Check how we can validate GCS values
|
||||||
"""
|
"""
|
||||||
gcp_values = GcpCredentialsValuesExternalAccount(
|
gcp_values = GcpExternalAccount(
|
||||||
type="external_account",
|
externalType="external_account",
|
||||||
audience="audience",
|
audience="audience",
|
||||||
subjectTokenType="subject_token_type",
|
subjectTokenType="subject_token_type",
|
||||||
tokenURL="token_url",
|
tokenURL="token_url",
|
||||||
@ -106,6 +106,4 @@ VEhPQF0i0tUU7Fl071hcYaiQoZx4nIjN+NG6p5QKbl6k
|
|||||||
"credential_source": {"environmentId": "environment_id"},
|
"credential_source": {"environmentId": "environment_id"},
|
||||||
}
|
}
|
||||||
|
|
||||||
build_google_credentials_dict(gcp_values)
|
|
||||||
|
|
||||||
self.assertEqual(expected_dict, build_google_credentials_dict(gcp_values))
|
self.assertEqual(expected_dict, build_google_credentials_dict(gcp_values))
|
||||||
|
|||||||
@ -3,11 +3,10 @@
|
|||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"javaType": "org.openmetadata.schema.security.credentials.GCPExternalAccount",
|
"javaType": "org.openmetadata.schema.security.credentials.GCPExternalAccount",
|
||||||
"title": "GCP Credentials Values ( External Account )",
|
"title": "GCP External Account",
|
||||||
"description": "Pass the raw credential values provided by GCP",
|
"description": "Pass the raw credential values provided by GCP",
|
||||||
"definitions": {},
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"type": {
|
"externalType": {
|
||||||
"title": "Credentials Type",
|
"title": "Credentials Type",
|
||||||
"description": "Google Cloud Platform account type.",
|
"description": "Google Cloud Platform account type.",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user