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

Add Section and Vlan import feature #88

Merged
merged 1 commit into from
May 15, 2024

Conversation

peterbaumert
Copy link
Contributor

I'm neither a go expert nor an terraform expert. I simply copied and edited from other files so please check :)

@peterbaumert peterbaumert mentioned this pull request Mar 25, 2024
@pavel-z1
Copy link
Collaborator

Hi @peterbaumert
Thanks for reporting the problem with importing VLAN and Section resources

Currently this PR has errors during build:

plugin/providers/phpipam/data_source_phpipam_section.go:49:23: undefined: strconv
plugin/providers/phpipam/data_source_phpipam_section.go:53:7: invalid operation: cannot index out (variable of type sections.Section)
plugin/providers/phpipam/data_source_phpipam_vlan.go:54:20: undefined: strconv
plugin/providers/phpipam/data_source_phpipam_vlan.go:58:7: invalid operation: cannot index out (variable of type vlans.VLAN)

To fix errors make this changes:

index 3b4add74..23685932 100644
--- a/plugin/providers/phpipam/data_source_phpipam_vlan.go
+++ b/plugin/providers/phpipam/data_source_phpipam_vlan.go
@@ -2,6 +2,7 @@ package phpipam

 import (
        "errors"
+       "strconv"

        "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
        "github.com/pavel-z1/phpipam-sdk-go/controllers/vlans"
@@ -55,7 +56,7 @@ func dataSourcePHPIPAMVLANRead(d *schema.ResourceData, meta interface{}) error {
                        if err != nil {
                                return err
                        }
-                       out[0], err = c.GetVLANByID(vlan_id)
+                       out, err = c.GetVLANByID(vlan_id)
                        if err != nil {
                                return err
                        }
index a2f8fb0d..5c9674dc 100644
--- a/plugin/providers/phpipam/data_source_phpipam_section.go
+++ b/plugin/providers/phpipam/data_source_phpipam_section.go
@@ -4,6 +4,7 @@ import (
        "errors"
        "log"
        "strings"
+       "strconv"

        "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
        "github.com/pavel-z1/phpipam-sdk-go/controllers/sections"
@@ -50,7 +51,7 @@ func dataSourcePHPIPAMSectionRead(d *schema.ResourceData, meta interface{}) erro
                        if err != nil {
                                return err
                        }
-                       out[0], err = c.GetSectionByID(section_id)
+                       out, err = c.GetSectionByID(section_id)
                        if err != nil {
                                return err
                        }

Also, please rebase commits in this PR to the single commit.

@pavel-z1 pavel-z1 self-assigned this Mar 26, 2024
@pavel-z1 pavel-z1 self-requested a review March 26, 2024 08:20
Update data_source_phpipam_section.go as suggested by pavel-z1
Update data_source_phpipam_vlan.go as suggested by pavel-z1
@peterbaumert
Copy link
Contributor Author

@pavel-z1 added your changed and did a single commit.

@peterbaumert
Copy link
Contributor Author

would you mind having a look at this @pavel-z1 ?

@pavel-z1
Copy link
Collaborator

Hi @peterbaumert
I am waiting for previous PR (#86) first to accept this

Copy link

@nullck nullck left a comment

Choose a reason for hiding this comment

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

LGTM

@pavel-z1 pavel-z1 merged commit 118f086 into lord-kyron:master May 15, 2024
@peterbaumert
Copy link
Contributor Author

Ty @pavel-z1 could you also generate a new release?

@lord-kyron
Copy link
Owner

@peterbaumert I will generate a new release when the last 3 pull requests currently pending get approved and merged.

@peterbaumert
Copy link
Contributor Author

Okay sounds good. Thanks for the info!

@peterbaumert peterbaumert deleted the patch-1 branch May 19, 2024 14:32
@peterbaumert
Copy link
Contributor Author

@lord-kyron could you generate the release? :)

@lord-kyron
Copy link
Owner

@peterbaumert new release was generated. Enjoy!

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.

4 participants