Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linter pass #203

Merged
merged 2 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions cmd/build-lambda-zip/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {

app.Action = func(c *cli.Context) error {
if !c.Args().Present() {
return errors.New("No input provided")
return errors.New("no input provided")
}

inputExe := c.Args().First()
Expand All @@ -35,7 +35,7 @@ func main() {
}

if err := compressExeAndArgs(outputZip, inputExe, c.Args().Tail()); err != nil {
return fmt.Errorf("Failed to compress file: %v", err)
return fmt.Errorf("failed to compress file: %v", err)
}
return nil
}
Expand Down Expand Up @@ -71,7 +71,6 @@ func compressExeAndArgs(outZipPath string, exePath string, args []string) error
if closeErr != nil {
fmt.Fprintf(os.Stderr, "Failed to close zip file: %v\n", closeErr)
}
return
}()

zipWriter := zip.NewWriter(zipFile)
Expand Down
4 changes: 2 additions & 2 deletions events/attributevalue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ func Test_DynamoDBAttributeValue_NewAttribute(t *testing.T) {
assert.Equal(t, true, av.Boolean())
}
{
av := NewBinarySetAttribute([][]byte{[]byte{1, 2, 3}})
av := NewBinarySetAttribute([][]byte{{1, 2, 3}})
assert.Equal(t, DataTypeBinarySet, av.DataType())
assert.Equal(t, [][]byte{[]byte{1, 2, 3}}, av.BinarySet())
assert.Equal(t, [][]byte{{1, 2, 3}}, av.BinarySet())
}
{
av := NewListAttribute([]DynamoDBAttributeValue{
Expand Down
7 changes: 3 additions & 4 deletions events/cloudwatch_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ func (c CloudwatchLogsRawData) Parse() (d CloudwatchLogsData, err error) {
}

zr, err := gzip.NewReader(bytes.NewBuffer(data))
defer zr.Close()
if err != nil {
return
}
defer zr.Close()

buf := &bytes.Buffer{}
buf.ReadFrom(zr)
dec := json.NewDecoder(zr)
err = dec.Decode(&d)

err = json.Unmarshal(buf.Bytes(), &d)
return
}

Expand Down
4 changes: 2 additions & 2 deletions events/cognito.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type CognitoEventUserPoolsPostConfirmation struct {
}

// CognitoEventUserPoolsPreTokenGen is sent by AWS Cognito User Pools when a user attempts to retrieve
// credentials, allowing a Lambda to perform insert, supress or override claims
// credentials, allowing a Lambda to perform insert, suppress or override claims
type CognitoEventUserPoolsPreTokenGen struct {
CognitoEventUserPoolsHeader
Request CognitoEventUserPoolsPreTokenGenRequest `json:"request"`
Expand Down Expand Up @@ -133,7 +133,7 @@ type CognitoEventUserPoolsMigrateUserResponse struct {
ForceAliasCreation bool `json:"forceAliasCreation"`
}

// ClaimsOverrideDetails allows lambda to add, supress or override claims in the token
// ClaimsOverrideDetails allows lambda to add, suppress or override claims in the token
type ClaimsOverrideDetails struct {
GroupOverrideDetails GroupConfiguration `json:"groupOverrideDetails"`
ClaimsToAddOrOverride map[string]string `json:"claimsToAddOrOverride"`
Expand Down
2 changes: 0 additions & 2 deletions events/firehose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ func testFirehoseResponseMarshaling(t *testing.T) {
}

func testMarshaling(t *testing.T, jsonFile string) {

// 1. read JSON from file
inputJson := test.ReadJSONFromFile(t, jsonFile)

Expand All @@ -41,7 +40,6 @@ func testMarshaling(t *testing.T, jsonFile string) {
}

func TestSampleTransformation(t *testing.T) {

inputJson := test.ReadJSONFromFile(t, "./testdata/kinesis-firehose-event.json")

// de-serialize into Go object
Expand Down
9 changes: 6 additions & 3 deletions lambda/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,20 @@ func validateArguments(handler reflect.Type) (bool, error) {

func validateReturns(handler reflect.Type) error {
errorType := reflect.TypeOf((*error)(nil)).Elem()
if handler.NumOut() > 2 {

switch n := handler.NumOut(); {
case n > 2:
return fmt.Errorf("handler may not return more than two values")
} else if handler.NumOut() > 1 {
case n > 1:
if !handler.Out(1).Implements(errorType) {
return fmt.Errorf("handler returns two values, but the second does not implement error")
}
} else if handler.NumOut() == 1 {
case n == 1:
if !handler.Out(0).Implements(errorType) {
return fmt.Errorf("handler returns a single value, but it does not implement error")
}
}

return nil
}

Expand Down