Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Airflow Datacat Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
eFlows4HPC WP2
Airflow Datacat Integration
Commits
cd65a836
Commit
cd65a836
authored
3 years ago
by
Christian Boettcher
Browse files
Options
Downloads
Patches
Plain Diff
consistently use json-string as intermediate format
parent
bbfe0c77
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/datacat_integration/secrets.py
+7
-6
7 additions, 6 deletions
src/datacat_integration/secrets.py
with
7 additions
and
6 deletions
src/datacat_integration/secrets.py
+
7
−
6
View file @
cd65a836
...
...
@@ -3,8 +3,9 @@ from urllib.parse import urljoin
from
airflow.secrets
import
BaseSecretsBackend
import
requests
import
logging
import
json
from
datacat_integration.connection
import
DataCatConnection
,
get_connection_from_entry
from
datacat_integration.connection
import
DataCatConnection
,
DataCatalogEntry
,
get_connection_from_entry
connection_backend_type
=
"
airflow_connections
"
...
...
@@ -42,7 +43,7 @@ class DataCatConnectionWithSecrets(DataCatConnection):
url
=
urljoin
(
self
.
url
,
f
"
{
datacat_type
}
/
{
oid
}
/secrets
"
)
response
=
requests
.
get
(
url
,
headers
=
headers
)
if
response
.
ok
:
return
response
.
json
()
return
json
.
dumps
(
response
.
json
()
)
else
:
raise
ConnectionError
(
response
.
text
)
...
...
@@ -55,7 +56,7 @@ class DataCatConnectionWithSecrets(DataCatConnection):
url
=
urljoin
(
self
.
url
,
f
"
{
datacat_type
}
/
{
oid
}
/secrets_values
"
)
response
=
requests
.
get
(
url
,
headers
=
headers
)
if
response
.
ok
:
return
response
.
json
()
return
json
.
dumps
(
response
.
json
()
)
else
:
raise
ConnectionError
(
response
.
text
)
...
...
@@ -68,7 +69,7 @@ class DataCatConnectionWithSecrets(DataCatConnection):
url
=
urljoin
(
self
.
url
,
f
"
{
datacat_type
}
/
{
oid
}
/secrets/
{
key
}
"
)
response
=
requests
.
get
(
url
,
headers
=
headers
)
if
response
.
ok
:
return
response
.
json
()
return
json
.
dumps
(
response
.
json
()
)
else
:
raise
ConnectionError
(
response
.
text
)
...
...
@@ -87,7 +88,7 @@ class DatacatSecretsBackend(BaseSecretsBackend):
log
.
debug
(
f
"
Get connection:
{
conn_id
}
"
)
secrets_conn
=
DataCatConnectionWithSecrets
(
self
.
url
,
self
.
user
,
self
.
password
)
data
=
secrets_conn
.
get_entry
(
connection_backend_type
,
conn_id
)
secrets
=
secrets_conn
.
get_all_secret_key_value
(
connection_backend_type
,
conn_id
)
data
=
DataCatalogEntry
.
from_json
(
secrets_conn
.
get_entry
(
connection_backend_type
,
conn_id
)
).
__dict__
secrets
=
json
.
loads
(
secrets_conn
.
get_all_secret_key_value
(
connection_backend_type
,
conn_id
)
)
conn
=
get_connection_with_secrets_from_entry
(
data
,
secrets
,
connection_backend_type
,
conn_id
)
return
conn
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment