Skip to content

Commit 35fa63b

Browse files
committed
Fix lint warnings
1 parent ad5573d commit 35fa63b

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

client.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ func Basic(client *http.Client, username, password string, urls ...string) Optio
8686
}
8787

8888
func newSimpleClient(client *http.Client, auth string, urls []string) []*HTTPClient {
89-
clients := make([]*HTTPClient, len(urls), len(urls))
90-
for index, baseUrl := range urls {
91-
clients[index] = &HTTPClient{BaseURL: baseUrl, Client: client, Authorization: auth}
89+
clients := make([]*HTTPClient, len(urls))
90+
for index, baseURL := range urls {
91+
clients[index] = &HTTPClient{BaseURL: baseURL, Client: client, Authorization: auth}
9292
}
9393
return clients
9494
}
@@ -147,26 +147,26 @@ func newCloudClientForService(name string, services map[string][]cfservices.Serv
147147
if err != nil {
148148
return nil, fmt.Errorf("failed to create cloud Client: %w", err)
149149
}
150-
clients := make([]*HTTPClient, len(creds.Credentials), len(creds.Credentials))
150+
clients := make([]*HTTPClient, len(creds.Credentials))
151151
for i, cred := range creds.Credentials {
152152
clients[i] = &HTTPClient{BaseURL: cred.Uri, Client: newOAuth2Client(cred.ClientId, cred.ClientSecret, cred.AccessTokenUri)}
153153
}
154154
return clients, nil
155155
}
156156

157157
// OAuth2 creates a Client for a Config Server based on the provided OAuth2.0 information.
158-
func OAuth2(baseURL string, clientId string, secret string, tokenURI string) Option {
158+
func OAuth2(baseURL string, clientID string, secret string, tokenURI string) Option {
159159
return func(clients *[]*HTTPClient) error {
160-
*clients = append(*clients, &HTTPClient{BaseURL: baseURL, Client: newOAuth2Client(clientId, secret, tokenURI)})
160+
*clients = append(*clients, &HTTPClient{BaseURL: baseURL, Client: newOAuth2Client(clientID, secret, tokenURI)})
161161
return nil
162162
}
163163
}
164164

165-
func newOAuth2Client(clientId string, secret string, tokenURI string) *http.Client {
166-
config := newOAuth2Config(clientId, secret, tokenURI)
165+
func newOAuth2Client(clientID string, secret string, tokenURI string) *http.Client {
166+
config := newOAuth2Config(clientID, secret, tokenURI)
167167
return config.Client(context.Background())
168168
}
169169

170-
func newOAuth2Config(clientId string, secret string, tokenURI string) *clientcredentials.Config {
171-
return &clientcredentials.Config{ClientID: clientId, ClientSecret: secret, TokenURL: tokenURI}
170+
func newOAuth2Config(clientID string, secret string, tokenURI string) *clientcredentials.Config {
171+
return &clientcredentials.Config{ClientID: clientID, ClientSecret: secret, TokenURL: tokenURI}
172172
}

configuration.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *Source) HandlePropertySources(handler PropertySourceHandler) {
6262
// This function is not optimized (ugly) and is intended to only be used at startup.
6363
func (s *Source) Unmarshal(v interface{}) error {
6464
// covert to a map[string]interface{} so we can convert to the target type
65-
obj, err := toJson(s.PropertySources)
65+
obj, err := toJSON(s.PropertySources)
6666
if err != nil {
6767
return err
6868
}
@@ -77,7 +77,7 @@ func (s *Source) Unmarshal(v interface{}) error {
7777

7878
var sliceRegex = regexp.MustCompile(`(.*)\[(\d+)]`)
7979

80-
func toJson(propertySources []PropertySource) (map[string]interface{}, error) {
80+
func toJSON(propertySources []PropertySource) (map[string]interface{}, error) {
8181
// get ready for a wild ride...
8282
output := map[string]interface{}{}
8383
// save the root, so we can get back there when we walk the tree

http.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,40 +105,40 @@ func (h *HTTPClient) GetResourceRaw(paths []string, params map[string]string) ([
105105

106106
// Get performs a http.MethodGet operation. Builds the URL based on the provided paths and params.
107107
func (h *HTTPClient) Get(paths []string, params map[string]string) (*http.Response, error) {
108-
fullUrl, err := newURL(h.BaseURL, paths, params)
108+
fullURL, err := newURL(h.BaseURL, paths, params)
109109
if err != nil {
110110
return nil, fmt.Errorf("failed to create url: %w", err)
111111
}
112-
req, err := http.NewRequest(http.MethodGet, fullUrl, nil)
112+
req, err := http.NewRequest(http.MethodGet, fullURL, nil)
113113
if err != nil {
114-
return nil, fmt.Errorf("failed to create request for %s: %w", fullUrl, err)
114+
return nil, fmt.Errorf("failed to create request for %s: %w", fullURL, err)
115115
}
116116
if h.Authorization != "" {
117117
req.Header.Set("Authorization", h.Authorization)
118118
}
119119
response, err := h.Do(req)
120120
if err != nil {
121-
return nil, fmt.Errorf("failed to retrieve from %s: %w", fullUrl, err)
121+
return nil, fmt.Errorf("failed to retrieve from %s: %w", fullURL, err)
122122
}
123123
return response, nil
124124
}
125125

126126
func newURL(baseURL string, paths []string, params map[string]string) (string, error) {
127-
parseUrl, err := url.Parse(baseURL)
127+
parseURL, err := url.Parse(baseURL)
128128
if err != nil {
129129
return "", fmt.Errorf("failed to parse url %s: %w", baseURL, err)
130130
}
131-
if paths != nil {
131+
if len(paths) > 0 {
132132
for _, p := range paths {
133-
parseUrl.Path = path.Join(parseUrl.Path, p)
133+
parseURL.Path = path.Join(parseURL.Path, p)
134134
}
135135
}
136136
if params != nil {
137-
query := parseUrl.Query()
137+
query := parseURL.Query()
138138
for key, value := range params {
139139
query.Set(key, value)
140140
}
141-
parseUrl.RawQuery = query.Encode()
141+
parseURL.RawQuery = query.Encode()
142142
}
143-
return parseUrl.String(), nil
143+
return parseURL.String(), nil
144144
}

0 commit comments

Comments
 (0)