Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Support For Hiding Previous Plan Comments on GitLab #3476

Merged
merged 2 commits into from
Jun 14, 2023

Conversation

X-Guardian
Copy link
Contributor

@X-Guardian X-Guardian commented Jun 2, 2023

what

Update the HidePrevCommandComments stub function on the GitLab client to hide previous plan comments, following the pattern implemented for the GitHub client, but using an HTML summary header and footer to hide the comment.

Also added a logger to the GitLab client so that log entries can be added from the GitLab client functions.

why

tests

Example Hidden Comment

Superseded Atlantis Plan

Ran Plan for 1 project:

  1. dir: s3-buckets/waf-logging workspace: default

1. dir: s3-buckets/waf-logging workspace: default

Show Output
Initializing the backend...

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.

Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Using hashicorp/aws v4.13.0 from the shared cache directory

Terraform has been successfully initialized!


Initializing the backend...

Initializing provider plugins...
- Reusing previous version of hashicorp/aws from the dependency lock file
- Using previously-installed hashicorp/aws v4.13.0

Terraform has been successfully initialized!
aws_iam_group.modify: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging-modify]
data.aws_iam_policy_document.kms: Reading...
aws_iam_group.read: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging-read]
data.aws_elb_service_account.main: Reading...
aws_s3_bucket.bucket: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging]
data.aws_elb_service_account.main: Read complete after 0s [id=652711504416]
data.aws_iam_policy_document.kms: Read complete after 0s [id=1198219433]
aws_s3_bucket_versioning.versioning: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging]
aws_iam_policy.modify: Refreshing state... [id=arn:aws:iam::846880112034:policy/aws-waf-logs-eu-west-2-develop-waf-logging-modify-policy]
aws_s3_bucket_logging.log_bucket[0]: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging]
aws_iam_policy.read: Refreshing state... [id=arn:aws:iam::846880112034:policy/aws-waf-logs-eu-west-2-develop-waf-logging-read-policy]
aws_s3_bucket_acl.acl: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging,private]
aws_s3_bucket_server_side_encryption_configuration.encryption: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging]
aws_s3_bucket_public_access_block.public_access_block: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging]
aws_s3_bucket_lifecycle_configuration.example[0]: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging]
aws_iam_group_policy_attachment.write: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging-modify-20220810153749169700000002]
aws_iam_group_policy_attachment.read: Refreshing state... [id=aws-waf-logs-eu-west-2-develop-waf-logging-read-20220810153749157600000001]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place
  - destroy
 <= read (data resources)

Terraform will perform the following actions:

  # data.aws_iam_policy_document.bucket_policy will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_iam_policy_document" "bucket_policy" {
+       id   = (known after apply)
+       json = (known after apply)
    }

  # data.aws_iam_policy_document.modify will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_iam_policy_document" "modify" {
+       id   = (known after apply)
+       json = (known after apply)

+       statement {
+           actions   = [
+               "s3:DeleteObject",
+               "s3:PutObject",
            ]
+           effect    = "Allow"
+           resources = [
+               "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging",
+               "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging/*",
            ]
        }
    }

  # data.aws_iam_policy_document.read will be read during apply
  # (depends on a resource or a module with changes pending)
 <= data "aws_iam_policy_document" "read" {
+       id   = (known after apply)
+       json = (known after apply)

+       statement {
+           actions   = [
+               "s3:GetBucketLocation",
+               "s3:GetObject",
+               "s3:GetObjectTagging",
+               "s3:ListBucket",
            ]
+           effect    = "Allow"
+           resources = [
+               "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging",
+               "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging/*",
            ]
        }
    }

  # aws_iam_policy.modify will be updated in-place
!   resource "aws_iam_policy" "modify" {
        id        = "arn:aws:iam::846880112034:policy/aws-waf-logs-eu-west-2-develop-waf-logging-modify-policy"
        name      = "aws-waf-logs-eu-west-2-develop-waf-logging-modify-policy"
!       policy    = jsonencode(
            {
-               Statement = [
-                   {
-                       Action   = [
-                           "s3:PutObject",
-                           "s3:DeleteObject",
                        ]
-                       Effect   = "Allow"
-                       Resource = [
-                           "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging/*",
-                           "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging",
                        ]
-                       Sid      = ""
                    },
                ]
-               Version   = "2012-10-17"
            }
        ) -> (known after apply)
!       tags      = {
+           "Environment" = "develop"
            "Name"        = "aws-waf-logs-eu-west-2-develop-waf-logging"
        }
!       tags_all  = {
+           "TerraformPath" = "s3-buckets/waf-logging"
            # (5 unchanged elements hidden)
        }
        # (3 unchanged attributes hidden)
    }

  # aws_iam_policy.read will be updated in-place
