Skip to content

Commit

Permalink
Update tf-plan.py
Browse files Browse the repository at this point in the history
  • Loading branch information
guptamukul-google committed Nov 15, 2021
1 parent 3934ead commit 7748b88
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tools/tf-plan.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ def main(PR):
# print('****************************')
# print(glob.glob(os.getcwd() + '/temp/' + dir+'/*/*'))

# Running Terraform Init & Terraform Plan
comment, status = tf(os.getcwd() + '/temp/' + dir)
comment = comment + ' for: **' + dir + '** !'

# Commenting on the PR
commentpr(GITHUB_REPOSITORY, PR, comment, TOKEN)
if(status == 'fail'):
sys.exit('Terraform Init or Terraform Plan FAILED for: '+ dir)
Expand Down Expand Up @@ -173,13 +177,14 @@ def tf(dir):

path = os.getcwd()+'/temp/'
if(return_code_init == 1):
comment = 'Terraform Init FAILED for: **' + dir.replace(path, '') + '** !'
comment = 'Terraform Init FAILED'
status = 'fail'
if(return_code_plan == 1):
comment = 'Terraform Plan FAILED for: **' + dir.replace(path, '') + '** !'
comment = 'Terraform Plan FAILED'
status = 'fail'
else:
comment = 'Terraform Init & Terraform Plan SUCCESSFUL for: **' + dir.replace(path, '') + '** !'
comment = 'Terraform Init & Terraform Plan SUCCESSFUL'
status = 'pass'

return comment, status

Expand Down

0 comments on commit 7748b88

Please sign in to comment.