GithubHelp home page GithubHelp logo

sue445 / gitpanda Goto Github PK

View Code? Open in Web Editor NEW
20.0 6.0 7.0 4.21 MB

GitLab URL expander for Slack

Home Page: https://godoc.org/github.com/sue445/gitpanda

License: MIT License

Go 98.38% Makefile 1.34% Dockerfile 0.28%
gitlab slack-webhook lambda docker-image

gitpanda's Introduction

gitpanda 🐼

GitLab URL expander for Slack

Latest Version test build docker-ghcr docker-gcp Maintainability Test Coverage Go Report Card

Example

example1

example2

Requirements

Supported URL format

  • User URL
    • e.g. ${GITLAB_BASE_URL}/:username
  • Group URL
    • e.g. ${GITLAB_BASE_URL}/:groupname
  • Project URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame
  • Issue URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/issues/:iid
  • MergeRequest URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/merge_requests/:iid
  • Job URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/-/jobs/:id
  • Pipeline URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/pipelines/:id
  • Blob URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/blob/:sha1/:filename
  • Commit URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/commit/:sha1
  • Project snippet URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/snippets/:id
  • Snippet URL
    • e.g. ${GITLAB_BASE_URL}/snippets/:id

Running standalone

Download latest binary from https://github.com/sue445/gitpanda/releases

PORT=8000 \
GITLAB_API_ENDPOINT=https://your-gitlab.example.com/api/v4 \
GITLAB_BASE_URL=https://your-gitlab.example.com \
GITLAB_PRIVATE_TOKEN=xxxxxxxxxx \
SLACK_OAUTH_ACCESS_TOKEN=xoxp-0000000000-0000000000-000000000000-00000000000000000000000000000000 \
SLACK_VERIFICATION_TOKEN=xxxxxxxxx \
TRUNCATE_LINES=5 \
./gitpanda

Environment variables

  • PORT
    • default is 8000
  • GITLAB_API_ENDPOINT
    • e.g. https://your-gitlab.example.com/api/v4
  • GITLAB_BASE_URL
    • e.g. https://your-gitlab.example.com
  • GITLAB_PRIVATE_TOKEN
    • Generate a personal access token with api scope
  • SLACK_OAUTH_ACCESS_TOKEN
    • see CREATE_SLACK_APP.md
    • e.g. xoxp-0000000000-0000000000-000000000000-00000000000000000000000000000000
  • SLACK_VERIFICATION_TOKEN
  • TRUNCATE_LINES
    • Line count to truncate the text (default. no truncate)
  • SENTRY_DSN

Running with AWS (Lambda + API Gateway + Parameter Store)

Use latest gitpanda_linux_amd64 on https://github.com/sue445/gitpanda/releases

Environment variables

One of the following is required

Environment Key of Parameter Store
GITLAB_API_ENDPOINT GITLAB_API_ENDPOINT_KEY
GITLAB_BASE_URL GITLAB_BASE_URL_KEY
GITLAB_PRIVATE_TOKEN GITLAB_PRIVATE_TOKEN_KEY
SLACK_OAUTH_ACCESS_TOKEN SLACK_OAUTH_ACCESS_TOKEN_KEY
SLACK_VERIFICATION_TOKEN SLACK_VERIFICATION_TOKEN_KEY
TRUNCATE_LINES

When you want to store to Parameter Store, please store as SecureString

aws parameter_store

Example

Arguments

$ ./gitpanda --help
Usage of ./gitpanda:
  -version
    	Whether showing version

Running with docker

Run latest version

docker run --rm -it ghcr.io/sue445/gitpanda

Run with specified version

docker run --rm -it ghcr.io/sue445/gitpanda:vX.Y.Z

Images

  • GitHub Container Registry (Recommended)
    • ghcr.io/sue445/gitpanda:latest: Use latest version
    • ghcr.io/sue445/gitpanda:vX.Y.Z: Use specified version
  • Google Artifact Registry: If you want to run this app on Cloud Run, use this image
    • us-docker.pkg.dev/gitpanda/gitpanda/app:latest: Use latest version
    • us-docker.pkg.dev/gitpanda/gitpanda/app:vX.Y.Z: Use specified version
    • us-docker.pkg.dev/gitpanda/gitpanda/app:edge: The contents of the main branch are pushed to this tag

Running with Kubernetes

1. [GKE] Create static IP and managed certificate if necessary

c.f https://cloud.google.com/kubernetes-engine/docs/how-to/managed-certs

2. Download and edit files in examples/kubernetes_manifests/

3. Create secrets

e.g.

kubectl create secret generic gitpanda-secret \
    --from-literal=gitlab_private_token=${GITLAB_PRIVATE_TOKEN} \
    --from-literal=slack_oauth_access_token=${SLACK_OAUTH_ACCESS_TOKEN} \
    --from-literal=slack_verification_token=${SLACK_VERIFICATION_TOKEN}

4. apply manifests

e.g.

