-
Notifications
You must be signed in to change notification settings - Fork 928
/
resources.go
42 lines (32 loc) · 875 Bytes
/
resources.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package uaa
import (
"fmt"
"net/http"
"code.cloudfoundry.org/cli/api/uaa/internal"
)
// SetupResources configures the client to use the specified settings and diescopers the UAA and Authentication resources
func (client *Client) SetupResources(bootstrapURL string) error {
request, err := client.newRequest(requestOptions{
Method: http.MethodGet,
URL: fmt.Sprintf("%s/login", bootstrapURL),
})
if err != nil {
return err
}
info := NewInfo(bootstrapURL)
response := Response{
Result: &info,
}
err = client.connection.Make(request, &response)
if err != nil {
return err
}
resources := map[string]string{
"uaa": info.UAALink(),
"authorization_endpoint": bootstrapURL,
}
client.router = internal.NewRouter(internal.APIRoutes, resources)
client.Info = info
client.config.SetUAAEndpoint(info.UAALink())
return nil
}