Skip to content

Commit

Permalink
merge master into feat/trigger-name-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrMatsko committed Sep 24, 2024
2 parents b389960 + d51fffa commit f101d93
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 41 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

- run: make build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
4 changes: 2 additions & 2 deletions .github/workflows/docker-feature.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
if: ${{github.event.issue.pull_request != null && startsWith(github.event.comment.body, '/build') && github.event.comment.author_association == 'MEMBER'}}
steps:
- name: Get PR branch
uses: xt0rted/pull-request-comment-branch@v1
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch

- uses: actions/github-script@v6
Expand All @@ -38,7 +38,7 @@ jobs:

- name: Checkout PR branch
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: ${{ fromJSON(steps.get-pr.outputs.result).head.repo.full_name }}
ref: ${{ fromJSON(steps.get-pr.outputs.result).head.sha }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ jobs:
name: lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version-file: go.mod

- name: Run linter
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.56.2

2 changes: 1 addition & 1 deletion .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
name: Create Release
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Ruby 3.3
uses: ruby/setup-ruby@v1
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/swagger-delete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
name: Delete api from SwaggerHub
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '16.16.0'
node-version: '20.17.0'
- run: npm i --location=global swaggerhub-cli
- run: |
VERSION=`echo ${GITHUB_REF_NAME}| sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/swagger-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ jobs:
working-directory: .

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- run: make install-swag

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16.16.0'
node-version: '20.17.0'
- run: npm install --location=global @openapitools/openapi-generator-cli
- run: make spec
- run: make validate-spec
Expand All @@ -45,10 +45,10 @@ jobs:
working-directory: .

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Download spec file artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.7
with:
name: specfile
path: docs
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/swagger-validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ jobs:
working-directory: .

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache-dependency-path: go.sum
- run: make install-swag

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '20.11.0'
node-version: '20.17.0'
- run: npm install --location=global @openapitools/openapi-generator-cli
- run: make spec
- run: make validate-spec
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ mock:

.PHONY: install-swag
install-swag:
go install github.com/swaggo/swag/cmd/swag@v1.8.12
go install github.com/swaggo/swag/cmd/swag@v1.16.3

.PHONY: spec
spec:
Expand Down
26 changes: 14 additions & 12 deletions cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ type RedisConfig struct {
// GetSettings returns redis config parsed from moira config files.
func (config *RedisConfig) GetSettings() redis.DatabaseConfig {
return redis.DatabaseConfig{
MasterName: config.MasterName,
Addrs: strings.Split(config.Addrs, ","),
Username: config.Username,
Password: config.Password,
MaxRetries: config.MaxRetries,
MetricsTTL: to.Duration(config.MetricsTTL),
DialTimeout: to.Duration(config.DialTimeout),
ReadTimeout: to.Duration(config.ReadTimeout),
WriteTimeout: to.Duration(config.WriteTimeout),
ReadOnly: config.ReadOnly,
RouteByLatency: config.RouteByLatency,
RouteRandomly: config.RouteRandomly,
MasterName: config.MasterName,
Addrs: strings.Split(config.Addrs, ","),
Username: config.Username,
Password: config.Password,
SentinelUsername: config.SentinelUsername,
SentinelPassword: config.SentinelPassword,
MaxRetries: config.MaxRetries,
MetricsTTL: to.Duration(config.MetricsTTL),
DialTimeout: to.Duration(config.DialTimeout),
ReadTimeout: to.Duration(config.ReadTimeout),
WriteTimeout: to.Duration(config.WriteTimeout),
ReadOnly: config.ReadOnly,
RouteByLatency: config.RouteByLatency,
RouteRandomly: config.RouteRandomly,
}
}

Expand Down
61 changes: 61 additions & 0 deletions cmd/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package cmd

import (
"testing"
"time"

"github.com/moira-alert/moira/database/redis"
. "github.com/smartystreets/goconvey/convey"
)

func TestRedisConfig(t *testing.T) {
Convey("Test RedisConfig.GetSettings", t, func() {
Convey("With empty config", func() {
redisCfg := RedisConfig{}

expected := redis.DatabaseConfig{
Addrs: []string{""},
}
databaseCfg := redisCfg.GetSettings()
So(databaseCfg, ShouldResemble, expected)
})

Convey("With filled config", func() {
redisCfg := RedisConfig{
MasterName: "test-master",
Addrs: "redis1:6379",
SentinelUsername: "sentinel-user",
SentinelPassword: "sentinel-pass",
Username: "user",
Password: "pass",
MetricsTTL: "1m",
DialTimeout: "1m",
ReadTimeout: "1m",
WriteTimeout: "1m",
MaxRetries: 3,
ReadOnly: true,
RouteByLatency: true,
RouteRandomly: true,
}

expected := redis.DatabaseConfig{
MasterName: "test-master",
Addrs: []string{"redis1:6379"},
SentinelUsername: "sentinel-user",
SentinelPassword: "sentinel-pass",
Username: "user",
Password: "pass",
MetricsTTL: time.Minute,
DialTimeout: time.Minute,
ReadTimeout: time.Minute,
WriteTimeout: time.Minute,
MaxRetries: 3,
ReadOnly: true,
RouteByLatency: true,
RouteRandomly: true,
}
databaseCfg := redisCfg.GetSettings()
So(databaseCfg, ShouldResemble, expected)
})
})
}
5 changes: 2 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/prometheus/client_golang v1.14.0
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475
github.com/rs/cors v1.9.0
github.com/rs/cors v1.11.0
github.com/rs/zerolog v1.29.0
github.com/russross/blackfriday/v2 v2.1.0
github.com/slack-go/slack v0.12.1
Expand All @@ -46,7 +46,6 @@ require (
require github.com/prometheus/common v0.37.0

require (
github.com/golang/mock v1.6.0
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/mattermost/mattermost/server/public v0.1.1
github.com/mitchellh/mapstructure v1.5.0
Expand Down Expand Up @@ -159,7 +158,7 @@ require (
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 // indirect
golang.org/x/image v0.13.0 // indirect
golang.org/x/image v0.18.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sys v0.21.0 // indirect
Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8=
github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -1081,8 +1080,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/cors v1.9.0 h1:l9HGsTsHJcvW14Nk7J9KFz8bzeAWXn3CG6bgt7LsrAE=
github.com/rs/cors v1.9.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w=
github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
Expand Down Expand Up @@ -1280,8 +1279,8 @@ golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXy
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.13.0 h1:3cge/F/QTkNLauhf2QoE9zp+7sr+ZcL4HnoZmdwg9sg=
golang.org/x/image v0.13.0/go.mod h1:6mmbMOeV28HuMTgA6OSRkdXKYw/t5W9Uwn2Yv1r3Yxk=
golang.org/x/image v0.18.0 h1:jGzIakQa/ZXI1I0Fxvaa9W7yP25TqT6cHIHn+6CqvSQ=
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand Down

0 comments on commit f101d93

Please sign in to comment.