kubectl apply -f path/to/kubernetes_manifests/*.yaml

Running with Cloud Run

See followings

Development

Recommend to use https://github.com/direnv/direnv

cp .envrc.example .envrc
vi .envrc
direnv allow

gitpanda's People

Contributors

dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar hiroponz avatar nakatanakatana avatar sue445 avatar suusan2go avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gitpanda's Issues

plant_erd_linux_amd64 doesn't work on Ubuntu 18.04

Ubuntu 20.04 LTS

$ cat /etc/issue
Ubuntu 20.04.2 LTS \n \l

$ wget https://github.com/sue445/plant_erd/releases/download/v0.2.1/plant_erd_linux_amd64 -O plant_erd

$ chmod 755 plant_erd

$ ./plant_erd --version
plant_erd version v0.2.1 (build. 580ad03)

Ubuntu 18.04 LTS

$ cat /etc/issue
Ubuntu 18.04.5 LTS \n \l

$ wget https://github.com/sue445/plant_erd/releases/download/v0.2.1/plant_erd_linux_amd64 -O plant_erd

$ chmod 755 plant_erd

$ ./plant_erd --version
./plant_erd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by ./plant_erd)

Dependabot can't parse your go.mod

Dependabot couldn't parse the go.mod found at /go.mod.

The error Dependabot encountered was:

go: writing go.mod cache: write /opt/go/gopath/pkg/mod/cache/download/golang.org/x/xerrors/@v/v0.0.0-20191011141410-1b5146add898.mod490861488.tmp: no space left on device
go: writing go.mod cache: write /opt/go/gopath/pkg/mod/cache/download/golang.org/x/sys/@v/v0.0.0-20181205085412-a5c9d58dba9a.mod645898619.tmp: no space left on device
go: failed to write version list: write /opt/go/gopath/pkg/mod/cache/download/golang.org/x/crypto/@v/list486425642.tmp: no space left on device

View the update logs.

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

go: github.com/aws/[email protected]: reading github.com/aws/aws-lambda-go/go.mod at revision v1.16.0: unknown revision v1.16.0

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't parse your go.mod

Dependabot couldn't parse the go.mod found at /go.mod.

The error Dependabot encountered was:

go: github.com/stretchr/[email protected] requires
	gopkg.in/[email protected] requires
	gopkg.in/[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /opt/go/gopath/pkg/mod/cache/vcs/9241c28341fcedca6a799ab7a465dd6924dc5d94044cbfabb75778817250adfc: exit status 128:
	fatal: The remote end hung up unexpectedly

View the update logs.

Add User-Agent

e.g. gitpanda/${version} (+https://github.com/sue445/gitpanda)

Truncate lines

Now

aaaaa
bbbb
cccc
dddd
...
zzzz

Idea

e.g. truncate by 3 lines

aaaa
bbbb
cccc

404 error for URLs containing anchors

e.g. https://gitlab.com/gitlab-org/gitlab#gitlab

Error

https://sentry.io/share/issue/61fcd9b2eea8437d96a0d6dd507837dd/

*errors.withStack: GET https://gitlab.com/api/v4/projects/gitlab-org/gitlab#gitlab: 404 {message: 404 Project Not Found}
  File "/tmp/build_ff8791cd/gitlab/project_fetcher.go", line 27, in (*projectFetcher).fetchPath
    return nil, errors.WithStack(err)
  File "/tmp/build_ff8791cd/gitlab/url_parser.go", line 78, in (*URLParser).FetchURL
    page, err := fetcher.fetchPath(path, p.client, p.isDebugLogging)
  File "/tmp/build_ff8791cd/webhook/slack_webhook.go", line 79, in (*SlackWebhook).requestLinkSharedEvent.func1
    page, err := p.FetchURL(url)
  File "/tmp/codon/tmp/cache/go-path/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go", line 57, in (*Group).Go.func1

Dependabot can't resolve your Go dependency files

Dependabot can't resolve your Go dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

go: github.com/aws/[email protected]: reading github.com/aws/aws-lambda-go/go.mod at revision v1.16.0: unknown revision v1.16.0

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

404 error for commit URL

e.g. https://gitlab.com/gitlab-org/gitlab/-/commit/abba013c35b139e7d47dd6a54c017912fcdb786e

2022/11/09 04:37:24 http: panic serving 169.254.1.1:44047: GET https://gitlab.com/api/v4/projects/gitlab-org/gitlab/-/commit/abba013c35b139e7d47dd6a54c017912fcdb786e: 404 {message: 404 Project Not Found}
goroutine 5 [running]:
net/http.(*conn).serve.func1()
	/usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0xd11700, 0xc0004dc198})
	/usr/local/go/src/runtime/panic.go:890 +0x262
github.com/getsentry/sentry-go/http.(*Handler).recoverWithSentry(0xc0000a9170, 0xc0003b46c0?, 0xc000310400)
	/go/pkg/mod/github.com/getsentry/[email protected]/http/sentryhttp.go:117 +0xf0
panic({0xd11700, 0xc0004dc198})
	/usr/local/go/src/runtime/panic.go:884 +0x212
main.normalHandler({0x10a6158, 0xc000326000}, 0xc000310400)
	/work/main.go:116 +0x625
net/http.HandlerFunc.ServeHTTP(0xc00032a000?, {0x10a6158?, 0xc000326000?}, 0xb?)
	/usr/local/go/src/net/http/server.go:2109 +0x2f
github.com/getsentry/sentry-go/http.(*Handler).handle.func1({0x10a6158, 0xc000326000}, 0xc000310100)
	/go/pkg/mod/github.com/getsentry/[email protected]/http/sentryhttp.go:103 +0x3c3
net/http.HandlerFunc.ServeHTTP(0xc000326000?, {0x10a6158?, 0xc000326000?}, 0xdeeb03?)
	/usr/local/go/src/net/http/server.go:2109 +0x2f
net/http.(*ServeMux).ServeHTTP(0x0?, {0x10a6158, 0xc000326000}, 0xc000310100)
	/usr/local/go/src/net/http/server.go:2487 +0x149
net/http.serverHandler.ServeHTTP({0x10a4fe0?}, {0x10a6158, 0xc000326000}, 0xc000310100)
	/usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0000000a0, {0x10a6740, 0xc0002d55c0})
	/usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:3102 +0x4db

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.