Skip to content

Commit 852468c

Browse files
authored
Improve logging around deployments (#315)
1 parent 3e3883f commit 852468c

File tree

5 files changed

+11
-6
lines changed

5 files changed

+11
-6
lines changed

internal/client/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ func (c *CSAPI) DoFunc(t *testing.T, method string, paths []string, opts ...Requ
440440
}
441441
// debug log the request
442442
if c.Debug {
443-
t.Logf("Making %s request to %s", method, req.URL)
443+
t.Logf("Making %s request to %s (%s)", method, req.URL, c.AccessToken)
444444
contentType := req.Header.Get("Content-Type")
445445
if contentType == "application/json" || strings.HasPrefix(contentType, "text/") {
446446
if req.Body != nil {

internal/config/config.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type Complement struct {
3838
CAPrivateKey *rsa.PrivateKey
3939
}
4040

41-
func NewConfigFromEnvVars() *Complement {
41+
func NewConfigFromEnvVars(pkgNamespace string) *Complement {
4242
cfg := &Complement{}
4343
cfg.BaseImageURI = os.Getenv("COMPLEMENT_BASE_IMAGE")
4444
cfg.BaseImageArgs = strings.Split(os.Getenv("COMPLEMENT_BASE_IMAGE_ARGS"), " ")
@@ -62,12 +62,15 @@ func NewConfigFromEnvVars() *Complement {
6262
if cfg.BaseImageURI == "" {
6363
panic("COMPLEMENT_BASE_IMAGE must be set")
6464
}
65-
cfg.PackageNamespace = "pkg"
65+
cfg.PackageNamespace = pkgNamespace
6666

6767
// create CA certs and keys
6868
if err := cfg.GenerateCA(); err != nil {
6969
panic("Failed to generate CA certificate/key: " + err.Error())
7070
}
71+
if cfg.PackageNamespace == "" {
72+
panic("package namespace must be set")
73+
}
7174

7275
return cfg
7376
}

internal/docker/builder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,9 @@ func createNetworkIfNotExists(docker *client.Client, pkgNamespace, blueprintName
390390
}
391391
// return the existing network
392392
if len(nws) > 0 {
393+
if len(nws) > 1 {
394+
log.Printf("WARNING: createNetworkIfNotExists got %d networks for pkg=%s blueprint=%s", len(nws), pkgNamespace, blueprintName)
395+
}
393396
return nws[0].ID, nil
394397
}
395398
// make a user-defined network so we get DNS based on the container name

tests/csapi/main_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ var complementBuilder *docker.Builder
2727
// It will clean up any old containers/images/networks from the previous run, then run the tests, then clean up
2828
// again. No blueprints are made at this point as they are lazily made on demand.
2929
func TestMain(m *testing.M) {
30-
cfg := config.NewConfigFromEnvVars()
31-
cfg.PackageNamespace = "csapi"
30+
cfg := config.NewConfigFromEnvVars("csapi")
3231
log.Printf("config: %+v", cfg)
3332
builder, err := docker.NewBuilder(cfg)
3433
if err != nil {

tests/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var complementBuilder *docker.Builder
2727
// It will clean up any old containers/images/networks from the previous run, then run the tests, then clean up
2828
// again. No blueprints are made at this point as they are lazily made on demand.
2929
func TestMain(m *testing.M) {
30-
cfg := config.NewConfigFromEnvVars()
30+
cfg := config.NewConfigFromEnvVars("fed")
3131
log.Printf("config: %+v", cfg)
3232
builder, err := docker.NewBuilder(cfg)
3333
if err != nil {

0 commit comments

Comments
 (0)