Skip to content

Commit

Permalink
Fix lint issues caught by golangci-lint
Browse files Browse the repository at this point in the history
Add missing error checks.
Deindent package comments.
Remove unnecessary type casts.
  • Loading branch information
ryboe authored and Ryan Boehning committed Jun 3, 2019
1 parent 1bfdf69 commit e3fb96e
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 94 deletions.
20 changes: 10 additions & 10 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package main

Expand Down
28 changes: 16 additions & 12 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package auth
Expand Down Expand Up @@ -57,7 +57,7 @@ func authenticate(client *api.Client, config cfg.Config, svc Authenticator) bool
log.Printf("could not write token to %s: %v\n", config.TokenPath, err)
return false
}
client.SetToken(string(vaultToken))
client.SetToken(vaultToken)
return true
}

Expand Down Expand Up @@ -166,13 +166,17 @@ func RenewService(client *api.Client, config cfg.Config) {
log.Fatalln("The existing token failed renewal, exiting..")
}
ttl, err := result.TokenTTL()
if err != nil {
log.Fatalln("Failed to parse the token's ttl from JSON")
}

if ttl.Seconds() < float64(config.RenewalThreshold) {
fmt.Println("token ttl of", ttl.Seconds(), "is below threshold of", config.RenewalThreshold, ", renewing to", config.RenewalIncrement)
secret, err := client.Auth().Token().RenewSelf(int(config.RenewalIncrement))
if err != nil {
log.Println("Failed to renew the existing token:", err)
}
client.SetToken(string(secret.Auth.ClientToken))
client.SetToken(secret.Auth.ClientToken)
err = ioutil.WriteFile(config.TokenPath, []byte(secret.Auth.ClientToken), 0600)
if err != nil {
log.Println("Could not write token to file", config.TokenPath, err.Error())
Expand Down
20 changes: 10 additions & 10 deletions pkg/auth/auth_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package auth

Expand Down
20 changes: 10 additions & 10 deletions pkg/auth/aws.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package auth
Expand Down
20 changes: 10 additions & 10 deletions pkg/auth/gcp.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package auth

Expand Down
22 changes: 11 additions & 11 deletions pkg/auth/k8s.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package auth

Expand Down Expand Up @@ -50,7 +50,7 @@ func (k *K8SService) Auth(client *api.Client, config cfg.Config) (string, error)
return fetchVaultToken(client, config, loginData)
}

// InferK8SConfig attempts to replace default configuration parameters on K8S with ones infered from the k8s environment
// InferK8SConfig attempts to replace default configuration parameters on K8S with ones inferred from the k8s environment
func InferK8SConfig(config *cfg.Config) {
log.Println("Attempting to automatically infer some k8s configuration data")
if config.VaultAuthRoleName == "" {
Expand Down
20 changes: 10 additions & 10 deletions pkg/auth/token_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package auth
Expand Down
6 changes: 5 additions & 1 deletion pkg/helpers/testhelpers/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import "github.com/hashicorp/vault/api"
func GetTestClient(url string) (*api.Client, error) {
vaultConfig := api.DefaultConfig()
vaultConfig.Address = url
vaultConfig.ConfigureTLS(&api.TLSConfig{Insecure: true})
err := vaultConfig.ConfigureTLS(&api.TLSConfig{Insecure: true})
if err != nil {
return nil, err
}

client, err := api.NewClient(vaultConfig)
if err != nil {
return nil, err
Expand Down
20 changes: 10 additions & 10 deletions pkg/secrets/secrets.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package secrets
Expand Down
20 changes: 10 additions & 10 deletions pkg/secrets/secrets_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
Copyright 2019 GM Cruise LLC
Copyright 2019 GM Cruise LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package secrets
Expand Down

0 comments on commit e3fb96e

Please sign in to comment.