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

Feature Additon: Contact Group resource and data source #366

Merged
merged 8 commits into from
May 7, 2023

Conversation

leasley199
Copy link
Contributor

Adds the following:

Data Source:

  • Contacts
  • Contact Groups

Resource:

  • Contact Groups

Currently the the contact module has a call out for group_id but no method to get/create the contact group. One would have to hardcode the group_id value. Adds the missing pieces to the provider.

Examples:

# Create contact_group called test department
resource "netbox_contact_group" "main" {
  name = "test department"
}

# Get data of contact_group test department
data "netbox_contact_group" "main" {
  name = "test deparment"
}

# Create netbox_contact with group_id from data.netbox_contact_group
resource "netbox_contact" "main" {
  name = "test contact"
  group_id = data.netbox_contact_group.main.id
}

# Get Data on netbox_contact
data "netbox_contact" "test" {
  name = "Test  Contact"
}

@leasley199
Copy link
Contributor Author

ready for workflow task, tested locally with make testacc and received a successful run.

leasley@optumserve.com added 2 commits March 28, 2023 13:44
@jantari
Copy link

jantari commented Apr 26, 2023

A netbox_contact data source would be really good to have for us so we can assign owners to resources from terraform.

@fbreckle Is there any chance this PR can be moved aloong? Thank you

@fbreckle
Copy link
Collaborator

Well, last time a test failed. This must be fixed. The original author seems to have abandoned the issue, do you want to take it up?

@@ -63,6 +63,7 @@ func Provider() *schema.Provider {
"netbox_cluster_type": resourceNetboxClusterType(),
"netbox_cluster": resourceNetboxCluster(),
"netbox_contact": resourceNetboxContact(),
"netbox_contact_group": resourceNetboxContact(),
Copy link

Choose a reason for hiding this comment

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

I don't have permissions to push to their fork / branch and therefore directly contribute to this PR but what about this?

Suggested change
"netbox_contact_group": resourceNetboxContact(),
"netbox_contact_group": resourceNetboxContactGroup(),

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh right. My bad :D

As for the change you mentioned: Yes, that seems to be wrong, but the tests fail for another reason.

I will look into this MR later (tm).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello, sorry got busy with other items and put this on the back-burn. Yea can't seem to find out why the changes fail testing. If you cowboy it with a live deployment they are succesful..

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't want to tell how long I debugged until I found in wireshark that the HTTP calls are made to /contacts instead of /contact-groups.
Then I was like "damn, I remember this". D'oh! 🙈 :D

Merge is now underway. No clue how the tests suite passes locally.

Fun fact: It does not pass locally if you only run the single test via -run TestAccNetboxContactGroupDataSource_basic to the go test make target.

@fbreckle fbreckle merged commit 30736c3 into e-breuninger:master May 7, 2023
twink0r pushed a commit to twink0r/terraform-provider-netbox that referenced this pull request Sep 15, 2023
…#366)

* Feature Additon: Contact Group resource and data source

* correcting data_source_netbox_contacts schema mapping

* corrected tests, passed locally, ready for github test. Added docs with go generate

* removed data_source_contacts as it was a problem child, corrected data_source_contacts_test. Please pass ci...

* removed data-source-contacts docs

* chore: Fix some names

* chore: Try implicit dependency

* fix: Use correct resource function for contact_group resource

---------

Co-authored-by: leasley@optumserve.com <leasley@optumserve.com>
Co-authored-by: Fabian Breckle <fabian.breckle@breuninger.de>
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.

3 participants