tofu-controller icon indicating copy to clipboard operation
tofu-controller copied to clipboard

Branch planner not showing workspace

Open eloo-abi opened this issue 2 years ago • 6 comments

Hi,

i just testing the branch planner feature and discovered that the reported plan nor the PR comment itself is having reference to the workspace used.

This makes it pretty hard to determine which change is relevant for what environment.

image

i would suggest to have at least the following information added to the comments:

  • name of the terraform k8s resource
  • workspace from the terraform k8s resource
  • path from the terraform k8s resource

Thanks

eloo-abi avatar Sep 13 '23 12:09 eloo-abi

Thank you @eloo-abi for your suggestion.

Would you mind drafting the output you'd like to see as a simple code block here?

chanwit avatar Sep 13 '23 12:09 chanwit

tf-controller plan output:

context:

  • namespace: flux-system
  • name: jowe-tf-controller-test
  • approvePlan: auto
  • path: ./
  • workspace: default

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:

  # local_file.changeme_local_file_hello will be created
  + resource "local_file" "changeme_local_file_hello" {
      + content              = "Hello terraform local!"
      + content_base64sha256 = (known after apply)
      + content_base64sha512 = (known after apply)
      + content_md5          = (known after apply)
      + content_sha1         = (known after apply)
      + content_sha256       = (known after apply)
      + content_sha512       = (known after apply)
      + directory_permission = "0777"
      + file_permission      = "0777"
      + filename             = "./changeme_local_file_hello_default.txt456"
      + id                   = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

To apply this plan, please merge this pull request.

eloo-abi avatar Sep 13 '23 12:09 eloo-abi

maybe something like this?

eloo-abi avatar Sep 13 '23 12:09 eloo-abi

Got it. That was helpful.

So they are basically some information from the original TF resource.

chanwit avatar Sep 13 '23 12:09 chanwit

yes exactly.. so its just clear what is going to be changed..

the same of course applies to the notification.. at least the resource name is added in the notification already terraform/jowe-tf-controller-test-workspace-test.flux-system

eloo-abi avatar Sep 13 '23 12:09 eloo-abi

We have a similar requirement to be able to show additional information in the PR comment as we have multiple terraform resources that are posting PR comments to a single PR and it is difficult to tell which terraform resource the comments relate to.

It would also be useful to be able to make the customization of the template configurable either then a command line argument or environment variable.

It would also be really useful to be able to access other notable plan information in the template rather than just the whole content of the plan output. In particular this sort of struct would be very useful e.g.

type Plan strict {
	Output          string
	TotalAdd        int
	TotalChange     int
	TotalDestory    int
	AddResources    []string // all resource names that are being added
	ChangeResources []string // all resource names that are being changed
	DestoryResource []string // all resource names that are being destroyed
}

This would be particularly useful for large plan outputs that can be hard to read and just present a summary.

dwalker-sabiogroup avatar Sep 28 '23 09:09 dwalker-sabiogroup