-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #244 from terrateamio/main
Release v1
- Loading branch information
Showing
1 changed file
with
56 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,29 +150,7 @@ def transform_tf_vars(env): | |
env.update(new_keys) | ||
|
||
|
||
def main(): | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
print(BANNER) | ||
print('*** These are not the logs you are looking for ***') | ||
print('***') | ||
print('*** The output of the action is not meant for debugging purposes ***') | ||
print('*** If you are reading this to debug an issue please: ***') | ||
print('- Join our Slack community https://slack.terrateam.io/ (Fastest)') | ||
print('- Email us directly at [email protected]') | ||
print('***') | ||
print('***') | ||
|
||
parser = make_parser() | ||
args = parser.parse_args() | ||
|
||
if not args.api_base_url: | ||
args.api_base_url = DEFAULT_API_BASE_URL | ||
|
||
if args.api_base_url[-1] == '/': | ||
# Remove trailing '/' | ||
args.api_base_url = args.api_base_url[:-1] | ||
|
||
def run(args): | ||
logging.debug('LOADING : WORK_MANIFEST') | ||
|
||
try: | ||
|
@@ -191,13 +169,10 @@ def main(): | |
print('*** or email us directly at [email protected] ***') | ||
raise | ||
|
||
# We only support a merge-based evaluation. We must perform the merge first | ||
# because we load the repo config next and we want it to be the merged | ||
# version. | ||
subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', args.workspace]) | ||
subprocess.check_call(['git', 'config', '--global', 'user.email', '[email protected]']) | ||
subprocess.check_call(['git', 'config', '--global', 'user.name', 'Terrateam Action']) | ||
subprocess.check_call(['git', 'config', '--global', 'advice.detachedHead', 'false']) | ||
# If it's a "done" work manifest, then bail | ||
if wm['type'] == 'done': | ||
logging.info('Work manifest is completed, exiting.') | ||
return True | ||
|
||
logging.debug('LOADING: REPO_CONFIG') | ||
rc = repo_config.load([os.path.join(args.workspace, path) for path in REPO_CONFIG_PATHS]) | ||
|
@@ -234,6 +209,57 @@ def main(): | |
logging.debug('EXEC : %s', wm['type']) | ||
WORK_MANIFEST_DISPATCH[wm['type']](state) | ||
|
||
return False | ||
|
||
|
||
def main(): | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
print(BANNER) | ||
print('*** These are not the logs you are looking for ***') | ||
print('***') | ||
print('*** The output of the action is not meant for debugging purposes ***') | ||
print('*** If you are reading this to debug an issue please: ***') | ||
print('- Join our Slack community https://slack.terrateam.io/ (Fastest)') | ||
print('- Email us directly at [email protected]') | ||
print('***') | ||
print('***') | ||
|
||
parser = make_parser() | ||
args = parser.parse_args() | ||
|
||
if not args.api_base_url: | ||
args.api_base_url = DEFAULT_API_BASE_URL | ||
|
||
if args.api_base_url[-1] == '/': | ||
# Remove trailing '/' | ||
args.api_base_url = args.api_base_url[:-1] | ||
|
||
# We only support a merge-based evaluation. We must perform the merge first | ||
# because we load the repo config next and we want it to be the merged | ||
# version. | ||
subprocess.check_call(['git', 'config', '--global', '--add', 'safe.directory', args.workspace]) | ||
subprocess.check_call(['git', 'config', '--global', 'user.email', '[email protected]']) | ||
subprocess.check_call(['git', 'config', '--global', 'user.name', 'Terrateam Action']) | ||
subprocess.check_call(['git', 'config', '--global', 'advice.detachedHead', 'false']) | ||
|
||
done = False | ||
run_count = 0 | ||
|
||
while not done: | ||
done = run(args) | ||
run_count += 1 | ||
if run_count > 10: | ||
print('*** Performed too many work manifests, exiting to prevent unexpected loop') | ||
break | ||
|
||
# This means we only did one run, which is that we got the "done" work | ||
# manifest. | ||
if run_count == 1: | ||
print('*** It looks like the work manifest was completed before this started ***') | ||
print('*** Manual re-runs are not supported ***') | ||
print('*** Please create a run through the Terrateam interface ***') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |