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

Setting components on an issue #99

Open
dmlayton opened this issue Sep 25, 2024 · 9 comments
Open

Setting components on an issue #99

dmlayton opened this issue Sep 25, 2024 · 9 comments

Comments

@dmlayton
Copy link

How do I set components on an issue? In the rest interface it would be
"fields": { "components": [{"name": "Xampl"}],, but when I try this, I get told Inappropriate value for attribute "fields": element "components": string required.. The value is appropriate.

@uhgtg
Copy link

uhgtg commented Oct 10, 2024

I do have the same problem. There was an FR to include components, but out of the doc I don't know, how to include them

@dmlayton
Copy link
Author

dmlayton commented Oct 11, 2024 via email

@OneCricketeer
Copy link

If you want to add a component, it would go here - https://github.com/fourplusone/terraform-provider-jira/blob/master/jira/resource_issue.go#L109-L120

@dmlayton
Copy link
Author

If you want to add a component, it would go here - https://github.com/fourplusone/terraform-provider-jira/blob/master/jira/resource_issue.go#L109-L120

Thanks for letting me know where to start. I've setup my local development envrionment (this will be my first time using go in anger).
However, I think components are isomorphic to labels so I'm going to copy-paste https://github.com/fourplusone/terraform-provider-jira/blob/master/jira/resource_issue.go#L143-L147 changing label to component, then do the same for any other blocks I find. Making it simple for a fisrt pass as I don't know what I am looking at.

Any insight into why the code is written this way? I've looked at a lot of go and it never looks DRY and the interfaces are hardcoded for brittleness. For example, why do I even need to do this? Why lines like labels := d.Get("labels")? Why not just get everything, then if it is an array, do the block for handling labels but using the name and not hardcode Labels? It feels silly to just have a bunch of code that is translating one representation of a resource to another handling each attribute in a bespoke way. Feels Java, but maybe this code was codegeneed from a spec, IDK.

@dmlayton
Copy link
Author

Ok so copying the label patterns doesn't work because go-jira defines Components on IssueType as []*Component and Labels as []string meaning a component is an object to the api and labels are just strings.

So I need to find an example of the same or figure it out from how the other objects that are 1:1 (or M:1) with Issues.

@dmlayton
Copy link
Author

Ok so. This may be naive, but what I am going to try is treating components in th same way as labels, but modify the schema elem to be of type jira.Component, then instead of formating each component to a string as labels does, I'll make a jira.Component assuming the input is the ID in the same way project to set on an issue from the input project_key. I'll call the input component_ids.

So you'd set them like:
component_ids = ["${jira_component.example.id}","${jira_component.another_example.id}"]
Nothing about this fels good, but I don't know enough about terrafrom convensions or Go to this of something better and it seems to be the same pattern used elsewhere in the module. Constructive critisicm welcome.

@dmlayton
Copy link
Author

PR submitted.

@dmlayton
Copy link
Author

dmlayton commented Dec 20, 2024

Matbe i'll try tackling the underlying of not being able to do:
fields = { (data.jira_field.components.id) = ["${jira_component.example.id}","${jira_component.another_example.id}"] }
generically for any of the outstanding upsupported fields that are arrays

@OneCricketeer
Copy link

Happy to review next week. Thanks for your patience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants