Skip to content

Commit

Permalink
fix-pkg-staticcheck and remove the repeat code
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjunchen committed Dec 3, 2019
1 parent 32682a5 commit 977f987
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 27 deletions.
10 changes: 0 additions & 10 deletions pkg/model/alimodel/convenience.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ func s(v string) *string {
return fi.String(v)
}

// i64 is a helper that builds a *int64 from an int64 value
func i64(v int64) *int64 {
return fi.Int64(v)
}

// i32 is a helper that builds a *int32 from an int32 value
func i32(v int32) *int32 {
return fi.Int32(v)
}

// i is a helper that builds a *int from an int value
func i(v int) *int {
return fi.Int(v)
Expand Down
5 changes: 0 additions & 5 deletions pkg/model/convenience.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,3 @@ func s(v string) *string {
func i64(v int64) *int64 {
return fi.Int64(v)
}

// i32 is a helper that builds a *int32 from an int32 value
func i32(v int32) *int32 {
return fi.Int32(v)
}
2 changes: 1 addition & 1 deletion pkg/model/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (b *DNSModelBuilder) ensureDNSZone(c *fi.ModelBuilderContext) error {
dnsZone.PrivateVPC = b.LinkToVPC()

default:
return fmt.Errorf("Unknown DNS type %q", topology.DNS.Type)
return fmt.Errorf("unknown DNS type %q", topology.DNS.Type)
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/model/openstackmodel/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (c *OpenstackModelContext) findSubnetClusterSpec(subnet string) (string, er
return name, nil
}
}
return "", fmt.Errorf("Could not find subnet %s from clusterSpec", subnet)
return "", fmt.Errorf("could not find subnet %s from clusterSpec", subnet)
}

func (c *OpenstackModelContext) findSubnetNameByID(subnetID string, subnetName string) (string, error) {
Expand Down
5 changes: 0 additions & 5 deletions pkg/model/openstackmodel/convenience.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ func s(v string) *string {
return fi.String(v)
}

// i64 is a helper that builds a *int64 from an int64 value
func i64(v int64) *int64 {
return fi.Int64(v)
}

// i32 is a helper that builds a *int32 from an int32 value
func i32(v int32) *int32 {
return fi.Int32(v)
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/openstackmodel/servergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ func (b *ServerGroupModelBuilder) buildInstances(c *fi.ModelBuilderContext, sg *

startupScript, err := b.BootstrapScript.ResourceNodeUp(ig, b.Cluster)
if err != nil {
return fmt.Errorf("Could not create startup script for instance group %s: %v", ig.Name, err)
return fmt.Errorf("could not create startup script for instance group %s: %v", ig.Name, err)
}
if startupScript != nil {
// var userData bytes.Buffer
startupStr, err := startupScript.AsString()
if err != nil {
return fmt.Errorf("Could not create startup script for instance group %s: %v", ig.Name, err)
return fmt.Errorf("could not create startup script for instance group %s: %v", ig.Name, err)
}
igUserData = fi.String(startupStr)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/nodeidentity/openstack/identify.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func New() (nodeidentity.Identifier, error) {

region := os.Getenv("OS_REGION_NAME")
if region == "" {
return nil, fmt.Errorf("Unable to find region")
return nil, fmt.Errorf("unable to find region")
}

provider, err := openstack.NewClient(env.IdentityEndpoint)
Expand Down Expand Up @@ -106,5 +106,5 @@ func (i *nodeIdentifier) getInstanceGroup(instanceID string) (string, error) {
if val, ok := instance.Metadata["KopsInstanceGroup"]; ok {
return val, nil
}
return "", fmt.Errorf("Could not find tag 'KopsInstanceGroup' from instance metadata")
return "", fmt.Errorf("could not find tag 'KopsInstanceGroup' from instance metadata")
}
2 changes: 1 addition & 1 deletion pkg/pki/sshkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func toDER(pubkey ssh.PublicKey) ([]byte, error) {
// cryptoKey = dsaPublicKey

default:
return nil, fmt.Errorf("Unexpected type of SSH key (%q); AWS can only import RSA keys", typeName)
return nil, fmt.Errorf("unexpected type of SSH key (%q); AWS can only import RSA keys", typeName)
}

der, err := x509.MarshalPKIXPublicKey(cryptoKey)
Expand Down

0 comments on commit 977f987

Please sign in to comment.