Skip to content

Commit

Permalink
feat(upstream) add Algorithm field to Upstream struct
Browse files Browse the repository at this point in the history
Kong 1.3 adds an `algorithm` field to the Upstream entity.

From #9
  • Loading branch information
hbagdi authored Aug 9, 2019
1 parent 10ecfd0 commit 6afaf06
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions kong/upstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Healthcheck struct {
type Upstream struct {
ID *string `json:"id,omitempty" yaml:"id,omitempty"`
Name *string `json:"name,omitempty" yaml:"name,omitempty"`
Algorithm *string `json:"algorithm,omitempty" yaml:"algorithm,omitempty"`
Slots *int `json:"slots,omitempty" yaml:"slots,omitempty"`
Healthchecks *Healthcheck `json:"healthchecks,omitempty" yaml:"healthchecks,omitempty"`
CreatedAt *int64 `json:"created_at,omitempty" yaml:"created_at,omitempty"`
Expand Down
22 changes: 22 additions & 0 deletions kong/upstream_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,28 @@ func TestUpstreamWithPassiveUnHealthyInterval(T *testing.T) {
assert.Nil(createdUpstream)
}

func TestUpstreamWithAlgorithm(T *testing.T) {
runWhenKong(T, ">=1.3.0")
assert := assert.New(T)

client, err := NewClient(nil, nil)
assert.Nil(err)
assert.NotNil(client)

upstream := &Upstream{
Name: String("upstream1"),
Algorithm: String("least-connections"),
}

createdUpstream, err := client.Upstreams.Create(defaultCtx, upstream)
assert.Nil(err)
assert.NotNil(createdUpstream)
assert.Equal("least-connections", *createdUpstream.Algorithm)

err = client.Upstreams.Delete(defaultCtx, createdUpstream.ID)
assert.Nil(err)
}

func TestUpstreamListEndpoint(T *testing.T) {
assert := assert.New(T)

Expand Down
5 changes: 5 additions & 0 deletions kong/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6afaf06

Please sign in to comment.