atlantis icon indicating copy to clipboard operation
atlantis copied to clipboard

feat: adding extra plan and apply flags to api_controller

Open dbmurphy opened this issue 1 year ago • 15 comments

what

  • Adding option to add flags to API (Test and Rebased from #3287 ) plus more improvements

why

used to specify terraform arguments via the API

tests

Control Test:
/usr/local/bin/python3.9 /Users/david.murphy/atlantis_api_test/atlantis_api_base_plan.py 
Plan request sent successfully!
Payload was:
{'PR': 1,
 'Paths': [{'Directory': '.', 'Workspace': 'default'}],
 'Ref': 'example',
 'Repository': 'dbmurphy/atlantis-example',
 'Type': 'Github'}
TF Command was: atlantis plan -d .
TF Output

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

  # null_resource.example will be created
+ resource "null_resource" "example" {
      + id = (known after apply)
    }

  # null_resource.example2 will be created
+ resource "null_resource" "example2" {
      + id = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.
Targeted example2 only Test:
/usr/local/bin/python3.9 /Users/david.murphy/atlantis_api_test/atlantis_api_targeted_plan.py 
Plan request sent successfully!
Payload was:
{'PR': 1,
 'Paths': [{'Directory': '.',
            'ExtraFlags': ['-target=null_resource.example2'],
            'Workspace': 'default'}],
 'Ref': 'example',
 'Repository': 'dbmurphy/atlantis-example',
 'Type': 'Github'}
TF Command was: atlantis plan -d . -- -target=null_resource.example2
TF Output

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create

Terraform will perform the following actions:

  # null_resource.example2 will be created
+ resource "null_resource" "example2" {
      + id = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
╷
│ Warning: Resource targeting is in effect
│ 
│ You are creating a plan with the -target option, which means that the
│ result of this plan may not represent all of the changes requested by the
│ current configuration.
│ 
│ The -target option is not for routine use, and is provided only for
│ exceptional situations such as recovering from errors or mistakes, or when
│ Terraform specifically suggests to use it as part of an error message.
╵
Bad ExtraFlag Test:
/usr/local/bin/python3.9 /Users/david.murphy/atlantis_api_test/atlantis_api_bad_plan.py 
Error occurred: 
Status Code: (500)
{'Error': None,
 'Failure': '',
 'PlansDeleted': False,
 'ProjectResults': [{'ApplySuccess': '',
                     'Command': 1,
                     'Error': {},
                     'Failure': '',
                     'ImportSuccess': None,
                     'PlanSuccess': None,
                     'PolicyCheckResults': None,
                     'ProjectName': '',
                     'RepoRelDir': '.',
                     'StateRmSuccess': None,
                     'SubCommand': '',
                     'VersionSuccess': '',
                     'Workspace': 'default'}]}
Payload was:
{'PR': 1,
 'Paths': [{'Directory': '.',
            'ExtraFlags': ['--invalid-flag'],
            'Workspace': 'default'}],
 'Ref': 'example',
 'Repository': 'dbmurphy/atlantis-example',
 'Type': 'Github'}

references

dbmurphy avatar Jul 15 '23 00:07 dbmurphy

@nitrocode I have added tests and fixed the merge issues

dbmurphy avatar Jul 16 '23 10:07 dbmurphy

@GenPage is there something I need to do here to trigger assignments and reviews? The only fail is on vupress messing with deploy test but I see you have a PR about that one.

dbmurphy avatar Jul 24 '23 08:07 dbmurphy

@GenPage is there something I need to do here to trigger assignments and reviews? The only fail is on vupress messing with deploy test but I see you have a PR about that one.

just requesting the review for maintainers is enough, we will try to review this week and the vuepress error should be fixed after we merge the fix we have.

jamengual avatar Jul 24 '23 16:07 jamengual

@jamengual @GenPage Where are we with this its sat for some time waiting on the approvers' group.

dbmurphy avatar Aug 31 '23 09:08 dbmurphy

@dbmurphy Can you add a comment on why the test calls are commented out with Paths being the out-of-scope cause, that way someone else coming along can understand.

GenPage avatar Aug 31 '23 17:08 GenPage

@dbmurphy Are you able to follow up on this?

GenPage avatar Oct 06 '23 16:10 GenPage

@dbmurphy Are you able to follow up on this?

I'll get to this this weekend. Sorry, I've been hectic leading up to the end of the quarter for main job

dbmurphy avatar Oct 06 '23 16:10 dbmurphy

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

github-actions[bot] avatar Nov 07 '23 01:11 github-actions[bot]

@dbmurphy any updates?

jamengual avatar Nov 15 '23 05:11 jamengual

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

github-actions[bot] avatar Jan 13 '24 01:01 github-actions[bot]

Hello, any updates on this PR?

caiodelgadonew avatar Jan 25 '24 17:01 caiodelgadonew

if there are no updates by next week, I'll take a look and merge. I don't want to block a PR on a code comment.

GenPage avatar Jan 26 '24 23:01 GenPage

Hey @GenPage can we move on this? :)

caiodelgadonew avatar Feb 08 '24 14:02 caiodelgadonew

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

github-actions[bot] avatar Mar 11 '24 01:03 github-actions[bot]

This issue is stale because it has been open for 1 month with no activity. Remove stale label or comment or this will be closed in 1 month.

github-actions[bot] avatar May 13 '24 01:05 github-actions[bot]

@caiodelgadonew Apologies for this; I no longer can do code reviews and rely on our maintainer/core contributors to do so. Enough time has passed, and this should be re-opened with a new PR.

GenPage avatar Jun 26 '24 05:06 GenPage