Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmann committed Jan 31, 2022
1 parent 0c45668 commit 49c3a59
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
13 changes: 9 additions & 4 deletions grantsSSH.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func (s SSHGrantEndpoint) DoHTTPRequest(method string, req interface{}, resp int
}

// DoHTTPRequestWithAuth performs an http request to the ssh grant endpoint
func (s SSHGrantEndpoint) DoHTTPRequestWithAuth(method string, req interface{}, resp interface{}, mytoken string) error {
func (s SSHGrantEndpoint) DoHTTPRequestWithAuth(
method string, req interface{}, resp interface{}, mytoken string,
) error {
return doHTTPRequestWithAuth(method, s.endpoint, req, resp, mytoken)
}

Expand Down Expand Up @@ -86,7 +88,8 @@ func (s SSHGrantEndpoint) Remove(mytoken *string, keyFP, publicKey string) error
// If the used mytoken changes (due to token rotation), the new mytoken is returned in the non-nil *api.MytokenResponse
func (s SSHGrantEndpoint) APIAdd(
mytoken, sshKey, name string, restrictions api.Restrictions, capabilities, subtokenCapabilities api.Capabilities,
callbacks PollingCallbacks) (response api.SSHKeyAddFinalResponse, tokenUpdate *api.MytokenResponse, err error) {
callbacks PollingCallbacks,
) (response api.SSHKeyAddFinalResponse, tokenUpdate *api.MytokenResponse, err error) {
initRes, err := s.APIInitAddSSHKey(mytoken, sshKey, name, restrictions, capabilities, subtokenCapabilities)
tokenUpdate = initRes.TokenUpdate
if err != nil {
Expand All @@ -113,8 +116,10 @@ func (s SSHGrantEndpoint) Add(
mytoken *string, sshKey, name string, restrictions api.Restrictions, capabilities,
subtokenCapabilities api.Capabilities, callbacks PollingCallbacks,
) (api.SSHKeyAddFinalResponse, error) {
resp, tokenUpdate, err := s.APIAdd(*mytoken, sshKey, name, restrictions, capabilities, subtokenCapabilities,
callbacks)
resp, tokenUpdate, err := s.APIAdd(
*mytoken, sshKey, name, restrictions, capabilities, subtokenCapabilities,
callbacks,
)
if tokenUpdate != nil {
*mytoken = tokenUpdate.Mytoken
}
Expand Down
6 changes: 4 additions & 2 deletions http.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ func doHTTPRequest(method, url string, reqBody interface{}, responseData interfa
return doHTTPRequestWithAuth(method, url, reqBody, responseData, "")
}

func doHTTPRequestWithAuth(method, url string, reqBody interface{}, responseData interface{},
bearerAuth string) error {
func doHTTPRequestWithAuth(
method, url string, reqBody interface{}, responseData interface{},
bearerAuth string,
) error {
b := new(bytes.Buffer)
if err := json.NewEncoder(b).Encode(reqBody); err != nil {
return newMytokenErrorFromError(errEncodingRequest, err)
Expand Down
10 changes: 7 additions & 3 deletions mytoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func (my MytokenEndpoint) FromMytoken(
mytoken *string, issuer string, restrictions api.Restrictions, capabilities,
subtokenCapabilities api.Capabilities, rotation *api.Rotation, responseType, name string,
) (string, error) {
resp, err := my.APIFromMytoken(*mytoken, issuer, restrictions, capabilities, subtokenCapabilities,
rotation, responseType, name)
resp, err := my.APIFromMytoken(
*mytoken, issuer, restrictions, capabilities, subtokenCapabilities,
rotation, responseType, name,
)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -128,7 +130,9 @@ func (my MytokenEndpoint) FromAuthorizationFlow(
issuer string, restrictions api.Restrictions, capabilities, subtokenCapabilities api.Capabilities,
rotation *api.Rotation, responseType, name string, callbacks PollingCallbacks,
) (string, error) {
resp, err := my.APIFromAuthorizationFlow(issuer, restrictions, capabilities, subtokenCapabilities, rotation, responseType, name, callbacks)
resp, err := my.APIFromAuthorizationFlow(
issuer, restrictions, capabilities, subtokenCapabilities, rotation, responseType, name, callbacks,
)
return resp.Mytoken, err
}

Expand Down

0 comments on commit 49c3a59

Please sign in to comment.