From 0d00a87eaad9588da6f35d8898e73959b1685d96 Mon Sep 17 00:00:00 2001 From: Mayco Lacerda Date: Wed, 23 Aug 2023 14:18:27 -0300 Subject: [PATCH 1/5] Feat: adding status and WebURL to the rulesheet. --- dtos/rulesheets.go | 2 ++ node_modules/.yarn-integrity | 10 ++++++++++ services/gitlab.go | 9 +++++++++ yarn.lock | 4 ++++ 4 files changed, 25 insertions(+) create mode 100644 node_modules/.yarn-integrity create mode 100644 yarn.lock diff --git a/dtos/rulesheets.go b/dtos/rulesheets.go index b808b7f..27b46b5 100644 --- a/dtos/rulesheets.go +++ b/dtos/rulesheets.go @@ -38,6 +38,8 @@ type Rulesheet struct { Slug string HasStringRule bool Version string + Status string + WebURL string Features *[]map[string]interface{} Parameters *[]map[string]interface{} Rules *map[string]interface{} diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity new file mode 100644 index 0000000..56c28ed --- /dev/null +++ b/node_modules/.yarn-integrity @@ -0,0 +1,10 @@ +{ + "systemParams": "win32-x64-108", + "modulesFolders": [], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/services/gitlab.go b/services/gitlab.go index 509c6c2..4e28cd3 100644 --- a/services/gitlab.go +++ b/services/gitlab.go @@ -394,6 +394,15 @@ func (gs *gitlabService) Fill(rulesheet *dtos.Rulesheet) (err error) { rulesheet.Rules = &rules } + pipeline, response, err := git.Pipelines.GetPipeline(proj.ID, 1) + if err != nil { + log.Errorf("Failed to fetch pipeline: %v", err) + } else { + rulesheet.Status = pipeline.Status + rulesheet.WebURL = pipeline.WebURL + log.Infof("Pipeline Status: %v", response.StatusCode) + } + return } diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + From f81c89c6f08efca603b736c401b2d1ce0e7aa1b1 Mon Sep 17 00:00:00 2001 From: Mayco Lacerda Date: Thu, 24 Aug 2023 13:20:47 -0300 Subject: [PATCH 2/5] Feat: updating support for latest pipeline --- api.http | 11 ++++++++++- go.mod | 24 ++++++++++++------------ go.sum | 44 +++++++++++++++++++++++++------------------- services/gitlab.go | 2 +- 4 files changed, 48 insertions(+), 33 deletions(-) diff --git a/api.http b/api.http index 95a8a0a..3ce1298 100644 --- a/api.http +++ b/api.http @@ -1,4 +1,4 @@ -GET {{url}}/api/v1/rulesheets +GET {{localhost:9007}}/api/v1/rulesheets X-API-Key: 123 ### @@ -22,3 +22,12 @@ X-API-Key: 123 "name": "teste Swagger Dokku", "slug": "teste_Swagger_dokku" } + +### +POST http://localhost:9007/api/v1/eval/rules-jamie-menu-64623317-d00c-4508-8db3-613d1ed24638/ +Content-Type: application/json +X-API-Key: 123 + +{ + "idade":13 +} diff --git a/go.mod b/go.mod index c39eeab..98c7171 100644 --- a/go.mod +++ b/go.mod @@ -19,11 +19,11 @@ require ( github.com/prometheus/client_golang v1.12.1 github.com/sirupsen/logrus v1.9.0 github.com/spf13/viper v1.13.0 - github.com/stretchr/testify v1.8.0 + github.com/stretchr/testify v1.8.4 github.com/swaggo/gin-swagger v1.4.2 github.com/swaggo/swag v1.7.9 github.com/toorop/gin-logrus v0.0.0-20210225092905-2c785434f26f - github.com/xanzy/go-gitlab v0.63.0 + github.com/xanzy/go-gitlab v0.90.0 go.opentelemetry.io/otel/trace v1.8.0 gorm.io/driver/mysql v1.3.3 gorm.io/gorm v1.23.5 @@ -49,13 +49,13 @@ require ( github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-sql-driver/mysql v1.6.0 // indirect github.com/goccy/go-json v0.9.11 // indirect - github.com/golang/protobuf v1.5.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-querystring v1.1.0 // indirect github.com/gosimple/unidecode v1.0.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.6.8 // indirect + github.com/hashicorp/go-retryablehttp v0.7.2 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/jinzhu/now v1.1.5 // indirect @@ -85,7 +85,7 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - github.com/stretchr/objx v0.4.0 // indirect + github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.1 // indirect github.com/ugorji/go/codec v1.2.7 // indirect github.com/uptrace/opentelemetry-go-extra/otellogrus v0.1.15 // indirect @@ -95,14 +95,14 @@ require ( go.opentelemetry.io/otel/sdk v1.8.0 // indirect go.uber.org/atomic v1.7.0 // indirect golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect - golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 // indirect - golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect - golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect - golang.org/x/text v0.3.7 // indirect - golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 // indirect - golang.org/x/tools v0.1.11 // indirect + golang.org/x/net v0.8.0 // indirect + golang.org/x/oauth2 v0.6.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.6.0 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.28.0 // indirect + google.golang.org/protobuf v1.29.1 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/go.sum b/go.sum index 2e30c00..4e6eaf9 100644 --- a/go.sum +++ b/go.sum @@ -612,8 +612,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= +github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= @@ -727,8 +728,8 @@ github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-retryablehttp v0.6.8 h1:92lWxgpa+fF3FozM4B3UZtHZMJX8T5XT+TFdCxsPyWs= -github.com/hashicorp/go-retryablehttp v0.6.8/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= +github.com/hashicorp/go-retryablehttp v0.7.2 h1:AcYqCvkpalPnPF2pn0KamgwamS42TqUDDYFRKq/RAd0= +github.com/hashicorp/go-retryablehttp v0.7.2/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= @@ -1210,8 +1211,9 @@ github.com/stretchr/objx v0.0.0-20180129172003-8a3f7159479f/go.mod h1:HFkY916IF+ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v0.0.0-20180303142811-b89eecf5ca5d/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= @@ -1220,8 +1222,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs= github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= @@ -1268,8 +1271,8 @@ github.com/vishvananda/netns v0.0.0-20210104183010-2eb08e3e575f/go.mod h1:DD4vA1 github.com/willf/bitset v1.1.11-0.20200630133818-d5bec3311243/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/willf/bitset v1.1.11/go.mod h1:83CECat5yLh5zVOf4P1ErAgKA5UDvKtgyUABdr3+MjI= github.com/xanzy/go-gitlab v0.15.0/go.mod h1:8zdQa/ri1dfn8eS3Ir1SyfvOKlw7WBJ8DVThkpGiXrs= -github.com/xanzy/go-gitlab v0.63.0 h1:a9fXpKWykUS6dowapFej/2Wjf4aOAEFC1q2ZIcz4IpI= -github.com/xanzy/go-gitlab v0.63.0/go.mod h1:F0QEXwmqiBUxCgJm8fE9S+1veX4XC9Z4cfaAbqwk4YM= +github.com/xanzy/go-gitlab v0.90.0 h1:j8ZUHfLfXdnC+B8njeNaW/kM44c1zw8fiuNj7D+qQN8= +github.com/xanzy/go-gitlab v0.90.0/go.mod h1:5ryv+MnpZStBH8I/77HuQBsMbBGANtVpLWC15qOjWAw= github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= @@ -1443,7 +1446,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1516,8 +1519,8 @@ golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20220111093109-d55c255bac03/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 h1:NWy5+hlRbC7HK+PmcXVUmW1IMyFce7to56IUvhUFm7Y= -golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180227000427-d7d64896b5ff/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181106182150-f42d05182288/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1538,8 +1541,8 @@ golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.6.0 h1:Lh8GPgSKBfWSwFvtuWOfeI3aAAnbXTSutYxJiOJFgIw= +golang.org/x/oauth2 v0.6.0/go.mod h1:ycmewcwgD4Rpr3eZJLSB4Kyyljb3qDh40vJ8STE5HKw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1684,8 +1687,9 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220317061510-51cd9980dadf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1699,8 +1703,9 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -1709,8 +1714,9 @@ golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs= golang.org/x/time v0.0.0-20220224211638-0e9765cccd65/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= +golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1792,8 +1798,8 @@ golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= -golang.org/x/tools v0.1.11 h1:loJ25fNOEhSXfHrpoGj91eCUThwdNX6u24rO1xnNteY= -golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1974,8 +1980,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.29.1 h1:7QBf+IK2gx70Ap/hDsOmam3GE0v9HicjfEdAxE62UoM= +google.golang.org/protobuf v1.29.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 h1:FVCohIoYO7IJoDDVpV2pdq7SgrMH6wHnuTyrdrxJNoY= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/services/gitlab.go b/services/gitlab.go index 4e28cd3..a6778cb 100644 --- a/services/gitlab.go +++ b/services/gitlab.go @@ -394,7 +394,7 @@ func (gs *gitlabService) Fill(rulesheet *dtos.Rulesheet) (err error) { rulesheet.Rules = &rules } - pipeline, response, err := git.Pipelines.GetPipeline(proj.ID, 1) + pipeline, response, err := git.Pipelines.GetLatestPipeline(proj.ID, nil, nil) if err != nil { log.Errorf("Failed to fetch pipeline: %v", err) } else { From 148e4d397e5e14b0ca8bbdb25c016e0d49acd8a9 Mon Sep 17 00:00:00 2001 From: Mayco Lacerda Date: Thu, 24 Aug 2023 13:48:54 -0300 Subject: [PATCH 3/5] Feat: updating support for latest pipeline --- responses/v1/rulesheet.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/responses/v1/rulesheet.go b/responses/v1/rulesheet.go index 1a834c6..885d58e 100644 --- a/responses/v1/rulesheet.go +++ b/responses/v1/rulesheet.go @@ -23,6 +23,8 @@ type Rulesheet struct { Description string `json:"description,omitempty"` Slug string `json:"slug,omitempty"` Version string `json:"version,omitempty"` + Status string `json:"status,omitempty"` + WebURL string `json:"web_url,omitempty"` Features *[]map[string]interface{} `json:"features,omitempty"` Parameters *[]map[string]interface{} `json:"parameters,omitempty"` Rules *map[string]interface{} `json:"rules,omitempty"` @@ -36,6 +38,8 @@ func NewRulesheet(dto *dtos.Rulesheet) Rulesheet { Description: dto.Description, Slug: dto.Slug, Version: dto.Version, + Status: dto.Status, + WebURL: dto.WebURL, Features: dto.Features, Parameters: dto.Parameters, Rules: dto.Rules, From 2ad6d350c0e7d819d3950c5357084d0238be27ad Mon Sep 17 00:00:00 2001 From: Mayco Lacerda Date: Thu, 24 Aug 2023 14:10:58 -0300 Subject: [PATCH 4/5] Feat: updating ruleshets fields --- dtos/rulesheets.go | 22 ++++++++++----------- responses/v1/rulesheet.go | 40 +++++++++++++++++++-------------------- services/gitlab.go | 2 +- 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/dtos/rulesheets.go b/dtos/rulesheets.go index 27b46b5..609b9b3 100644 --- a/dtos/rulesheets.go +++ b/dtos/rulesheets.go @@ -32,17 +32,17 @@ type Rule struct { // - Parameters: a pointer to a slice of maps, where each map represents a parameter that can be used in the rules defined in the `Rules` property. Each mapcontains key-value pairs where the key is a string representing the name of the parameter and the value is an interface{} // - Rules: property is a pointer to a map of string keys and interface values. This map represents the set of rules that are associated with the rulesheet. Each key in the map represents a unique rule identifier, and the corresponding value is an interface that can be usedto store any type of data. The use of `interface` allows for flexibility in the type of data that can be stored in the map. type Rulesheet struct { - ID uint - Name string - Description string - Slug string - HasStringRule bool - Version string - Status string - WebURL string - Features *[]map[string]interface{} - Parameters *[]map[string]interface{} - Rules *map[string]interface{} + ID uint + Name string + Description string + Slug string + HasStringRule bool + Version string + PipelineStatus string + WebURL string + Features *[]map[string]interface{} + Parameters *[]map[string]interface{} + Rules *map[string]interface{} } // NewRulesheetV1 takes in a payload of rulesheet and returns a DTO with the rules converted to a diff --git a/responses/v1/rulesheet.go b/responses/v1/rulesheet.go index 885d58e..3f67fb9 100644 --- a/responses/v1/rulesheet.go +++ b/responses/v1/rulesheet.go @@ -18,30 +18,30 @@ import "github.com/bancodobrasil/featws-api/dtos" // - Rules: a pointer to a map of string keys and interface values. This is likely where the actual rules for the rulesheet are stored. The keys in the map would likely correspond to some sort of rule identifier or name, and the values would contain the logic or conditions for. type Rulesheet struct { FindResult - ID uint `json:"id,omitempty"` - Name string `json:"name,omitempty"` - Description string `json:"description,omitempty"` - Slug string `json:"slug,omitempty"` - Version string `json:"version,omitempty"` - Status string `json:"status,omitempty"` - WebURL string `json:"web_url,omitempty"` - Features *[]map[string]interface{} `json:"features,omitempty"` - Parameters *[]map[string]interface{} `json:"parameters,omitempty"` - Rules *map[string]interface{} `json:"rules,omitempty"` + ID uint `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Description string `json:"description,omitempty"` + Slug string `json:"slug,omitempty"` + Version string `json:"version,omitempty"` + PipelineStatus string `json:"status,omitempty"` + WebURL string `json:"web_url,omitempty"` + Features *[]map[string]interface{} `json:"features,omitempty"` + Parameters *[]map[string]interface{} `json:"parameters,omitempty"` + Rules *map[string]interface{} `json:"rules,omitempty"` } // NewRulesheet creates a new Rulesheet object by copying data from a DTO object. func NewRulesheet(dto *dtos.Rulesheet) Rulesheet { return Rulesheet{ - ID: dto.ID, - Name: dto.Name, - Description: dto.Description, - Slug: dto.Slug, - Version: dto.Version, - Status: dto.Status, - WebURL: dto.WebURL, - Features: dto.Features, - Parameters: dto.Parameters, - Rules: dto.Rules, + ID: dto.ID, + Name: dto.Name, + Description: dto.Description, + Slug: dto.Slug, + Version: dto.Version, + PipelineStatus: dto.PipelineStatus, + WebURL: dto.WebURL, + Features: dto.Features, + Parameters: dto.Parameters, + Rules: dto.Rules, } } diff --git a/services/gitlab.go b/services/gitlab.go index a6778cb..e409ffc 100644 --- a/services/gitlab.go +++ b/services/gitlab.go @@ -398,7 +398,7 @@ func (gs *gitlabService) Fill(rulesheet *dtos.Rulesheet) (err error) { if err != nil { log.Errorf("Failed to fetch pipeline: %v", err) } else { - rulesheet.Status = pipeline.Status + rulesheet.PipelineStatus = pipeline.Status rulesheet.WebURL = pipeline.WebURL log.Infof("Pipeline Status: %v", response.StatusCode) } From cc717c6dc9db0f697856517f1836b9b1ebb45c9c Mon Sep 17 00:00:00 2001 From: Mayco Lacerda Date: Fri, 25 Aug 2023 11:12:09 -0300 Subject: [PATCH 5/5] Update gitlab_test.go --- services/gitlab_test.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/services/gitlab_test.go b/services/gitlab_test.go index 09fdd47..b5c64b4 100644 --- a/services/gitlab_test.go +++ b/services/gitlab_test.go @@ -653,6 +653,10 @@ func TestFill(t *testing.T) { w.Write([]byte(`{"id":1,"name":"teste", "full_path":"testpath"}`)) return } + if r.URL.Path == "/api/v4/projects/1/pipelines/latest" { + w.Write([]byte(`{ "PippelineStatus": "success", "webURL": "testURL"}`)) + + } if r.Method == "GET" && r.URL.Path == "/api/v4/projects/testpath/prefix-test" { w.Write([]byte(`{"id":1,"description":"testeDesc","name":"teste"}`)) @@ -774,6 +778,10 @@ func TestFillJSON(t *testing.T) { w.Write([]byte(`{"id":1,"name":"teste", "full_path":"testpath"}`)) return } + if r.URL.Path == "/api/v4/projects/1/pipelines/latest" { + w.Write([]byte(`{ "PippelineStatus": "success", "webURL": "testURL"}`)) + + } if r.Method == "GET" && r.URL.Path == "/api/v4/projects/testpath/prefix-test" { w.Write([]byte(`{"id":1,"description":"testeDesc","name":"teste"}`)) @@ -897,7 +905,10 @@ func TestFillRulesSlices(t *testing.T) { w.Write([]byte(`{"id":1,"name":"teste", "full_path":"testpath"}`)) return } + if r.URL.Path == "/api/v4/projects/1/pipelines/latest" { + w.Write([]byte(`{ "PippelineStatus": "success", "webURL": "testURL"}`)) + } if r.Method == "GET" && r.URL.Path == "/api/v4/projects/testpath/prefix-test" { w.Write([]byte(`{"id":1,"description":"testeDesc","name":"teste"}`)) return