Skip to content
Open
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
7 changes: 4 additions & 3 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
with:
version: v1.64.5
args: --timeout 5m
# renovate: datasource=go packageName=github.com/golangci/golangci-lint versioning=regex:^v(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)?$
version: v2.2.1
args: --timeout 5m --verbose
test:
runs-on: ubuntu-latest
steps:
Expand Down
251 changes: 247 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,250 @@
linters-settings:
goimports:
local-prefixes: github.com/argoproj/notifications-engine
formatters:
enable:
- goimports

settings:
goimports:
local-prefixes:
- github.com/argoproj/notifications-engine

issues:
max-issues-per-linter: 0

max-same-issues: 0

linters:
enable:
- goimports
- errorlint
- exptostd
- gocritic
- gomodguard
- govet
- importas
- misspell
- staticcheck
- thelper
- tparallel
- unparam
- usestdlibvars
- usetesting
- whitespace
disable:
- perfsprint # Performance optimizations cause many changes
- testifylint # Test assertion order changes cause large diffs
- revive # Too many style changes (265+ issues)

exclusions:
rules:
- linters:
- unparam
path: (.+)_test\.go

presets:
- comments
- common-false-positives
- legacy
- std-error-handling

warn-unused: true

settings:
gocritic:
enable-all: true
# Most of these should probably be enabled one-by-one.
disabled-checks:
- appendAssign
- appendCombine # Leave disabled, multi-line assigns can be more readable.
- assignOp # Leave disabled, assign operations can be more confusing than helpful.
- commentedOutCode
- deferInLoop
- exitAfterDefer
- exposedSyncMutex
- hugeParam
- importShadow
- paramTypeCombine # Leave disabled, there are too many failures to be worth fixing.
- rangeValCopy
- tooManyResultsChecker
- unnamedResult
- whyNoLint

gomodguard:
blocked:
modules:
- github.com/golang-jwt/jwt/v4:
recommendations:
- github.com/golang-jwt/jwt/v5

- github.com/imdario/mergo:
recommendations:
- dario.cat/mergo
reason: '`github.com/imdario/mergo` has been renamed.'

- github.com/pkg/errors:
recommendations:
- errors

govet:
disable:
- fieldalignment
- shadow
enable-all: true

importas:
alias:
- pkg: github.com/golang-jwt/jwt/v5
alias: jwtgo

- pkg: k8s.io/api/apps/v1
alias: appsv1

- pkg: k8s.io/api/core/v1
alias: corev1

- pkg: k8s.io/api/rbac/v1
alias: rbacv1

- pkg: k8s.io/apimachinery/pkg/api/errors
alias: apierrors

- pkg: k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1
alias: apiextensionsv1

- pkg: k8s.io/apimachinery/pkg/apis/meta/v1
alias: metav1

- pkg: k8s.io/client-go/informers/core/v1
alias: informersv1

- pkg: errors
alias: stderrors

nolintlint:
require-specific: true

perfsprint:
# Optimizes even if it requires an int or uint type cast.
int-conversion: true
# Optimizes into `err.Error()` even if it is only equivalent for non-nil errors.
err-error: true
# Optimizes `fmt.Errorf`.
errorf: true
# Optimizes `fmt.Sprintf` with only one argument.
sprintf1: true
# Optimizes into strings concatenation.
strconcat: true

revive:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md
rules:
- name: bool-literal-in-expr

- name: blank-imports
disabled: true

- name: context-as-argument
arguments:
- allowTypesBefore: '*testing.T,testing.TB'

- name: context-keys-type
disabled: true

- name: dot-imports
disabled: true

- name: duplicated-imports

- name: early-return
arguments:
- preserveScope

- name: empty-block
disabled: true

- name: error-naming
disabled: true

- name: error-return

- name: error-strings
disabled: true

- name: errorf

- name: identical-branches

- name: if-return

- name: increment-decrement

- name: indent-error-flow
arguments:
- preserveScope

- name: modifies-parameter

- name: optimize-operands-order

- name: range

- name: receiver-naming

- name: redefines-builtin-id
disabled: true

- name: redundant-import-alias

