Skip to content

Commit

Permalink
fix(state) drop index on target.Target (#280)
Browse files Browse the repository at this point in the history
target.Target represents an IP address or a DNS name in Kong. These can
be same across different Upstreams.
Drop the unique index on Target resource for this reason.

This is similar to the fix applies to ServiceVersion resource in
cf44212.

The test has been updated to remove insertion of Upstream which doesn't
add in value.

Fix #233
  • Loading branch information
hbagdi committed Mar 8, 2021
1 parent 99f3a84 commit a640f10
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
11 changes: 0 additions & 11 deletions state/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ var targetTableSchema = &memdb.TableSchema{
Unique: true,
Indexer: &memdb.StringFieldIndex{Field: "ID"},
},
"target": {
Name: "target",
Indexer: &indexers.SubFieldIndexer{
Fields: []indexers.Field{
{
Struct: "Target",
Sub: "Target",
},
},
},
},
all: allIndex,
// foreign
targetsByUpstreamID: {
Expand Down
12 changes: 2 additions & 10 deletions state/target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ func TestTargetsInvalidType(t *testing.T) {

collection := targetsCollection()

var upstream Upstream
upstream.Name = kong.String("my-upstream")
upstream.ID = kong.String("first")
txn := collection.db.Txn(true)
err := txn.Insert(targetTableName, &upstream)
assert.NotNil(err)
txn.Abort()

type badTarget struct {
kong.Target
Meta
Expand All @@ -145,8 +137,8 @@ func TestTargetsInvalidType(t *testing.T) {
},
}

txn = collection.db.Txn(true)
err = txn.Insert(targetTableName, &target)
txn := collection.db.Txn(true)
err := txn.Insert(targetTableName, &target)
assert.Nil(err)
txn.Commit()

Expand Down

0 comments on commit a640f10

Please sign in to comment.