Skip to content

Commit 68fe1a3

Browse files
committed
fix backend,add logger,update readme
1 parent 0cccfe4 commit 68fe1a3

File tree

22 files changed

+289
-208
lines changed

22 files changed

+289
-208
lines changed

.github/workflows/master-build.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name: master
99
- master
1010

1111
jobs:
12-
build_and_publish:
12+
build_and_publish_dockerhub:
1313
runs-on: ubuntu-latest
1414
steps:
1515
-
@@ -25,8 +25,22 @@ jobs:
2525
username: ${{ secrets.DOCKERHUB_USERNAME }}
2626
password: ${{ secrets.DOCKERHUB_TOKEN }}
2727
-
28-
name: Build and push
28+
name: Build/Push to Docker Hub
2929
uses: docker/build-push-action@v3
3030
with:
3131
push: true
3232
tags: larscom/gitlab-ci-dashboard:master
33+
34+
build_and_publish_gcr:
35+
runs-on: ubuntu-latest
36+
steps:
37+
- uses: actions/checkout@v3
38+
-
39+
name: Build/Push to Google Cloud Registry
40+
uses: RafikFarhad/push-to-gcr-github-action@v5-beta
41+
with:
42+
gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
43+
registry: gcr.io
44+
project_id: gitlab-ci-dashboard-370412
45+
image_name: larscom/gitlab-ci-dashboard
46+
image_tag: master

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ npm-debug.log
1313
yarn-error.log
1414

1515
# local env files
16-
*.env*
16+
*local.env*
1717

1818
# IDEs and editors
1919
.idea/

