Skip to content

Commit

Permalink
Merge pull request #816 from ericchiang/cherry-pick-k8s-storage-fix
Browse files Browse the repository at this point in the history
storage/kubernetes: fix kubernetes storage conformance test failures
  • Loading branch information
ericchiang authored Feb 24, 2017
2 parents af0d9ce + 7968f28 commit f8aec4c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions storage/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ func checkHTTPErr(r *http.Response, validStatusCodes ...int) error {
if r.StatusCode == http.StatusNotFound {
return storage.ErrNotFound
}
if r.Request.Method == "POST" && r.StatusCode == http.StatusConflict {
return storage.ErrAlreadyExists
}

var url, method string
if r.Request != nil {
Expand Down
2 changes: 1 addition & 1 deletion storage/kubernetes/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
resourceRefreshToken = "refreshtokens"
resourceKeys = "signingkeies" // Kubernetes attempts to pluralize.
resourcePassword = "passwords"
resourceOfflineSessions = "offlinesessions"
resourceOfflineSessions = "offlinesessionses" // Again attempts to pluralize.
)

// Config values for the Kubernetes storage type.
Expand Down
7 changes: 6 additions & 1 deletion storage/kubernetes/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,9 +502,14 @@ func (cli *client) fromStorageOfflineSessions(o storage.OfflineSessions) Offline
}

func toStorageOfflineSessions(o OfflineSessions) storage.OfflineSessions {
return storage.OfflineSessions{
s := storage.OfflineSessions{
UserID: o.UserID,
ConnID: o.ConnID,
Refresh: o.Refresh,
}
if s.Refresh == nil {
// Server code assumes this will be non-nil.
s.Refresh = make(map[string]*storage.RefreshTokenRef)
}
return s
}

0 comments on commit f8aec4c

Please sign in to comment.