Skip to content

Commit

Permalink
Merge branch 'master' into mybranch
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmayb committed Oct 11, 2017
2 parents 8885b58 + 80793a9 commit cebd5a3
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
23 changes: 23 additions & 0 deletions objects.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,29 @@ func NewRecordCNAME(rc RecordCNAME) *RecordCNAME {
return &res
}

type RecordHostIpv4Addr struct {
Ipv4Addr string `json:"ipv4addr,omitempty"`
}

type RecordHost struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Ipv4Addr string `json:"ipv4addr,omitempty"`
Ipv4Addrs []RecordHostIpv4Addr `json:"ipv4addrs,omitempty"`
Name string `json:"name,omitempty"`
View string `json:"view,omitempty"`
Zone string `json:"zone,omitempty"`
Ea EA `json:"extattrs,omitempty"`
}

func NewRecordHost(rh RecordHost) *RecordHost {
res := rh
res.objectType = "record:host"
res.returnFields = []string{"extattrs", "ipv4addrs", "name", "view", "zone"}

return &res
}

type RecordTXT struct {
IBBase `json:"-"`
Ref string `json:"_ref,omitempty"`
Expand Down
25 changes: 25 additions & 0 deletions objects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,31 @@ var _ = Describe("Objects", func() {
})
})

Context("RecordHost object", func() {
ipv4addrs := []RecordHostIpv4Addr{{Ipv4Addr: "1.1.1.1"}, {Ipv4Addr: "2.2.2.2"}}
name := "bind_host.domain.com"
view := "default"
zone := "domain.com"

rh := NewRecordHost(RecordHost{
Ipv4Addrs: ipv4addrs,
Name: name,
View: view,
Zone: zone})

It("should set fields correctly", func() {
Expect(rh.Ipv4Addrs).To(Equal(ipv4addrs))
Expect(rh.Name).To(Equal(name))
Expect(rh.View).To(Equal(view))
Expect(rh.Zone).To(Equal(zone))
})

It("should set base fields correctly", func() {
Expect(rh.ObjectType()).To(Equal("record:host"))
Expect(rh.ReturnFields()).To(ConsistOf("extattrs", "ipv4addrs", "name", "view", "zone"))
})
})

Context("RecordTXT object", func() {
name := "txt.domain.com"
text := "this is text string"
Expand Down

0 comments on commit cebd5a3

Please sign in to comment.