Skip to content

Commit

Permalink
feat: create kong jwtCredentials if not create
Browse files Browse the repository at this point in the history
  • Loading branch information
JingYiJun committed Apr 15, 2024
1 parent c4b5f81 commit 82f98a3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions utils/kong/kong.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ func ListJwtCredentials(userID int) ([]*JwtCredential, error) {
return nil, err
}
if statusCode != 200 {

return nil, fmt.Errorf("list credential error: %v", string(body))
}

Expand All @@ -136,10 +137,10 @@ func ListJwtCredentials(userID int) ([]*JwtCredential, error) {
}

func GetJwtCredential(userID int) (*JwtCredential, error) {
jwtCredentials, err := ListJwtCredentials(userID)
if err != nil {
return nil, err
}
jwtCredentials, _ := ListJwtCredentials(userID)
//if err != nil {
// return nil, err
//}
if len(jwtCredentials) == 0 {
return CreateJwtCredential(userID)
} else {
Expand Down Expand Up @@ -172,7 +173,11 @@ func DeleteJwtCredential(userID int) error {
for i := range jwtCredentials {
innerErr := deleteAJwtCredential(jwtCredentials[i].ID)
if innerErr != nil {
err = errors.Wrap(innerErr, err.Error())
if err == nil {
err = innerErr
} else {
err = errors.Wrap(innerErr, err.Error())
}
}
}
return err
Expand Down

0 comments on commit 82f98a3

Please sign in to comment.