Skip to content

Commit

Permalink
Allows for more flexible secureData to be set (#230)
Browse files Browse the repository at this point in the history
* Allows for more flexible secureData to be set

Fixes #229

* Some updates and cleanup to the documentation

* Updating mock generation
  • Loading branch information
safaci2000 authored Dec 14, 2023
1 parent 560d874 commit 7503ab7
Show file tree
Hide file tree
Showing 45 changed files with 4,509 additions and 784 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code_scanners.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: "1.21.3"
go-version: "1.21.5"
cache: false
- name: Install Task
run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
test:
strategy:
matrix:
go: [ {version: 1.21.3, token: 1}, {version: 1.21.3, token: 0}]
go: [ {version: 1.21.5, token: 1}, {version: 1.21.5, token: 0}]
grafana: [ 10.1.4 ]

env:
Expand Down Expand Up @@ -40,11 +40,11 @@ jobs:
run: |
echo "token IS $TEST_TOKEN_CONFIG"
- name: Calc coverage
if: "${{ matrix.go.version == '1.21.3' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
if: "${{ matrix.go.version == '1.21.5' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
run: |
go test -v -covermode=atomic -coverprofile=coverage.out ./...
- name: Convert coverage.out to coverage.lcov
if: "${{ matrix.go.version == '1.21.3' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
if: "${{ matrix.go.version == '1.21.5' && matrix.grafana == '10.1.4' && matrix.go.token == '0' }}"
uses: jandelgado/gcov2lcov-action@v1.0.9
- name: Test
if: "${{ matrix.go.token == '1' }}"
Expand Down
13 changes: 13 additions & 0 deletions .mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
with-expecter: true
recursive: false
all: true
dir: "{{.InterfaceDir}}/mocks"
outpkg: "mocks"
filename: "{{.InterfaceName}}.go"
mockname: "{{.InterfaceName}}"
packages:
github.com/esnet/gdg/internal/service:
config:
all: true
dir: "{{.InterfaceDir}}/mocks"
outpkg: "mocks"
3 changes: 2 additions & 1 deletion Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ tasks:
mocks:
desc: "Re-generate Mocks"
cmds:
- mockery --dir=internal/service/ --output=internal/service/mocks --outpkg=mocks --all
- rm -fr internal/service/mocks
- mockery
linux:
desc: "Build linux binary"
cmds:
Expand Down
4 changes: 2 additions & 2 deletions cli/test/conections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ func TestConnectionCommand(t *testing.T) {
},
}

testSvc.On("InitOrganizations").Return(nil)
testSvc.On("ListConnections", mock.Anything).Return(resp)
testSvc.EXPECT().InitOrganizations().Return()
testSvc.EXPECT().ListConnections(mock.Anything).Return(resp)

optionMockSvc := func() support.RootOption {
return func(response *support.RootCommand) {
Expand Down
2 changes: 1 addition & 1 deletion cli/test/devel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestDevelSrvInfo(t *testing.T) {
expected["Commit"] = "commit"
expected["Version"] = "version"

mock.On("GetServerInfo").Return(expected)
mock.EXPECT().GetServerInfo().Return(expected)
err := cli.Execute(string(data), []string{"tools", "devel", "srvinfo"}, optionMockSvc())
return err
}
Expand Down
28 changes: 7 additions & 21 deletions config/importer-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,16 @@ contexts:
regex: "misc"
- field: "url"
value: ".*esproxy2*"
auth:
user: user
password: password
secure_data: "default.json"
- rules:
- field: "url"
regex: ".*esproxy2*"
auth:
user: admin
password: secret
secure_data: "default.json"
- rules:
# Default
- field: "name"
regex: ".*"
auth:
user: user
password: password
secure_data: "default.json"
url: http://grafana:3000
user_name: admin
password: admin
Expand All @@ -72,16 +66,12 @@ contexts:
- rules:
- field: "name"
regex: "(?i)complex name"
auth:
user: test
password: secret
secure_data: "default.json"
# Default
- rules:
- field: "name"
regex: ".*"
auth:
user: user
password: password
secure_data: "default.json"
url: https://grafana.com
user_name: admin
password: admin
Expand All @@ -98,16 +88,12 @@ contexts:
- rules:
- field: "name"
regex: "(?i)complex name"
auth:
user: test
password: secret
secure_data: "default.json"
- rules:
# Default
- field: "name"
regex: ".*"
auth:
user: user
password: password
secure_data: "default.json"
url: https://staging.grafana.com
organization_id: 1
filter_override:
Expand Down
30 changes: 8 additions & 22 deletions config/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,11 @@ contexts:
regex: "misc"
- field: "url"
regex: ".*esproxy2*"
auth:
user: admin
password: secret
secure_data: "default.json"
- rules:
- field: "name"
regex: ".*"
auth:
user: user
password: password
secure_data: "default.json"
url: http://localhost:3000
user_name: admin
password: admin
Expand All @@ -34,16 +30,12 @@ contexts:
- rules:
- field: "name"
regex: "(?i)complex name"
auth:
password: secret
user: test
secure_data: "default.json"
- rules:
- match:
- field: "name"
regex: ".*"
auth:
password: password
user: user
secure_data: "default.json"

url: https://grafana.com
user_name: admin
Expand All @@ -53,29 +45,23 @@ contexts:
watched:
- General
qa:
output_path: qa
output_path: test/data
token: <CHANGEME>
connections:
credential_rules:
- rules:
- field: "name"
regex: "(?i)complex name"
auth:
user: test
password: secret
secure_data: "complex.json"
- rules:
- field: "name"
regex: "ds_name"
auth:
user: abcd
password: secret
secure_data: "default.json"
# Default
- rules:
- field: "name"
regex: ".*"
auth:
user: user
password: password
secure_data: "default.json"
url: https://staging.grafana.com
organization: your-org
ignore_filters: False # When set to true all Watched filtered folders will be ignored and ALL folders will be acted on
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ services:
environment:
- GF_INSTALL_PLUGINS=grafana-googlesheets-datasource

influx:
image: influxdb:latest
container_name: influxdb
security_opt:
- no-new-privileges:true
restart: unless-stopped
ports:
- "8086:8086"
Loading

0 comments on commit 7503ab7

Please sign in to comment.