Skip to content

Commit

Permalink
fixing PR suggestions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmurret committed Jun 3, 2024
1 parent bc56a59 commit edd0f73
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
15 changes: 4 additions & 11 deletions dependency/dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,24 +236,17 @@ func (c *ClientSet) createConsulSamenessGroups(name, partition, failoverPartitio
Partition: failoverPartition,
})
sg := &api.SamenessGroupConfigEntry{
Kind: QuerySamenessGroup,
Kind: api.SamenessGroup,
Name: name,
Partition: partition,
DefaultForFailover: true,
Members: members,
}
log.Printf("sameness group: %+v", sg)
_, _, err := c.consul.client.ConfigEntries().Set(sg, &api.WriteOptions{})
if err != nil {
return err
}

sgs, _, err := c.consul.client.ConfigEntries().List(QuerySamenessGroup, &api.QueryOptions{})
if err != nil {
return err
}
log.Printf("sameness groups: %+v", sgs)

return nil
}

Expand Down Expand Up @@ -563,9 +556,9 @@ func (v *nomadServer) DeleteVariable(path string, opts *nomadapi.WriteOptions) e
func (c *ClientSet) createConsulPartitions() error {
for p := range tenancyHelper.GetUniquePartitions() {
if p.Name != "" && p.Name != "default" {
err2 := c.createConsulPartition(p.Name)
if err2 != nil {
return err2
err := c.createConsulPartition(p.Name)
if err != nil {
return err
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions dependency/health_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ func healthServiceQuery(s string, connect bool) (*HealthServiceQuery, error) {
return nil, err
}

if queryParams.Get(QuerySamenessGroup) != "" && queryParams.Get(QueryPeer) != "" {
return nil, fmt.Errorf("health.service: cannot specify both peer and sameness-group")
}

qry := &HealthServiceQuery{
stopCh: make(chan struct{}, 1),
dc: m["dc"],
Expand All @@ -138,10 +142,6 @@ func healthServiceQuery(s string, connect bool) (*HealthServiceQuery, error) {
samenessGroup: queryParams.Get(QuerySamenessGroup),
}

if qry.samenessGroup != "" && qry.peer != "" {
return nil, fmt.Errorf("health.service: cannot specify both peer and sameness-group")
}

return qry, nil
}

Expand Down
2 changes: 1 addition & 1 deletion dependency/health_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ func TestHealthServiceQuery_Fetch_SamenessGroup(t *testing.T) {
require.NoError(t, testClients.createConsulPartition(partitionTwo))
require.NoError(t, testClients.createConsulSamenessGroups(samenessGroup, partitionOne, partitionTwo))

// Register services in foo partition as critical so they will fall back to default partition service
// Register services with the same name in partionOne and partitionTwo and them to a sameness group so that we can test failover.
svcName := "sameness-group-service"
registerSvc := func(service, node, partition, status string) {
checkName := fmt.Sprintf("%s:%s", service, node)
Expand Down
4 changes: 4 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ module github.com/hashicorp/consul-template

go 1.22

// used to test locally
replace (
github.com/hashicorp/consul/api => ../consul/api
)
require (
dario.cat/mergo v1.0.0
github.com/BurntSushi/toml v1.3.2
Expand Down

0 comments on commit edd0f73

Please sign in to comment.