Skip to content

Commit

Permalink
Merge pull request #94 from daum/bugfix/93-target-base-fix-dashboard-…
Browse files Browse the repository at this point in the history
…looks

Fixes #93, target_base required for deploy content.
  • Loading branch information
AdamMinton authored Oct 7, 2022
2 parents 3065a4f + c9f6a4f commit 575b6f5
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 30 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ jobs:
os:
- ubuntu
python-version:
- '3.6'
- '3.7'
- '3.8'
- '3.9'
- "3.7"
- "3.8"
- "3.9"

steps:
- name: Repo Checkout
Expand Down Expand Up @@ -115,5 +114,5 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}
report_individual_runs: true
hide_comments: orphaned commits
check_run_annotations_branch: '*'
files: 'artifacts/python-test-results/*.xml'
check_run_annotations_branch: "*"
files: "artifacts/python-test-results/*.xml"
2 changes: 1 addition & 1 deletion looker_deployer/commands/deploy_boards.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def board_content_lists(board_object):
if j.look_id:
look_list.append(j.look_id)

return(dash_list, look_list)
return (dash_list, look_list)


def audit_board_content(board_object, source_sdk, target_sdk):
Expand Down
18 changes: 9 additions & 9 deletions looker_deployer/commands/deploy_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def build_spaces(spaces, sdk):
return id_tracker[0]


def deploy_space(s, sdk, env, ini, recursive, debug=False, target_base=None):
def deploy_space(s, sdk, env, ini, recursive, target_base, debug=False):

logger.debug("working folder", extra={"working_folder": s})

Expand Down Expand Up @@ -202,12 +202,12 @@ def deploy_space(s, sdk, env, ini, recursive, debug=False, target_base=None):
if recursive and space_children:
logger.info("Attemting Recursion of children folders", extra={"children_folders": space_children})
for child in space_children:
deploy_space(child, sdk, env, ini, recursive, debug, target_base)
deploy_space(child, sdk, env, ini, recursive, target_base, debug)
else:
logger.info("No Recursion specified or empty child list", extra={"children_folders": space_children})


def deploy_content(content_type, content, sdk, env, ini, debug=False, target_base=None):
def deploy_content(content_type, content, sdk, env, ini, target_base, debug=False):
# extract directory path
dirs = content.rpartition(os.sep)[0] + os.sep

Expand Down Expand Up @@ -243,10 +243,10 @@ def send_content(
# copy the source space directory tree to target space override
shutil.copytree(s, updated_space)
# kick off the job from the new space
deploy_space(updated_space, sdk, env, ini, recursive, debug, target_base)
deploy_space(updated_space, sdk, env, ini, recursive, target_base, debug)
# If no target space override, kick off job normally
else:
deploy_space(s, sdk, env, ini, recursive, debug, target_base)
deploy_space(s, sdk, env, ini, recursive, target_base, debug)
if dashboards:
logger.debug("Deploying dashboards", extra={"dashboards": dashboards})
for dash in dashboards:
Expand All @@ -263,9 +263,9 @@ def send_content(
shutil.copy(dash, target_dir)
new_dash_path = [os.path.join(target_dir, f) for f in os.listdir(target_dir)][0]
# kick off the job from the new space
deploy_content("dashboard", new_dash_path, sdk, env, ini, debug)
deploy_content("dashboard", new_dash_path, sdk, env, ini, target_base, debug)
else:
deploy_content("dashboard", dash, sdk, env, ini, debug)
deploy_content("dashboard", dash, sdk, env, ini, target_base, debug)
if looks:
logger.debug("Deploying looks", extra={"looks": looks})
for look in looks:
Expand All @@ -282,9 +282,9 @@ def send_content(
shutil.copy(look, target_dir)
new_look_path = [os.path.join(target_dir, f) for f in os.listdir(target_dir)][0]
# kick off the job from the new space
deploy_content("look", new_look_path, sdk, env, ini, debug)
deploy_content("look", new_look_path, sdk, env, ini, target_base, debug)
else:
deploy_content("look", look, sdk, env, ini, debug)
deploy_content("look", look, sdk, env, ini, target_base, debug)


def main(args):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
name=NAME,
packages=["looker_deployer", "looker_deployer/commands", "looker_deployer/utils"],
entry_points={"console_scripts": ["ldeploy=looker_deployer.cli:main"]},
python_requires=">=3.6.0, <=3.9.13",
python_requires=">=3.6.0, <3.10",
version=VERSION
)
19 changes: 6 additions & 13 deletions tests/test_deploy_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def test_deploy_space_build_call(mocker):

mocker.patch("looker_deployer.commands.deploy_content.build_spaces")
mocker.patch("looker_deployer.commands.deploy_content.import_content")
deploy_content.deploy_space("Foo/Shared/Bar/", "sdk", "env", "ini", False, False, "Shared")
deploy_content.deploy_space("Foo/Shared/Bar/", "sdk", "env", "ini", False, "Shared", False)
deploy_content.build_spaces.assert_called_with(["Shared", "Bar"], "sdk")


Expand All @@ -239,7 +239,7 @@ def test_deploy_space_look_call(mocker):
deploy_content.build_spaces.return_value = "42"

mocker.patch("looker_deployer.commands.deploy_content.import_content")
deploy_content.deploy_space("Foo/Shared/Bar", "sdk", "env", "ini", False, False, "Shared")
deploy_content.deploy_space("Foo/Shared/Bar", "sdk", "env", "ini", False, "Shared", False)
deploy_content.import_content.assert_called_once_with("look", "Foo/Shared/Bar/Look_test", "42", "env", "ini", False)


Expand All @@ -257,22 +257,15 @@ def test_deploy_space_dashboard_call(mocker):
deploy_content.build_spaces.return_value = "42"

mocker.patch("looker_deployer.commands.deploy_content.import_content")
deploy_content.deploy_space("Foo/Shared/Bar", "sdk", "env", "ini", False, False, "Shared")
deploy_content.import_content.assert_called_once_with(
"dashboard",
"Foo/Shared/Bar/Dashboard_test",
"42",
"env",
"ini",
False
)
deploy_content.deploy_space("Foo/Shared/Bar", "sdk", "env", "ini", False, "Shared", False)
deploy_content.import_content.assert_called_once_with("dashboard", "Foo/Shared/Bar/Dashboard_test", "42", "env", "ini", False)


def test_deploy_content_build_call(mocker):

mocker.patch("looker_deployer.commands.deploy_content.build_spaces")
mocker.patch("looker_deployer.commands.deploy_content.import_content")
deploy_content.deploy_content("look", "Foo/Shared/Bar/Baz/Dashboard_test.json", "sdk", "env", "ini", False, "Shared")
deploy_content.deploy_content("look", "Foo/Shared/Bar/Baz/Dashboard_test.json", "sdk", "env", "ini", "Shared")
deploy_content.build_spaces.assert_called_with(["Shared", "Bar", "Baz"], "sdk")


Expand All @@ -281,5 +274,5 @@ def test_deploy_content_import_content_call(mocker):
deploy_content.build_spaces.return_value = "42"

mocker.patch("looker_deployer.commands.deploy_content.import_content")
deploy_content.deploy_content("look", "Foo/Shared/Bar/Look_test.json", "sdk", "env", "ini", False, "Shared")
deploy_content.deploy_content("look", "Foo/Shared/Bar/Look_test.json", "sdk", "env", "ini", "Shared")
deploy_content.import_content.assert_called_with("look", "Foo/Shared/Bar/Look_test.json", "42", "env", "ini", False)

0 comments on commit 575b6f5

Please sign in to comment.