Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Add linting and fix builds #4

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
name: ci
on:
push:
Expand All @@ -8,7 +7,7 @@ on:
branches:
- main
env:
golang-version: '1.17'
golang-version: "1.21"
jobs:
generate:
runs-on: ubuntu-latest
Expand Down
16 changes: 12 additions & 4 deletions .lint
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
---
exclusions:
template-job-rule:
panel-job-instance-rule:
target-rate-interval-rule:
panel-datasource-rule:
template-job-rule:
reason: Jobs are set to multi in our case.
target-job-rule:
reason: Jobs are set to multi in our case.
template-instance-rule:
reason: We don't use instances.
panel-datasource-rule:
reason: Using a datasource for each panel.
panel-title-description-rule:
reason: TODO(adinhodovic)
target-instance-rule:
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ $(OUT_DIR)/.lint: $(OUT_DIR)

.PHONY: dashboards-lint
dashboards-lint: $(GRAFANA_DASHBOARD_LINTER_BIN) $(OUT_DIR)/.lint
# Replace rates var with $$__rate_interval to make dashboard-linter happy.
@sed -i -e 's/7d/$$__rate_interval/g' $(OUT_DIR)/*.json
@find $(OUT_DIR) -name '*.json' -print0 | xargs -n 1 -0 $(GRAFANA_DASHBOARD_LINTER_BIN) lint --strict
@find $(OUT_DIR) -name '*.json' -print0 | xargs -n 1 -0 $(GRAFANA_DASHBOARD_LINTER_BIN) lint --strict --config .lint


.PHONY: clean
Expand All @@ -74,5 +72,5 @@ $(BIN_DIR):

$(TOOLING): $(BIN_DIR)
@echo Installing tools from hack/tools.go
@cd scripts && go list -mod=mod -e -tags tools -f '{{ range .Imports }}{{ printf "%s\n" .}}{{end}}' ./ | xargs -tI % go build -mod=mod -o $(BIN_DIR) %
@cd scripts && go list -e -mod=mod -e -tags tools -f '{{ range .Imports }}{{ printf "%s\n" .}}{{end}}' ./ | xargs -tI % go build -mod=mod -o $(BIN_DIR) %

22 changes: 17 additions & 5 deletions dashboards/argo-cd-applications.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local tbOverride = tbStandardOptions.override;
'datasource',
'prometheus',
) +
datasource.generalOptions.withLabel('Data Source'),
datasource.generalOptions.withLabel('Data source'),

local namespaceVariable =
query.new(
Expand Down Expand Up @@ -286,9 +286,11 @@ local tbOverride = tbStandardOptions.override;
tablePanel.new(
'Applications Unhealthy',
) +
tbStandardOptions.withUnit('short') +
tbOptions.withSortBy(
tbOptions.sortBy.withDisplayName('Application')
) +
tbOptions.footer.TableFooterOptions.withEnablePagination(true) +
tbQueryOptions.withTargets(
prometheus.new(
'$datasource',
Expand Down Expand Up @@ -331,7 +333,8 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To Application') +
tbPanelOptions.link.withUrl(
$._config.argoCdUrl + '/applications/${__data.fields.Project}/${__value.raw}'
)
) +
tbPanelOptions.link.withTargetBlank(true)
)
),
tbOverride.byName.new('health_status') +
Expand All @@ -355,9 +358,11 @@ local tbOverride = tbStandardOptions.override;
tablePanel.new(
'Applications Out Of Sync',
) +
tbStandardOptions.withUnit('short') +
tbOptions.withSortBy(
tbOptions.sortBy.withDisplayName('Application')
) +
tbOptions.footer.TableFooterOptions.withEnablePagination(true) +
tbQueryOptions.withTargets(
prometheus.new(
'$datasource',
Expand Down Expand Up @@ -400,7 +405,8 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To Application') +
tbPanelOptions.link.withUrl(
$._config.argoCdUrl + '/applications/${__data.fields.Project}/${__value.raw}'
)
) +
tbPanelOptions.link.withTargetBlank(true)
)
),
tbOverride.byName.new('sync_status') +
Expand Down Expand Up @@ -428,9 +434,11 @@ local tbOverride = tbStandardOptions.override;
tablePanel.new(
'Applications That Failed to Sync[7d]',
) +
tbStandardOptions.withUnit('short') +
tbOptions.withSortBy(
tbOptions.sortBy.withDisplayName('Application')
) +
tbOptions.footer.TableFooterOptions.withEnablePagination(true) +
tbQueryOptions.withTargets(
prometheus.new(
'$datasource',
Expand Down Expand Up @@ -473,7 +481,8 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To Application') +
tbPanelOptions.link.withUrl(
$._config.argoCdUrl + '/applications/${__data.fields.Project}/${__value.raw}'
)
) +
tbPanelOptions.link.withTargetBlank(true)
)
),
tbOverride.byName.new('Value') +
Expand All @@ -497,9 +506,11 @@ local tbOverride = tbStandardOptions.override;
tablePanel.new(
'Applications With Auto Sync Disabled',
) +
tbStandardOptions.withUnit('short') +
tbOptions.withSortBy(
tbOptions.sortBy.withDisplayName('Application')
) +
tbOptions.footer.TableFooterOptions.withEnablePagination(true) +
tbQueryOptions.withTargets(
prometheus.new(
'$datasource',
Expand Down Expand Up @@ -542,7 +553,8 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withTitle('Go To Application') +
tbPanelOptions.link.withUrl(
$._config.argoCdUrl + '/applications/${__data.fields.Project}/${__value.raw}'
)
) +
tbPanelOptions.link.withTargetBlank(true)
)
),
tbOverride.byName.new('autosync_enabled') +
Expand Down
2 changes: 1 addition & 1 deletion dashboards/argo-cd-notifications.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local tsLegend = tsOptions.legend;
'datasource',
'prometheus',
) +
datasource.generalOptions.withLabel('Data Source'),
datasource.generalOptions.withLabel('Data source'),

local namespaceVariable =
query.new(
Expand Down
14 changes: 10 additions & 4 deletions dashboards/argo-cd-operational.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ local tsLegend = tsOptions.legend;
local tbOptions = tablePanel.options;
local tbStandardOptions = tablePanel.standardOptions;
local tbQueryOptions = tablePanel.queryOptions;
local tbPanelOptions = tablePanel.panelOptions;
local tbOverride = tbStandardOptions.override;

// HeatmapPanel
local hmStandardOptions = heatmapPanel.standardOptions;
local tbPanelOptions = tablePanel.panelOptions;
local hmQueryOptions = heatmapPanel.queryOptions;
local tbOverride = tbStandardOptions.override;

{
grafanaDashboards+:: {
Expand All @@ -47,7 +47,7 @@ local tbOverride = tbStandardOptions.override;
'datasource',
'prometheus',
) +
datasource.generalOptions.withLabel('Data Source'),
datasource.generalOptions.withLabel('Data source'),

local namespaceVariable =
query.new(
Expand Down Expand Up @@ -130,6 +130,7 @@ local tbOverride = tbStandardOptions.override;
statPanel.new(
'Clusters',
) +
statPanel.standardOptions.withUnit('short') +
statPanel.queryOptions.withTargets(
prometheus.new(
'$datasource',
Expand All @@ -153,6 +154,7 @@ local tbOverride = tbStandardOptions.override;
statPanel.new(
'Repositories',
) +
statPanel.standardOptions.withUnit('short') +
statPanel.queryOptions.withTargets(
prometheus.new(
'$datasource',
Expand All @@ -172,6 +174,7 @@ local tbOverride = tbStandardOptions.override;
statPanel.new(
'Applications',
) +
statPanel.standardOptions.withUnit('short') +
statPanel.queryOptions.withTargets(
prometheus.new(
'$datasource',
Expand Down Expand Up @@ -283,9 +286,11 @@ local tbOverride = tbStandardOptions.override;
tablePanel.new(
'Applications',
) +
tbStandardOptions.withUnit('short') +
tbOptions.withSortBy(
tbOptions.sortBy.withDisplayName('Application')
) +
tbOptions.footer.TableFooterOptions.withEnablePagination(true) +
tbQueryOptions.withTargets(
prometheus.new(
'$datasource',
Expand Down Expand Up @@ -331,7 +336,8 @@ local tbOverride = tbStandardOptions.override;
tbPanelOptions.link.withType('dashboard') +
tbPanelOptions.link.withUrl(
'/d/%s/argocd-notifications-overview?&var-project=${__data.fields.Project}&var-application=${__value.raw}' % $._config.applicationOverviewDashboardUid
)
) +
tbPanelOptions.link.withTargetBlank(true)
)
),
]),
Expand Down
Loading
Loading