Skip to content
This repository has been archived by the owner on Jan 21, 2022. It is now read-only.

Commit

Permalink
Merge 0848747 into 7b3048c
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Wu committed Apr 2, 2015
2 parents 7b3048c + 0848747 commit 11a3d2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cfcomponent/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/cloudfoundry/gosteno"
"github.com/cloudfoundry/loggregatorlib/cfcomponent/auth"
"github.com/cloudfoundry/loggregatorlib/cfcomponent/instrumentation"
uuid "github.com/nu7hatch/gouuid"
"github.com/pivotal-golang/localip"
"net/http"
)
Expand Down Expand Up @@ -42,6 +43,11 @@ func NewComponent(logger *gosteno.Logger, componentType string, index uint, heat
}
}

uuid, err := uuid.NewV4()
if err != nil {
return Component{}, err
}

if len(statusCreds) == 0 || statusCreds[username] == "" || statusCreds[password] == "" {
randUser := make([]byte, 42)
randPass := make([]byte, 42)
Expand All @@ -59,6 +65,7 @@ func NewComponent(logger *gosteno.Logger, componentType string, index uint, heat
IpAddress: ip,
Type: componentType,
Index: index,
UUID: uuid.String(),
HealthMonitor: heathMonitor,
StatusPort: statusPort,
StatusCredentials: statusCreds,
Expand Down
6 changes: 6 additions & 0 deletions cfcomponent/component_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ func TestStatusCredentialsDefault(t *testing.T) {
assert.NotEmpty(t, credentials[1])
}

func TestGUID(t *testing.T) {
component, err := NewComponent(loggertesthelper.Logger(), "loggregator", 0, GoodHealthMonitor{}, 0, []string{"", ""}, nil)
assert.NoError(t, err)
assert.NotEmpty(t, component.UUID)
}

func TestGoodHealthzEndpoint(t *testing.T) {
component := &Component{
Logger: loggertesthelper.Logger(),
Expand Down

0 comments on commit 11a3d2b

Please sign in to comment.