!   resource "aws_iam_policy" "read" {
        id        = "arn:aws:iam::846880112034:policy/aws-waf-logs-eu-west-2-develop-waf-logging-read-policy"
        name      = "aws-waf-logs-eu-west-2-develop-waf-logging-read-policy"
!       policy    = jsonencode(
            {
-               Statement = [
-                   {
-                       Action   = [
-                           "s3:ListBucket",
-                           "s3:GetObjectTagging",
-                           "s3:GetObject",
-                           "s3:GetBucketLocation",
                        ]
-                       Effect   = "Allow"
-                       Resource = [
-                           "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging/*",
-                           "arn:aws:s3:::aws-waf-logs-eu-west-2-develop-waf-logging",
                        ]
-                       Sid      = ""
                    },
                ]
-               Version   = "2012-10-17"
            }
        ) -> (known after apply)
!       tags      = {
+           "Environment" = "develop"
            "Name"        = "aws-waf-logs-eu-west-2-develop-waf-logging"
        }
!       tags_all  = {
+           "TerraformPath" = "s3-buckets/waf-logging"
            # (5 unchanged elements hidden)
        }
        # (3 unchanged attributes hidden)
    }

  # aws_s3_bucket.bucket will be updated in-place
!   resource "aws_s3_bucket" "bucket" {
        id                          = "aws-waf-logs-eu-west-2-develop-waf-logging"
!       tags                        = {
+           "Environment" = "develop"
            "Name"        = "aws-waf-logs-eu-west-2-develop-waf-logging"
        }
!       tags_all                    = {
+           "TerraformPath" = "s3-buckets/waf-logging"
            # (5 unchanged elements hidden)
        }
        # (10 unchanged attributes hidden)

        # (5 unchanged blocks hidden)
    }

  # aws_s3_bucket_logging.log_bucket[0] will be destroyed
  # (because index [0] is out of range for count)
-   resource "aws_s3_bucket_logging" "log_bucket" {
-       bucket        = "aws-waf-logs-eu-west-2-develop-waf-logging" -> null
-       id            = "aws-waf-logs-eu-west-2-develop-waf-logging" -> null
-       target_bucket = "eu-west-2-develop-s3-access-logging" -> null
-       target_prefix = "/waf" -> null
    }

Plan: 0 to add, 3 to change, 1 to destroy.
  • ▶️ To apply this plan, comment:
    • atlantis apply -d s3-buckets/waf-logging
  • 🚮 To delete this plan click here
  • 🔁 To plan this project again, comment:
    • atlantis plan -d s3-buckets/waf-logging
Plan: 0 to add, 3 to change, 1 to destroy.

@X-Guardian X-Guardian marked this pull request as ready for review June 5, 2023 16:59
@X-Guardian X-Guardian requested a review from a team as a code owner June 5, 2023 16:59
@github-actions github-actions bot added docs Documentation go Pull requests that update Go code provider/gitlab labels Jun 5, 2023
@X-Guardian
Copy link
Contributor Author

@nitrocode, can this PR be included in the 0.24.3 release? It is not currently tagged with the milestone.

@nitrocode
Copy link
Member

cc @GenPage @jamengual please review when you get a chance

Copy link
Contributor

@jamengual jamengual left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@nitrocode nitrocode merged commit 556de93 into runatlantis:main Jun 14, 2023
@nitrocode nitrocode added this to the v0.24.3 milestone Jun 14, 2023
@X-Guardian X-Guardian deleted the gitlab-comment-hide branch June 22, 2023 09:11
@X-Guardian
Copy link
Contributor Author

@jamengual, this PR has been missed from the v0.24.3 release notes.

@jamengual
Copy link
Contributor

that is weird, we use an autogenerated option.

maybe there is a limit n the lines, I will add it manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation go Pull requests that update Go code provider/gitlab
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Add Support For Hiding Previous Plan Comments on GitLab
3 participants