yor icon indicating copy to clipboard operation
yor copied to clipboard

tag-prefix doesn't work with tags or tag-groups cli switches

Open jim-weller opened this issue 11 months ago • 3 comments

Describe the bug tag-prefix does not play well with other command line switches. I've tried quite a few combinations of switches. Prefix only seems to work in the barest of configurations.

To Reproduce main.tf

resource "aws_ssm_parameter" "environment_type" {
  name        = "environment_type"
  type        = "String"
  value       = "dev"
  description = "A basic SSM parameter that will vary between DEV and PROD aws accounts according to the tfvars files in the env/ directory."

  # tags will be injected below  here by yor
}

prefix switch breaks behavior when specifying tags

❯ yor tag -d . --tags yor_trace  --tag-prefix "test:" --dry-run
  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.189
 Yor Findings Summary
 Scanned Resources:	  1
 New Resources Traced: 	  0
 Updated Resources:	  0

prefix switch works alone

❯ yor tag -d . --tag-prefix "technical:" --dry-run
  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.189
 Yor Findings Summary
 Scanned Resources:	  1
 New Resources Traced: 	  1
 Updated Resources:	  0

New Resources Traced (1):
+---------+------------------------------------+--------------------------------+------------------------------------------+--------+
|  FILE   |              RESOURCE              |            TAG KEY             |                TAG VALUE                 | YOR ID |
+---------+------------------------------------+--------------------------------+------------------------------------------+--------+
| main.tf | aws_ssm_parameter.environment_type | technical:yor_trace            | cc810173-70aa-4c76-9493-5edd20288bec     |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:yor_name             | environment_type                         |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_repo             | enbl-demo-iac-yor-tagging                |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_org              | HylandSoftware                           |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_modifiers        | jim.weller                               |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_last_modified_by | [email protected]                    |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_last_modified_at | 2024-02-29 15:21:45                      |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_file             | main.tf                                  |        |
+         +                                    +--------------------------------+------------------------------------------+--------+
|         |                                    | technical:git_commit           | 4c39aa9f59024a8d618a77bba5a75f05345058e5 |        |
+---------+------------------------------------+--------------------------------+------------------------------------------+--------+

Expected behavior yor should tag files with the appropriate prefix and honor other CLI switches like tags and tag-groups.

Desktop (please complete the following information):

  • OS: MacOS 14.3.1 (Darwin APL-wfh0x9vmc6 23.3.0 Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000 arm64)
  • Yor Version: yor version 0.1.189

Additional context n/a

jim-weller avatar Mar 08 '24 02:03 jim-weller

More weird combinations

works, just the tag-group for git

  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.189
 Yor Findings Summary
 Scanned Resources:	  1
 New Resources Traced: 	  1
 Updated Resources:	  0

New Resources Traced (1):
+---------+------------------------------------+---------------------------+------------------------------------------+--------+
|  FILE   |              RESOURCE              |          TAG KEY          |                TAG VALUE                 | YOR ID |
+---------+------------------------------------+---------------------------+------------------------------------------+--------+
| main.tf | aws_ssm_parameter.environment_type | TEST_git_repo             | enbl-demo-iac-yor-tagging                |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_org              | HylandSoftware                           |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_modifiers        | jim.weller                               |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_last_modified_by | [email protected]                    |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_last_modified_at | 2024-02-29 15:21:45                      |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_file             | main.tf                                  |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_commit           | 4c39aa9f59024a8d618a77bba5a75f05345058e5 |        |
+---------+------------------------------------+---------------------------+------------------------------------------+--------+

add code2cloud tag-group and it still works

❯ yor tag -d . --tag-prefix "TEST_" --tag-groups git,code2cloud  --dry-run
  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.189
 Yor Findings Summary
 Scanned Resources:	  1
 New Resources Traced: 	  1
 Updated Resources:	  0

New Resources Traced (1):
+---------+------------------------------------+---------------------------+------------------------------------------+--------+
|  FILE   |              RESOURCE              |          TAG KEY          |                TAG VALUE                 | YOR ID |
+---------+------------------------------------+---------------------------+------------------------------------------+--------+
| main.tf | aws_ssm_parameter.environment_type | TEST_yor_trace            | baf4cd53-f627-4f80-9511-bb467ebcc121     |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_yor_name             | environment_type                         |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_repo             | enbl-demo-iac-yor-tagging                |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_org              | HylandSoftware                           |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_modifiers        | jim.weller                               |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_last_modified_by | [email protected]                    |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_last_modified_at | 2024-02-29 15:21:45                      |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_file             | main.tf                                  |        |
+         +                                    +---------------------------+------------------------------------------+--------+
|         |                                    | TEST_git_commit           | 4c39aa9f59024a8d618a77bba5a75f05345058e5 |        |
+---------+------------------------------------+---------------------------+------------------------------------------+--------+

add a tag and it fails

❯ yor tag -d . --tag-prefix "TEST_" --tag-groups git --tags git_repo  --dry-run
  __    __
  \ \  / /
   \ \/ /___  _  ____
    \  /  _ \| |/  __|
    | |  |_| |   /
    |_|\____/|__|v0.1.189
 Yor Findings Summary
 Scanned Resources:	  1
 New Resources Traced: 	  0
 Updated Resources:	  0

jim-weller avatar Mar 08 '24 03:03 jim-weller

It looks like tags and tag-prefix are incompatible. This doesn't work

yor tag -d . --tag-prefix "TEST_" --tags git_repo --dry-run

jim-weller avatar Mar 08 '24 03:03 jim-weller

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Apr 23 '24 02:04 stale[bot]

Merged a fix by @MIRIAM-SLOV. Thank you Miriam.

ChanochShayner avatar Jul 25 '24 07:07 ChanochShayner