Skip to content

Commit

Permalink
Add webhook lambdas (#25)
Browse files Browse the repository at this point in the history
Signed-off-by: Stavros Foteinopoulos <[email protected]>
  • Loading branch information
stafot authored Nov 14, 2023
1 parent 9789e3e commit 5052673
Show file tree
Hide file tree
Showing 18 changed files with 1,969 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/upload-lambdas-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,48 @@ jobs:
LAMBDA_NAME: cloudwatch-event-alerts
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}

upload-elrond-notification:
name: Upload elrond-notification function to S3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Lambda Upload
uses: ./.github/actions/upload-lambda
env:
ENVIRONMENT: ${{ inputs.environment }}
LAMBDA_NAME: elrond-notification
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}

upload-gitlab-webhook:
name: Upload gitlab-webhook function to S3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Lambda Upload
uses: ./.github/actions/upload-lambda
env:
ENVIRONMENT: ${{ inputs.environment }}
LAMBDA_NAME: gitlab-webhook
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}

upload-provisioner-notification:
name: Upload provisioner-notification function to S3
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Lambda Upload
uses: ./.github/actions/upload-lambda
env:
ENVIRONMENT: ${{ inputs.environment }}
LAMBDA_NAME: provisioner-notification
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
16 changes: 16 additions & 0 deletions elrond-notification/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

run:
skip-dirs-use-default: false

linters:
enable:
- revive
- gocyclo
- misspell

gocyclo:
min-complexity: 15

issues:
exclude-use-default: false

59 changes: 59 additions & 0 deletions elrond-notification/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
HANDLER ?= bootstrap
PACKAGE ?= $(HANDLER)
GOPATH ?= $(HOME)/go
GOOS ?= linux
GOARCH ?= amd64

WORKDIR = $(CURDIR:$(GOPATH)%=/go%)
ifeq ($(WORKDIR),$(CURDIR))
WORKDIR = /tmp
endif

all: build pack

build:
@echo "Building..."
@GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -ldflags='-w -s' -o $(HANDLER) .

pack:
@echo "Packing binary..."
@zip $(PACKAGE).zip $(HANDLER)

update-modules:
go get -u ./...
go mod tidy

.PHONY: fmt
## fmt: Run go fmt on codebase
fmt:
@echo Checking if code is formatted
files=$$(go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' .); \
if [ "$$files" ]; then \
gofmt_output=$$(gofmt -d -s $$files 2>&1); \
if [ "$$gofmt_output" ]; then \
echo "$$gofmt_output"; \
echo "gofmt failed"; \
echo "To fix it, run:"; \
echo "go fmt [FILE]"; \
exit 1; \
fi; \
fi; \
echo "gofmt success"; \

.PHONY: lint
## lint: Run golangci-lint on codebase
lint:
@echo "Linting..."
@if ! [ -x "$$(command -v golangci-lint)" ]; then \
echo "golangci-lint is not installed. Please see https://github.com/golangci/golangci-lint#install for installation instructions."; \
exit 1; \
fi; \

@echo Running golangci-lint
golangci-lint run ./...

clean:
@echo "Cleaning up..."
@rm -rf $(HANDLER) $(PACKAGE).zip

.PHONY: all build pack clean update-modules
63 changes: 63 additions & 0 deletions elrond-notification/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
module github.com/mattermost/mattermost-cloud-lambdas/elrond-notification

go 1.21

require (
github.com/aws/aws-lambda-go v1.41.0
github.com/mattermost/elrond v0.5.0
github.com/opsgenie/opsgenie-go-sdk-v2 v1.2.22
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
)

require (
github.com/aws/aws-sdk-go v1.47.9 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattermost/mattermost-cloud v0.78.0 // indirect
github.com/mattermost/mattermost-operator v1.21.0-rc.2 // indirect
github.com/mattermost/rotator v0.2.1-0.20230830064954-61490ed26761 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pborman/uuid v1.2.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.28.3 // indirect
k8s.io/apimachinery v0.28.3 // indirect
k8s.io/client-go v0.28.3 // indirect
k8s.io/klog/v2 v2.110.1 // indirect
k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/controller-runtime v0.16.3 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit 5052673

Please sign in to comment.