Skip to content

Commit

Permalink
Upgrade Go version to 1.21+ and add support for new object (#237)
Browse files Browse the repository at this point in the history
* [ADD] Support zone_forward DNS object

* [IMP] Updated Go Version to support 1.21 and above with updating dependent libs.

* added E2E test cases for Forward zone. (#232)

* added unit test cases for Forward zone. (#234)

* updated go version for travis CI run (#236)

* Add release notes and changelog (#235)

* Add release notes and changelog

* Update CHANGELOG.md

---------

Co-authored-by: Aish-sp <[email protected]>
Co-authored-by: Jaykumar Chhatbar <[email protected]>
  • Loading branch information
3 people authored Jun 20, 2024
1 parent b3db346 commit 0e7c3b2
Show file tree
Hide file tree
Showing 386 changed files with 24,086 additions and 8,809 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: go

go:
- 1.15
- 1.21

env:
- GO111MODULE=auto
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Infoblox Go Client Release Notes

## v2.7.0

### Release Summary

- Create, Update, Delete and Get operations for zone-forward record is being added.

### Major Changes

- Upgraded go version from 1.17 to 1.21
- Added Create, Update and Delete operations for zone-forward record.
- Added `GetZoneForwardByRef` function to fetch zone-forward record by reference.
- Added `GetZoneForwardFilters` function to fetch all zone-forward records with the given filters.
- Added wrapper structs `NullableForwardingServers` and `NullForwardTo` to handle omitempty fields `Forwardingmemberserver` and `ForwardTo` of ZoneForward struct.

## v2.6.0

### Release Summary
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ This library is compatible with Go 1.2+


## Prerequisites
* Infoblox GRID with 2.5 or above WAPI support
* Go 1.2 or above
* Infoblox GRID with 2.9 or above WAPI support
* Go 1.21 or above

## Installation
To get the latest released version [v2.6.0](https://github.com/infobloxopen/infoblox-go-client/releases/tag/v2.6.0) of Go Client use below command.
To get the latest released version [v2.7.0](https://github.com/infobloxopen/infoblox-go-client/releases/tag/v2.7.0) of Go Client use below command.

`go get github.com/infobloxopen/infoblox-go-client/v2`

Expand Down Expand Up @@ -74,6 +74,7 @@ This library is compatible with Go 1.2+
* CreateZoneAuth
* CreateCNAMERecord
* CreateDefaultNetviews
* CreateZoneForward
* CreateEADefinition
* CreateHostRecord
* CreateNetwork
Expand All @@ -85,6 +86,7 @@ This library is compatible with Go 1.2+
* DeleteARecord
* DeleteAAAARecord
* DeleteZoneAuth
* DeleteZoneForward
* DeleteCNAMERecord
* DeleteFixedAddress
* DeleteHostRecord
Expand Down Expand Up @@ -125,6 +127,8 @@ This library is compatible with Go 1.2+
* GetZoneDelegated
* GetUpgradeStatus (2.7 or above)
* GetAllMembers
* GetZoneForwardByRef
* GetZoneForwardFilters
* GetGridInfo
* GetGridLicense
* ReleaseIP
Expand All @@ -141,5 +145,6 @@ This library is compatible with Go 1.2+
* UpdateTXTRecord
* UpdateARecord
* UpdateZoneDelegated
* UpdateZoneForward


250 changes: 250 additions & 0 deletions e2e_tests/wapi_framework_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2086,3 +2086,253 @@ var _ = Describe("Go Client", func() {
Expect(err).To(MatchError(ibclient.NewNotFoundError("requested object not found")))
})
})

var _ = Describe("DNS Forward Zone", func() {
var connector *ConnectorFacadeE2E

BeforeEach(func() {
hostConfig := ibclient.HostConfig{
Host: os.Getenv("INFOBLOX_SERVER"),
Version: os.Getenv("WAPI_VERSION"),
Port: os.Getenv("PORT"),
}

authConfig := ibclient.AuthConfig{
Username: os.Getenv("INFOBLOX_USERNAME"),
Password: os.Getenv("INFOBLOX_PASSWORD"),
}

transportConfig := ibclient.NewTransportConfig("false", 20, 10)
requestBuilder := &ibclient.WapiRequestBuilder{}
requestor := &ibclient.WapiHttpRequestor{}
ibclientConnector, err := ibclient.NewConnector(hostConfig, authConfig, transportConfig, requestBuilder, requestor)
Expect(err).To(BeNil())
connector = &ConnectorFacadeE2E{*ibclientConnector, make([]string, 0)}
})

AfterEach(func() {
err := connector.SweepObjects()
Expect(err).To(BeNil())
})

It("Should create a DNS Forward Zone", func() {
// Create a DNS Forward Zone
zone := &ibclient.ZoneForward{
Fqdn: "example.com",
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "2.3.4.5"},
},
IsNull: false,
},
}
ref, err := connector.CreateObject(zone)
Expect(err).To(BeNil())
Expect(ref).To(MatchRegexp("^zone_forward.*"))
})

It("Should create a DNS Forward Zone with all params", func() {
// Create a DNS Forward Zone
zone := &ibclient.ZoneForward{
Fqdn: "example.com",
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "2.3.4.5"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
ForwardersOnly: utils.BoolPtr(true),
ForwardingServers: &ibclient.NullableForwardingServers{
[]*ibclient.Forwardingmemberserver{
{
Name: "infoblox.localdomain",
ForwardersOnly: true,
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "2.3.4.5"},
},
IsNull: false,
},
UseOverrideForwarders: false,
}},
false,
},
}
ref, err := connector.CreateObject(zone)
Expect(err).To(BeNil())
Expect(ref).To(MatchRegexp("^zone_forward.*"))
})

It("Should get the DNS Forward Zone", func() {
zone := &ibclient.ZoneForward{
Fqdn: "example.com",
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "2.3.4.5"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
}
ref, err := connector.CreateObject(zone)
Expect(err).To(BeNil())
Expect(ref).To(MatchRegexp("^zone_forward.*"))

var res []ibclient.ZoneForward
search := &ibclient.ZoneForward{}
errCode := connector.GetObject(search, "", nil, &res)
Expect(errCode).To(BeNil())
Expect(res[0].Ref).To(MatchRegexp("^zone_forward.*"))
})

It("Should update the DNS Forward Zone", func() {
// Create a DNS Forward Zone
zoneCreate := &ibclient.ZoneForward{
Fqdn: "example.com",
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "1.2.3.5"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
}
ref, errCode := connector.CreateObject(zoneCreate)
Expect(errCode).To(BeNil())
Expect(ref).To(MatchRegexp("^zone_forward.*"))

// Update a DNS Forward Zone
zone := &ibclient.ZoneForward{
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "1.2.3.6"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
}

var res []ibclient.ZoneForward
search := &ibclient.ZoneForward{}
err := connector.GetObject(search, "", nil, &res)
ref, err = connector.UpdateObject(zone, res[0].Ref)
Expect(err).To(BeNil())
Expect(ref).To(MatchRegexp("^zone_forward.*"))
})

It("Should delete the DNS Forward Zone", func() {
// Create a DNS Forward Zone
zoneCreate := &ibclient.ZoneForward{
Fqdn: "example.com",
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "1.2.3.5"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
}
refCreate, errCode := connector.CreateObject(zoneCreate)
Expect(errCode).To(BeNil())
Expect(refCreate).To(MatchRegexp("^zone_forward.*"))

var res []ibclient.ZoneForward
search := &ibclient.ZoneForward{}
err := connector.GetObject(search, "", nil, &res)
ref, err := connector.DeleteObject(res[0].Ref)
Expect(err).To(BeNil())
Expect(ref).To(MatchRegexp("^zone_forward.*"))
})

It("Should fail to create a DNS Forward Zone with invalid data", func() {
zone := &ibclient.ZoneForward{
Fqdn: "invalid..com", // Invalid FQDN
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "1.2.3.5"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
ForwardersOnly: utils.BoolPtr(true),
}
_, err := connector.CreateObject(zone)
Expect(err).NotTo(BeNil())
})

It("Should fail to get a non-existent DNS Forward Zone", func() {
var res []ibclient.ZoneForward
search := &ibclient.ZoneForward{Fqdn: "nonexistent.com"}
err := connector.GetObject(search, "", nil, &res)
Expect(err).NotTo(BeNil())
})

It("Should fail to update a non-existent DNS Forward Zone", func() {
zone := &ibclient.ZoneForward{
Fqdn: "nonexistent.com",
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "1.2.3.6"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
}

_, err := connector.UpdateObject(zone, "nonexistent_ref")
Expect(err).NotTo(BeNil())
})

It("Should fail to delete a non-existent DNS Forward Zone", func() {
_, err := connector.DeleteObject("nonexistent_ref")
Expect(err).NotTo(BeNil())
})

It("Should fail to create a DNS Forward Zone without mandatory parameters", func() {
zone := &ibclient.ZoneForward{
// Missing mandatory parameters like Fqdn and ForwardTo
Comment: utils.StringPtr("wapi added"),
ForwardersOnly: utils.BoolPtr(true),
}
_, err := connector.CreateObject(zone)
Expect(err).NotTo(BeNil())
})

It("Should fail to create a DNS Forward Zone without fqdn parameter", func() {
zone := &ibclient.ZoneForward{
// Missing mandatory parameter Fqdn
ForwardTo: ibclient.NullForwardTo{
ForwardTo: []ibclient.NameServer{
{Name: "test", Address: "1.2.3.4"},
{Name: "test2", Address: "1.2.3.5"},
},
IsNull: false,
},
Comment: utils.StringPtr("wapi added"),
ForwardersOnly: utils.BoolPtr(true),
}
_, err := connector.CreateObject(zone)
Expect(err).NotTo(BeNil())
})

It("Should fail to create a DNS Forward Zone without forward_to parameter", func() {
zone := &ibclient.ZoneForward{
// Missing mandatory parameter ForwardTo
Fqdn: "example.com",
Comment: utils.StringPtr("wapi added"),
ForwardersOnly: utils.BoolPtr(true),
}
_, err := connector.CreateObject(zone)
Expect(err).NotTo(BeNil())
})
})
13 changes: 6 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
module github.com/infobloxopen/infoblox-go-client/v2

go 1.17
go 1.21

require (
github.com/onsi/ginkgo/v2 v2.1.4
github.com/onsi/gomega v1.19.0
github.com/sirupsen/logrus v1.8.0
golang.org/x/net v0.7.0
github.com/sirupsen/logrus v1.9.3
golang.org/x/net v0.24.0
)

require (
github.com/magefile/mage v1.10.0 // indirect
github.com/stretchr/testify v1.5.1 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
github.com/stretchr/testify v1.8.4 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Loading

0 comments on commit 0e7c3b2

Please sign in to comment.