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_repository_autolink_reference #924

Merged
merged 3 commits into from
Oct 17, 2021
Merged

New resource github_repository_autolink_reference #924

merged 3 commits into from
Oct 17, 2021

Conversation

relusc
Copy link
Contributor

@relusc relusc commented Oct 6, 2021

This PR adds a new resource github_repository_autolink_reference. Supports creation and deletion, in-place updates are not possible for autolink references afaik.

This is my first time working on a Terraform provider, so sorry if I missed something :)

Fixes #285

Example usage:

resource "github_repository" "repo" {
  name           = "xyz"
}

resource "github_repository_autolink_reference" "auto" {
  repository = github_repository.repo.name

  key_prefix = "TICKET-"

  target_url_template = "https://hello.there/TICKET?query=<num>"
}

}

resource "github_repository_autolink_reference" "autolink" {
depends_on = ["github_repository.off"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be

Suggested change
depends_on = ["github_repository.off"]
depends_on = ["github_repository.oof"]

everywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, true. Good catch, has been updated with the latest commit

Copy link
Contributor

Choose a reason for hiding this comment

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

I was about to start to implement this, then found your PR, so I thought I'd help with some code review... Hopefully the maintainers will bless it soon.

@jcudit jcudit added this to the v4.17.0 milestone Oct 17, 2021
@jcudit jcudit merged commit 534f002 into integrations:main Oct 17, 2021
@relusc relusc deleted the add-autolink-ref branch October 18, 2021 05:06
Comment on lines +22 to +32
Importer: &schema.ResourceImporter{
State: func(d *schema.ResourceData, meta interface{}) ([]*schema.ResourceData, error) {
parts := strings.Split(d.Id(), "/")
if len(parts) != 2 {
return nil, fmt.Errorf("Invalid ID specified. Supplied ID must be written as <repository>/<autolink_reference_id>")
}
d.Set("repository", parts[0])
d.SetId(parts[1])
return []*schema.ResourceData{d}, nil
},
},

Choose a reason for hiding this comment

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

Should we allow to import by <repository>/<key-prefix> instead / as well? That's gonna make it much easier to import... Now the API must be called to get the id while everyone will have the key-prefix probably

#947

kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
* Add resource github_repository_autolink_reference

* Add resource to provider main file

* Use correct resource name, thanks to @mrwacky42
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

Successfully merging this pull request may close these issues.

Feature request: Autolink references
4 participants