Skip to content

Commit

Permalink
refactor: url → endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Dec 15, 2020
1 parent 253d794 commit e4bc551
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions core/commands/pin/remotepin.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,13 +391,11 @@ var addRemotePinServiceCmd = &cmds.Command{
}

name := req.Arguments[0]
url := req.Arguments[1]
key := req.Arguments[2]

endpoint, err := normalizeEndpoint(url)
endpoint, err := normalizeEndpoint(req.Arguments[1])
if err != nil {
return err
}
key := req.Arguments[2]

cfg, err := repo.Config()
if err != nil {
Expand Down Expand Up @@ -640,18 +638,14 @@ func getRemotePinService(env cmds.Environment, name string) (*pinclient.Client,
if name == "" {
return nil, fmt.Errorf("remote pinning service name not specified")
}
url, key, err := getRemotePinServiceInfo(env, name)
if err != nil {
return nil, err
}
endpoint, err := normalizeEndpoint(url)
endpoint, key, err := getRemotePinServiceInfo(env, name)
if err != nil {
return nil, err
}
return pinclient.NewClient(endpoint, key), nil
}

func getRemotePinServiceInfo(env cmds.Environment, name string) (url, key string, err error) {
func getRemotePinServiceInfo(env cmds.Environment, name string) (endpoint, key string, err error) {
cfgRoot, err := cmdenv.GetConfigRoot(env)
if err != nil {
return "", "", err
Expand All @@ -672,7 +666,11 @@ func getRemotePinServiceInfo(env cmds.Environment, name string) (url, key string
if !present {
return "", "", fmt.Errorf("service not known")
}
return service.Api.Endpoint, service.Api.Key, nil
endpoint, err = normalizeEndpoint(service.Api.Endpoint)
if err != nil {
return "", "", err
}
return endpoint, service.Api.Key, nil
}

func normalizeEndpoint(endpoint string) (string, error) {
Expand Down

0 comments on commit e4bc551

Please sign in to comment.