Skip to content

Commit 2b90d3a

Browse files
authored
Merge pull request #11 from elementary-data/feature/support-snowflake-keyfile
added snowflake keyfile support
2 parents 0a635fb + 2f64052 commit 2b90d3a

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ If you're using BigQuery with a key file,
149149
supply the `bigquery-keyfile` argument to the action and make sure your `keyfile` in the `profiles-yml`
150150
is `/tmp/bigquery_keyfile.json`.
151151

152+
### Snowflake Keyfile Authentication
153+
154+
If you're using Snowflake with a key file,
155+
supply the `snowflake-keyfile` argument to the action and make sure your `private_key_path` in the `profiles-yml`
156+
is `/tmp/snowflake_keyfile.key`.
157+
152158
### Google Cloud Storage Keyfile
153159

154160
If you want to upload your report to a Google Cloud Storage bucket using `send-report`,

action.yml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ inputs:
4040
bigquery-keyfile:
4141
description: The content of your BigQuery keyfile.
4242
required: false
43+
snowflake-keyfile:
44+
description: The content of your Snowflake keyfile.
45+
required: false
4346
gcs-keyfile:
4447
description: The content of your Google service account keyfile, for usage with Google Cloud Storage.
4548
required: false

entrypoint.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def setup_env(
2727
profiles_yml: Optional[str],
2828
bigquery_keyfile: Optional[str],
2929
gcs_keyfile: Optional[str],
30+
snowflake_keyfile: Optional[str],
3031
):
31-
logging.info(f"Setting up the environment.")
32+
logging.info("Setting up the environment.")
3233
dbt_dir = Path.home() / ".dbt"
3334
dbt_dir.mkdir(parents=True, exist_ok=True)
3435
if profiles_yml:
@@ -37,6 +38,8 @@ def setup_env(
3738
Path("/tmp/bigquery_keyfile.json").write_text(bigquery_keyfile)
3839
if gcs_keyfile:
3940
Path("/tmp/gcs_keyfile.json").write_text(gcs_keyfile)
41+
if snowflake_keyfile:
42+
Path("/tmp/snowflake_keyfile.key").write_text(snowflake_keyfile)
4043

4144

4245
def install_edr(
@@ -108,7 +111,7 @@ def install_edr(
108111

109112

110113
def run_edr(edr_command: str, project_dir: Optional[str]):
111-
logging.info(f"Running the edr command.")
114+
logging.info("Running the edr command.")
112115
subprocess.run(edr_command, shell=True, check=True, cwd=project_dir)
113116

114117

@@ -119,6 +122,7 @@ class Args(BaseModel):
119122
profiles_yml: Optional[str]
120123
edr_command: str
121124
bigquery_keyfile: Optional[str]
125+
snowflake_keyfile: Optional[str]
122126
gcs_keyfile: Optional[str]
123127
profile_target: Optional[str]
124128

@@ -131,16 +135,22 @@ def main():
131135
profile_target=os.getenv("INPUT_PROFILE-TARGET") or None,
132136
project_dir=os.getenv("INPUT_PROJECT-DIR") or None,
133137
bigquery_keyfile=os.getenv("INPUT_BIGQUERY-KEYFILE") or None,
138+
snowflake_keyfile=os.getenv("INPUT_SNOWFLAKE-KEYFILE") or None,
134139
gcs_keyfile=os.getenv("INPUT_GCS-KEYFILE") or None,
135140
adapter_version=os.getenv("INPUT_ADAPTER-VERSION") or None,
136141
)
137142
install_dbt(args.adapter, args.adapter_version)
138-
setup_env(args.profiles_yml, args.bigquery_keyfile, args.gcs_keyfile)
143+
setup_env(
144+
args.profiles_yml,
145+
args.bigquery_keyfile,
146+
args.gcs_keyfile,
147+
args.snowflake_keyfile,
148+
)
139149
install_edr(args.adapter, args.project_dir, args.profile_target)
140150
try:
141151
run_edr(args.edr_command, args.project_dir)
142152
except subprocess.CalledProcessError:
143-
logging.exception(f"Failed to run the edr command.")
153+
logging.exception("Failed to run the edr command.")
144154
raise
145155

146156

0 commit comments

Comments
 (0)