README.md

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,81 @@
33
[![Docker Image Version](https://img.shields.io/docker/v/larscom/gitlab-ci-dashboard?sort=semver&label=latest%20release&color=blue)](https://hub.docker.com/r/larscom/gitlab-ci-dashboard)
44
[![Docker Image Size](https://img.shields.io/docker/image-size/larscom/gitlab-ci-dashboard?sort=semver)](https://hub.docker.com/r/larscom/gitlab-ci-dashboard)
55
[![License MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6-
[![master](https://github.com/larscom/gitlab-ci-dashboard/actions/workflows/master-build.yml/badge.svg?branch=master)](https://github.com/larscom/gitlab-ci-dashboard/actions/workflows/master-build.yml)
6+
[![master](https://github.com/larscom/gitlab-ci-dashboard/actions/workflows/master-build.yml/badge.svg?branch=master)](https://github.com/larscom/gitlab-ci-dashboard)
77
[![Docker Image Version By Date](https://img.shields.io/docker/v/larscom/gitlab-ci-dashboard?color=violet&label=latest%20build&sort=date)](https://hub.docker.com/r/larscom/gitlab-ci-dashboard/tags?page=1&name=master)
88

9-
> Gitlab CI Dashboard will provide information about all pipeline statuses in Gitlab in one overview.
9+
## :fire: Notice
10+
11+
This app is under heavy development, not all features might be fully implemented yet :wink:
12+
13+
> Gitlab CI Dashboard will provide you information about all pipeline statuses in Gitlab.
14+
15+
### [Demo Dashboard](https://gitlab-ci-dashboard-g2yczvalwa-ez.a.run.app)
1016

1117
## Highlights
1218

13-
- View Gitlab CI pipeline statuses
14-
- Communication to the Gitlab API happens server side (so only one API token needed)
15-
- Read only (write actions needs to be done in Gitlab)
19+
- View Gitlab CI pipeline statuses (maybe more functionality will be added later) uses the default branch by default
20+
- Communication to the Gitlab API happens server side (only 1 `read only` token is needed for you or your team)
1621
- Easy navigation to Gitlab from within the dashboard
17-
- Small in size, low memory usage
18-
- Shows all groups within Gitlab by default (configurable)
22+
- Configurable caching (to handle rate limit or reduce load)
1923

2024
## Requirements
2125

22-
- Gitlab server (self hosted or https://gitlab.com)
23-
- Supports `v4` only of the Gitlab API
26+
- Gitlab server (can be self hosted)
27+
- Supports only `v4` of the Gitlab API
2428
- Docker
2529

30+
## Versioning
31+
32+
- larscom/gitlab-ci-dashboard:x.x.x `specific release version, e.g: 1.1.0`
33+
- larscom/gitlab-ci-dashboard:latest `latest release`
34+
- larscom/gitlab-ci-dashboard:master `latest master build`
35+
2636
## Getting started
2737

2838
1. Generate a `read_api` access token in Gitlab (e.g: https://gitlab.com/-/profile/personal_access_tokens)
2939

3040
![Access Token](https://github.com/larscom/gitlab-ci-dashboard/blob/master/.github/img/access_token.png)
3141

32-
2. Run docker command with the required environment variables (GITLAB_BASE_URL, GITLAB_API_TOKEN)
42+
2. Run docker with the required environment variables (GITLAB_BASE_URL, GITLAB_API_TOKEN)
3343

3444
```bash
35-
docker run -p 8080:8080 -e GITLAB_BASE_URL=https://gitlab.com -e GITLAB_API_TOKEN=my_token larscom/gitlab-ci-dashboard:latest
45+
docker run -p 8080:8080 -e GITLAB_BASE_URL=https://example.gitlab.com -e GITLAB_API_TOKEN=my_token larscom/gitlab-ci-dashboard
3646
```
3747

3848
3. Dashboard should be available at: http://localhost:8080/#/ showing (by default) all available groups and their projects
3949

40-
## Environment variables
50+
## Gitlab specific env variables
51+
52+
| Variable | Type | Description | Required | Default |
53+
| --------------------------- | ------- | ------------------------------------------------------------------------------------------------------ | -------- | ------- |
54+
| GITLAB_BASE_URL | string | The base url to the Gitlab server (e.g: https://gitlab.com) | yes | |
55+
| GITLAB_API_TOKEN | string | A readonly access token generated in Gitlab (see: https://gitlab.com/-/profile/personal_access_tokens) | yes | |
56+
| GITLAB_GROUP_ONLY_IDS | string | Provide a comma seperated string of group ids which will only be displayed (e.g: 123,789,888) | no | |
57+
| GITLAB_GROUP_SKIP_IDS | string | Provide a comma seperated string of group ids which will be ignored (e.g: 123,789,888) | no | |
58+
| GITLAB_GROUP_ONLY_TOP_LEVEL | boolean | Show only top level groups | no | false |
59+
60+
## Server specific env variables
4161

42-
| Variable | Type | Description | Required |
43-
| --------------------------- | ------- | ------------------------------------------------------------------------------------------------------ | -------- |
44-
| GITLAB_BASE_URL | string | The base url to the Gitlab server (e.g: https://gitlab.com) | yes |
45-
| GITLAB_API_TOKEN | string | A readonly access token generated in Gitlab (see: https://gitlab.com/-/profile/personal_access_tokens) | yes |
46-
| GITLAB_GROUP_ONLY_IDS | string | Provide a comma seperated string of group ids which will only be visibile (e.g: 123,789,888) | no |
47-
| GITLAB_GROUP_SKIP_IDS | string | Provide a comma seperated string of group ids which will be ignored (e.g: 123,789,888) | no |
48-
| GITLAB_GROUP_ONLY_TOP_LEVEL | boolean | Show only top level groups (no child groups) | no |
62+
| Variable | Type | Description | Default |
63+
| ----------------------------- | ------- | ------------------------------------------------------- | ------- |
64+
| SERVER_REST_CACHE_TTL_SECONDS | integer | Time to Live (in seconds) for projects/groups/pipelines | 10 |
65+
| SERVER_DEBUG | boolean | Gives you more logging to see what is happening | false |
4966

5067
## Why?
5168

5269
At the moment there is no overview of all pipeline statuses within Gitlab, so you might not be aware of a failed pipeline somewhere in Gitlab.
5370

54-
This dashboard is not a replacement for Gitlab, it is supposed to give you a `readonly` overview of all pipelines (configurable) within a Gitlab server.
71+
This dashboard is `not` a replacement for Gitlab, it is supposed to give you a `readonly` overview of all pipelines (configurable) within a Gitlab server. Maybe more functionality is there to come later.
5572

56-
## :fire: Notice
73+
## Run without docker (development)
5774

58-
This app is under heavy development, not all features might be fully implemented yet :wink:
75+
Be sure you have the following dependencies installed
76+
- Node 14+
77+
- Go 1.19+
78+
79+
1. Run: `mv ./api/.local.example.env ./api/.local.env` <-- fill in the required env variables
80+
2. Run: `npm ci` <-- install frontend packages
81+
3. Run: `npm run api` <-- starts backend
82+
4. Run: `npm start` <-- starts frontend
83+
5. Open browser and goto: http://localhost:4200

api/.local.example.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
GITLAB_BASE_URL=https://gitlab.com
2+
GITLAB_API_TOKEN=mygeneratedtoken
3+
SERVER_DEBUG=true
4+
# SERVER_REST_CACHE_TTL_SECONDS=60
5+
# GITLAB_GROUP_ONLY_IDS=10,13

api/cmd/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ func main() {
1414
fmt.Println("Loading environment: .local.env")
1515
godotenv.Load(".local.env")
1616

17-
appConfig := config.NewAppConfig()
17+
appConfig := config.NewGitlabConfig()
1818
gitlabClient, err := gitlab.NewClient(appConfig.GitlabToken, gitlab.WithBaseURL(appConfig.GitlabUrl))
1919
if err != nil {
2020
log.Fatalf("Failed to create gitlabClient: %v", err)
2121
}
22-
echo := server.NewServer(gitlabClient, appConfig)
22+
23+
serverConfig := config.NewServerConfig()
24+
echo := server.NewServer(gitlabClient, serverConfig, appConfig)
2325

2426
echo.Logger.Fatal(echo.Start(":8080"))
2527
}

api/config/app_config.go renamed to api/config/gitlab_config.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@ import (
88
"strings"
99
)
1010

11-
type AppConfig struct {
11+
type GitlabConfig struct {
1212
GitlabToken string
1313
GitlabUrl string
14-
GitlabGroupSkipIds []int
15-
GitlabGroupOnlyIds []int
14+
GitlabGroupSkipIds *[]int
15+
GitlabGroupOnlyIds *[]int
1616
GitlabGroupOnlyTopLevel bool
1717
}
1818

19-
func NewAppConfig() *AppConfig {
19+
func NewGitlabConfig() *GitlabConfig {
2020
gitlabUrl := getBaseUrl()
2121
gitlabToken := getToken()
2222
gitlabGroupSkipIds := getSkippedGroupIds()
2323
gitlabGroupOnlyIds := getOnlyGroupIds()
2424
gitlabGroupOnlyTopLevel := getOnlyTopLevelGroups()
2525

26-
return &AppConfig{
26+
return &GitlabConfig{
2727
GitlabUrl: gitlabUrl,
2828
GitlabToken: gitlabToken,
29-
GitlabGroupSkipIds: *gitlabGroupSkipIds,
30-
GitlabGroupOnlyIds: *gitlabGroupOnlyIds,
29+
GitlabGroupSkipIds: gitlabGroupSkipIds,
30+
GitlabGroupOnlyIds: gitlabGroupOnlyIds,
3131
GitlabGroupOnlyTopLevel: gitlabGroupOnlyTopLevel,
3232
}
3333
}
@@ -94,7 +94,7 @@ func getOnlyTopLevelGroups() bool {
9494
var err error = nil
9595
onlyTopLevelGroups, err = strconv.ParseBool(onlyTopLevelString)
9696
if err != nil {
97-
log.Fatal("'GITLAB_GROUP_ONLY_TOP_LEVEL' should be of type: boolean")
97+
log.Fatalf("GITLAB_GROUP_ONLY_TOP_LEVEL contains: '%s' which is not a boolean", onlyTopLevelString)
9898
}
9999
fmt.Printf("GITLAB_GROUP_ONLY_TOP_LEVEL=%t\n", onlyTopLevelGroups)
100100
}

api/config/server_config.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package config
2+
3+
import (
4+
"fmt"
5+
"log"
6+
"os"
7+
"strconv"
8+
)
9+
10+
type ServerConfig struct {
11+
CacheTTLSeconds int
12+
Debug bool
13+
}
14+
15+
func NewServerConfig() *ServerConfig {
16+
return &ServerConfig{
17+
CacheTTLSeconds: getCacheTTLSeconds(),
18+
Debug: getDebug(),
19+
}
20+
}
21+
22+
func getCacheTTLSeconds() int {
23+
var cacheTTL = 10
24+
25+
ttlString, found := os.LookupEnv("SERVER_REST_CACHE_TTL_SECONDS")
26+
if found {
27+
val, err := strconv.Atoi(ttlString)
28+
if err != nil {
29+
log.Fatalf("SERVER_REST_CACHE_TTL_SECONDS contains: '%s' which is not an integer", ttlString)
30+
}
31+
cacheTTL = val
32+
fmt.Printf("SERVER_REST_CACHE_TTL_SECONDS=%d\n", cacheTTL)
33+
}
34+
35+
return cacheTTL
36+
}
37+
38+
func getDebug() bool {
39+
var debug = false
40+
41+
debugString, found := os.LookupEnv("SERVER_DEBUG")
42+
if found {
43+
val, err := strconv.ParseBool(debugString)
44+
if err != nil {
45+
log.Fatalf("SERVER_DEBUG contains: '%s' which is not a boolean", debugString)
46+
}
47+
debug = val
48+
fmt.Printf("SERVER_DEBUG=%v\n", debug)
49+
}
50+
51+
return debug
52+
}

api/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ require (
1818
github.com/labstack/gommon v0.4.0 // indirect
1919
github.com/mattn/go-colorable v0.1.13 // indirect
2020
github.com/mattn/go-isatty v0.0.16 // indirect
21+
github.com/rs/zerolog v1.28.0 // indirect
2122
github.com/stretchr/testify v1.8.1 // indirect
2223
github.com/valyala/bytebufferpool v1.0.0 // indirect
2324
github.com/valyala/fasttemplate v1.2.2 // indirect

api/go.sum

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
1313
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
1414
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
1515
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
16+
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
1617
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
1718
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
1819
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -27,6 +28,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
2728
github.com/go-redis/cache/v8 v8.0.0-beta.11/go.mod h1:4wxD/neK+Uw+SteOR+AXtlyQYMBlI/D1u7UahfDCBAI=
2829
github.com/go-redis/redis/v8 v8.0.0-beta.2/go.mod h1:o1M7JtsgfDYyv3o+gBn/jJ1LkqpnCrmil7PSppZGBak=
2930
github.com/go-redis/redis/v8 v8.0.0-beta.5/go.mod h1:Mm9EH/5UMRx680UIryN6rd5XFn/L7zORPqLV+1D5thQ=
31+
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
3032
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
3133
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
3234
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
@@ -83,6 +85,7 @@ github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVc
8385
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
8486
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
8587
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
88+
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
8689
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
8790
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
8891
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
@@ -96,9 +99,13 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W
9699
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
97100
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
98101
github.com/opentracing/opentracing-go v1.1.1-0.20190913142402-a7454ce5950e/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
102+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
99103
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
100104
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
101105
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
106+
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
107+
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
108+
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
102109
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
103110
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
104111
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=

api/group/group_controller.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,5 @@ func NewGroupController(groupService *GroupService) *GroupController {
1717
}
1818

1919
func (g *GroupController) GetGroups(c echo.Context) error {
20-
groups, errDto := g.groupService.GetGroups()
21-
if errDto != nil {
22-
return c.JSON(errDto.StatusCode, errDto)
23-
}
24-
25-
return c.JSON(http.StatusOK, groups)
20+
return c.JSON(http.StatusOK, g.groupService.GetGroups())
2621
}

0 commit comments

Comments
 (0)