- name: superfluous-else
arguments:
- preserveScope

- name: time-equal

- name: time-naming
disabled: true

- name: unexported-return
disabled: true

- name: unnecessary-stmt

- name: unreachable-code

- name: unused-parameter

- name: use-any

- name: useless-break

- name: var-declaration

- name: var-naming
arguments:
- - ID
- - VM
- - skipPackageNameChecks: true
upperCaseConst: true

staticcheck:
checks:
- all
- -SA5011
- -ST1003
- -ST1016

testifylint:
enable-all: true

disable:
- go-require

unused:
field-writes-are-uses: false
exported-fields-are-used: false

usetesting:
os-mkdir-temp: false

output:
show-stats: false

version: "2"
4 changes: 4 additions & 0 deletions docs/services/alertmanager.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ The notification service is used to push events to [Alertmanager](https://github
* `basicAuth` - optional, server auth
* `bearerToken` - optional, server auth
* `timeout` - optional, the timeout in seconds used when sending alerts, default is "3 seconds"
* `maxIdleConns` - optional, maximum number of idle (keep-alive) connections across all hosts.
* `maxIdleConnsPerHost` - optional, maximum number of idle (keep-alive) connections per host.
* `maxConnsPerHost` - optional, maximum total connections per host.
* `idleConnTimeout` - optional, maximum amount of time an idle (keep-alive) connection will remain open before closing.

`basicAuth` or `bearerToken` is used for authentication, you can choose one. If the two are set at the same time, `basicAuth` takes precedence over `bearerToken`.

Expand Down
4 changes: 4 additions & 0 deletions docs/services/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ The GitHub notification service changes commit status using [GitHub Apps](https:
- `installationID` - the app installation id
- `privateKey` - the app private key
- `enterpriseBaseURL` - optional URL, e.g. https://git.example.com/api/v3
- `maxIdleConns` - optional, maximum number of idle (keep-alive) connections across all hosts.
- `maxIdleConnsPerHost` - optional, maximum number of idle (keep-alive) connections per host.
- `maxConnsPerHost` - optional, maximum total connections per host.
- `idleConnTimeout` - optional, maximum amount of time an idle (keep-alive) connection will remain open before closing.

> ⚠️ _NOTE:_ Specifying `/api/v3` in the `enterpriseBaseURL` is required until [argoproj/notifications-engine#205](https://github.com/argoproj/notifications-engine/issues/205) is resolved.

Expand Down
25 changes: 22 additions & 3 deletions docs/services/grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Available parameters :
* `apiURL` - the server url, e.g. https://grafana.example.com
* `apiKey` - the API key for the serviceaccount
* `insecureSkipVerify` - optional bool, true or false
* `maxIdleConns` - optional, maximum number of idle (keep-alive) connections across all hosts.
* `maxIdleConnsPerHost` - optional, maximum number of idle (keep-alive) connections per host.
* `maxConnsPerHost` - optional, maximum total connections per host.
* `idleConnTimeout` - optional, maximum amount of time an idle (keep-alive) connection will remain open before closing.

1. Login to your Grafana instance as `admin`
2. On the left menu, go to Configuration / API Keys
Expand Down Expand Up @@ -37,7 +41,22 @@ stringData:
grafana-api-key: api-key
```

7. Create subscription for your Grafana integration
7. Create a template in `argo-notifications-cm` Configmap
This will be used to pass the (required) text of the annocation to Grafana (or re-use an existing one)
As there is no specific template for Grafana, you must use the generic `message`:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
templates:
template.app-deployed: |
messsage: Application {{.app.metadata.name}} is now running new version of deployments manifests.
```

8. Create subscription for your Grafana integration

```yaml
apiVersion: argoproj.io/v1alpha1
Expand All @@ -47,5 +66,5 @@ metadata:
notifications.argoproj.io/subscribe.<trigger-name>.grafana: tag1|tag2 # list of tags separated with |
```

8. Change the annotations settings
![8](https://user-images.githubusercontent.com/18019529/112022083-47fb0600-8b75-11eb-849b-d25d41925909.png)
9. Change the annotations settings
![8](https://user-images.githubusercontent.com/18019529/112022083-47fb0600-8b75-11eb-849b-d25d41925909.png)
4 changes: 4 additions & 0 deletions docs/services/mattermost.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* `apiURL` - the server url, e.g. https://mattermost.example.com
* `token` - the bot token
* `insecureSkipVerify` - optional bool, true or false
* `maxIdleConns` - optional, maximum number of idle (keep-alive) connections across all hosts.
* `maxIdleConnsPerHost` - optional, maximum number of idle (keep-alive) connections per host.
* `maxConnsPerHost` - optional, maximum total connections per host.
* `idleConnTimeout` - optional, maximum amount of time an idle (keep-alive) connection will remain open before closing, e.g. '90s'.

## Configuration

Expand Down
4 changes: 4 additions & 0 deletions docs/services/newrelic.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

* `apiURL` - the api server url, e.g. https://api.newrelic.com
* `apiKey` - a [NewRelic ApiKey](https://docs.newrelic.com/docs/apis/rest-api-v2/get-started/introduction-new-relic-rest-api-v2/#api_key)
* `maxIdleConns` - optional, maximum number of idle (keep-alive) connections across all hosts.
* `maxIdleConnsPerHost` - optional, maximum number of idle (keep-alive) connections per host.
* `maxConnsPerHost` - optional, maximum total connections per host.
* `idleConnTimeout` - optional, maximum amount of time an idle (keep-alive) connection will remain open before closing, e.g. '90s'.

## Configuration

Expand Down
5 changes: 5 additions & 0 deletions docs/services/slack.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ The Slack notification service configuration includes following settings:
| `token` | **True** | `string` | The app's OAuth access token. | `xoxb-1234567890-1234567890123-5n38u5ed63fgzqlvuyxvxcx6` |
| `username` | False | `string` | The app username. | `argocd` |
| `disableUnfurl` | False | `bool` | Disable slack unfurling links in messages | `true` |
| `maxIdleConns` | False | `int` | Maximum number of idle (keep-alive) connections across all hosts. | — |
| `maxIdleConnsPerHost` | False | `int` | Maximum number of idle (keep-alive) connections per host. | — |
| `maxConnsPerHost` | False | `int` | Maximum total connections per host. | — |
| `idleConnTimeout` | False | `string` | Maximum amount of time an idle (keep-alive) connection will remain open before closing (e.g., `90s`). | — |


## Configuration

Expand Down
4 changes: 4 additions & 0 deletions docs/services/webhook.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ The Webhook notification service configuration includes following settings:
- `retryWaitMin` - Optional, the minimum wait time between retries. Default value: 1s.
- `retryWaitMax` - Optional, the maximum wait time between retries. Default value: 5s.
- `retryMax` - Optional, the maximum number of retries. Default value: 3.
- `maxIdleConns` - optional, maximum number of idle (keep-alive) connections across all hosts.
- `maxIdleConnsPerHost` - optional, maximum number of idle (keep-alive) connections per host.
- `maxConnsPerHost` - optional, maximum total connections per host.
- `idleConnTimeout` - optional, maximum amount of time an idle (keep-alive) connection will remain open before closing, e.g. '90s'.

## Retry Behavior

Expand Down
4 changes: 2 additions & 2 deletions examples/certmanager/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/argoproj/notifications-engine/pkg/cmd"
"github.com/argoproj/notifications-engine/pkg/services"

v1 "k8s.io/api/core/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime/schema"

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
Expand All @@ -20,7 +20,7 @@ func main() {
}, api.Settings{
ConfigMapName: "cert-manager-notifications-cm",
SecretName: "cert-manager-notifications-secret",
InitGetVars: func(cfg *api.Config, configMap *v1.ConfigMap, secret *v1.Secret) (api.GetVars, error) {
InitGetVars: func(cfg *api.Config, configMap *corev1.ConfigMap, secret *corev1.Secret) (api.GetVars, error) {
return func(obj map[string]interface{}, dest services.Destination) map[string]interface{} {
return map[string]interface{}{"cert": obj}
}, nil
Expand Down
Loading