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

New Resource: github_project_column #139

Merged
merged 5 commits into from
Sep 5, 2018

Conversation

shihanng
Copy link
Contributor

Hi, this PR adds the abilities to

  1. manage the projects' columns: github_project_column
  2. maintain the ordering of the columns' positions: github_project_column_positions
    into this provider.

It uses the APIs described in https://developer.github.com/v3/projects/columns/.

I have to admit that github_project_column_positions is a bit odd as it does not really create/destroy any resources on GitHub but only maintains the positions of the columns. I am not sure if this violates the philosophy of Terraform.

Would love to hear what you think about this. Thank you.

Copy link
Contributor

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Hi @shihanng
thanks for this PR.

I'm generally happy to pull github_project_column in as a new resource. I left you some comments to address, but most are just small nitpicks.

Besides my inline comments, I'd greatly appreciate if you could take a brief look at my recent PR and add log messages to C/R/U/D here in a similar fashion.


I do share your feelings about github_project_column_positions.

The main reason why I think it's not a great fit for Terraform is that the definition is relative, so the declaration is not reproducible, in the sense that definition of first, last or after:<column_id> will differ in time which makes the config to produce potentially different results in different environments (with different cards). Also there doesn't seem to be any way to check the current position of a card, so we cannot detect drifts, which is one of the features of Terraform users expect from the tool.

I appreciate the time & effort you spent on the second resource (_positions), but I'm not too inclined to pull that one in, unless you or someone else comes up with a strong reason/argument.

}

projectURL := column.GetProjectURL()
projectID := strings.TrimPrefix(projectURL, "https://api.github.com/projects/")
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it's hard to answer without sufficient documentation or access to GitHub Enterprise instance to test this against, but do you have any idea whether it works with GHE? I reckon the prefix would differ in such case?

How do you feel about leveraging regular expression (e.g. projects/([0-9]+)$) or checking client.BaseURL?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also can't we use the passthrough function here instead and reuse the logic (i.e. move d.Set("project_id") there) in Read() instead? That would save us some LOC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I totally forgot to consider about GitHub Enterprise. b545371 addresses this comment. I've decided to use BaseURL to extract the project ID and move the logic to read. Thank you.

if err != nil {
if resp != nil && resp.StatusCode == 404 {
d.SetId("")
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you mind using github.ErrorResponse instead of reading response and/or more generally following what I did here just for consistency?
😉

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix in b5dcbb6, thank you.


# github_repository_project

This resource allows you to create and manage project columns for Github projects.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: I'd leave out the first "project" to avoid the repetition, i.e.

This resource allows you to create and manage columns of GitHub projects.

Also please note the capital H in GitHub. 😉

page_title: "GitHub: github_project_column"
sidebar_current: "docs-github-resource-project-column"
description: |-
Creates and manages project columns for Github projects
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: GitHub (capital H)


The following arguments are supported:

* `project_id` - (Required) The id of an exisiting project that the column will be created in.
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo - exisiting -> existing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you 😅. Fix in 756292e.

github/resource_github_project_column.go Show resolved Hide resolved
@ghost ghost added the size/XL label Sep 4, 2018
@shihanng
Copy link
Contributor Author

shihanng commented Sep 4, 2018

Hi @radeksimko, I've addressed your comments. Thank you so much for your time. As for github_project_column_positions, I have no strong opinion on this and don't mind at all if it is not merged. I believe that all the codes for github_project_column_positions are in separate commits from the github_project_column:

I can remove/revert those if you want.

@ghost ghost added size/L and removed size/XL labels Sep 5, 2018
@radeksimko
Copy link
Contributor

@shihanng Thank you for making those changes, I squashed some commits to make the log a bit cleaner and I also removed the second _position resource as discussed.
Finally I added etag field in the spirit of https://github.com/terraform-providers/terraform-provider-github/pull/143

@radeksimko radeksimko merged commit d2ecb24 into integrations:master Sep 5, 2018
@radeksimko radeksimko changed the title New Resource: github_project_column and github_project_column_positions New Resource: github_project_column Sep 5, 2018
kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
New Resource: github_project_column and github_project_column_positions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants