Skip to content

Commit

Permalink
Merge pull request #11 from elementary-data/feature/support-snowflake…
Browse files Browse the repository at this point in the history
…-keyfile

added snowflake keyfile support
  • Loading branch information
ofek1weiss authored Feb 4, 2024
2 parents 0a635fb + 2f64052 commit 2b90d3a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ If you're using BigQuery with a key file,
supply the `bigquery-keyfile` argument to the action and make sure your `keyfile` in the `profiles-yml`
is `/tmp/bigquery_keyfile.json`.

### Snowflake Keyfile Authentication

If you're using Snowflake with a key file,
supply the `snowflake-keyfile` argument to the action and make sure your `private_key_path` in the `profiles-yml`
is `/tmp/snowflake_keyfile.key`.

### Google Cloud Storage Keyfile

If you want to upload your report to a Google Cloud Storage bucket using `send-report`,
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ inputs:
bigquery-keyfile:
description: The content of your BigQuery keyfile.
required: false
snowflake-keyfile:
description: The content of your Snowflake keyfile.
required: false
gcs-keyfile:
description: The content of your Google service account keyfile, for usage with Google Cloud Storage.
required: false
Expand Down
18 changes: 14 additions & 4 deletions entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ def setup_env(
profiles_yml: Optional[str],
bigquery_keyfile: Optional[str],
gcs_keyfile: Optional[str],
snowflake_keyfile: Optional[str],
):
logging.info(f"Setting up the environment.")
logging.info("Setting up the environment.")
dbt_dir = Path.home() / ".dbt"
dbt_dir.mkdir(parents=True, exist_ok=True)
if profiles_yml:
Expand All @@ -37,6 +38,8 @@ def setup_env(
Path("/tmp/bigquery_keyfile.json").write_text(bigquery_keyfile)
if gcs_keyfile:
Path("/tmp/gcs_keyfile.json").write_text(gcs_keyfile)
if snowflake_keyfile:
Path("/tmp/snowflake_keyfile.key").write_text(snowflake_keyfile)


def install_edr(
Expand Down Expand Up @@ -108,7 +111,7 @@ def install_edr(


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


Expand All @@ -119,6 +122,7 @@ class Args(BaseModel):
profiles_yml: Optional[str]
edr_command: str
bigquery_keyfile: Optional[str]
snowflake_keyfile: Optional[str]
gcs_keyfile: Optional[str]
profile_target: Optional[str]

Expand All @@ -131,16 +135,22 @@ def main():
profile_target=os.getenv("INPUT_PROFILE-TARGET") or None,
project_dir=os.getenv("INPUT_PROJECT-DIR") or None,
bigquery_keyfile=os.getenv("INPUT_BIGQUERY-KEYFILE") or None,
snowflake_keyfile=os.getenv("INPUT_SNOWFLAKE-KEYFILE") or None,
gcs_keyfile=os.getenv("INPUT_GCS-KEYFILE") or None,
adapter_version=os.getenv("INPUT_ADAPTER-VERSION") or None,
)
install_dbt(args.adapter, args.adapter_version)
setup_env(args.profiles_yml, args.bigquery_keyfile, args.gcs_keyfile)
setup_env(
args.profiles_yml,
args.bigquery_keyfile,
args.gcs_keyfile,
args.snowflake_keyfile,
)
install_edr(args.adapter, args.project_dir, args.profile_target)
try:
run_edr(args.edr_command, args.project_dir)
except subprocess.CalledProcessError:
logging.exception(f"Failed to run the edr command.")
logging.exception("Failed to run the edr command.")
raise


Expand Down

0 comments on commit 2b90d3a

Please sign in to comment.