Skip to content

Commit

Permalink
Merge pull request #87 from buildpacks/jkutner/debug
Browse files Browse the repository at this point in the history
Add more logging to help determine cause of Github 409
  • Loading branch information
jkutner authored Nov 1, 2021
2 parents 90c778f + e95fa46 commit 117bbe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion registry/verify-namespace-owner/verify_namespace_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func getNamespace(tk toolkit.Toolkit, c config, user github.User, repositories s
return namespace.Namespace{}, toolkit.FailedErrorf("unable to decode namespace\n%w", err)
}

tk.Debugf("creating new namespace: %s\n%s", file, b)
if _, resp, err := repositories.CreateFile(context.Background(), c.Owner, c.Repository, file, &github.RepositoryContentFileOptions{
Author: &github.CommitAuthor{
Name: github.String("buildpacks-bot"),
Expand All @@ -142,9 +143,10 @@ func getNamespace(tk toolkit.Toolkit, c config, user github.User, repositories s
Message: github.String(fmt.Sprintf("New Namespace: %s", c.Namespace)),
Content: b,
}); resp != nil && resp.StatusCode == http.StatusConflict {
tk.Warning("retrying namespace update after conflict")
tk.Warningf("retrying namespace update after conflict: %s", file)
continue
} else if err != nil {
tk.Errorf("unable to create namespace: %s", file)
return namespace.Namespace{}, toolkit.FailedErrorf("unable to create namespace\n%w", err)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func TestVerifyNamespaceOwner(t *testing.T) {
}

it.Before(func() {
tk.On("Debugf", mock.Anything, mock.Anything, mock.Anything).Return()
tk.On("GetInput", "owner").Return("test-owner", true)
tk.On("GetInput", "repository").Return("test-repository", true)
tk.On("GetInput", "namespace").Return("test-namespace", true)
Expand Down

0 comments on commit 117bbe7

Please sign in to comment.