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

Grant privileges lambda #30

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 15 additions & 0 deletions .github/workflows/upload-lambdas-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,18 @@ jobs:
LAMBDA_NAME: provisioner-notification
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}

upload-grant-privileges-to-schemas:
name: Upload grant-privileges-to-schemas 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: grant-privileges-to-schemas
AWS_ACCESS_KEY_ID: ${{ secrets.aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.aws_secret_access_key }}
37 changes: 37 additions & 0 deletions grant-privileges-to-schemas/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

linters:
disable-all: true
enable:
- revive
- gocyclo
- misspell
- gofmt
- gosimple
- govet
- ineffassign
- predeclared
- staticcheck
- unconvert
- unused

gocyclo:
min-complexity: 15

issues:
exclude-use-default: false
exclude-dirs-use-default: false
max-issues-per-linter: 0
max-same-issues: 0

linters-settings:
gofmt:
simplify: true
govet:
enable-all: true
disable:
- fieldalignment
- atomicalign




65 changes: 65 additions & 0 deletions grant-privileges-to-schemas/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
HANDLER ?= bootstrap
PACKAGE ?= $(HANDLER)
GOPATH ?= $(HOME)/go
GOOS ?= linux
GOARCH ?= amd64
GOLANGCILINT_VER := v1.61.0

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

check-style: lint fmt

lint-install:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCILINT_VER)

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

go 1.23.2

require (
github.com/aws/aws-lambda-go v1.47.0
github.com/aws/aws-sdk-go v1.55.5
github.com/lib/pq v1.10.9
)

require github.com/jmespath/go-jmespath v0.4.0 // indirect
23 changes: 23 additions & 0 deletions grant-privileges-to-schemas/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
github.com/aws/aws-lambda-go v1.47.0 h1:0H8s0vumYx/YKs4sE7YM0ktwL2eWse+kfopsRI1sXVI=
github.com/aws/aws-lambda-go v1.47.0/go.mod h1:dpMpZgvWx5vuQJfBt0zqBha60q7Dd7RfgJv23DymV8A=
github.com/aws/aws-sdk-go v1.55.5 h1:KKUZBfBoyqy5d3swXyiC7Q76ic40rYcbqH7qjh59kzU=
github.com/aws/aws-sdk-go v1.55.5/go.mod h1:eRwEWoyTWFMVYVQzKMNHWP5/RV4xIUGMQfXQHfHkpNU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading
Loading