Skip to content

Commit

Permalink
Merge pull request #6 from nixwiz/maintenance/handler_updates
Browse files Browse the repository at this point in the history
* Q1 '21 handler maintenance
  • Loading branch information
Jef Spaleta authored Feb 26, 2021
2 parents be05ae5 + 84f3562 commit ef81a46
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Go Lint

on: [push]
on: [push, pull_request]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Go Test

on: [push]
on: [push, pull_request]

jobs:
test:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased

### Changed
- Q1 '21 handler maintenance:
- Updated modules (go get -u && go mod tidy)
- Add pull_request to lint and test GitHub Actions
- Ran gofmt on source files
- README updates
- Fix linter error for dead code

## [0.0.1] - 2000-01-01

### Added
Expand Down
48 changes: 31 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/calebhailey/sensu-entity-manager)
![goreleaser](https://github.com/calebhailey/sensu-entity-manager/workflows/goreleaser/badge.svg)
[![Go Test](https://github.com/calebhailey/sensu-entity-manager/workflows/Go%20Test/badge.svg)](https://github.com/calebhailey/sensu-entity-manager/actions?query=workflow%3A%22Go+Test%22)
[![goreleaser](https://github.com/calebhailey/sensu-entity-manager/workflows/goreleaser/badge.svg)](https://github.com/calebhailey/sensu-entity-manager/actions?query=workflow%3Agoreleaser)
[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu/sensu-entity-manager)
![goreleaser](https://github.com/sensu/sensu-entity-manager/workflows/goreleaser/badge.svg)
[![Go Test](https://github.com/sensu/sensu-entity-manager/workflows/Go%20Test/badge.svg)](https://github.com/sensu/sensu-entity-manager/actions?query=workflow%3A%22Go+Test%22)
[![goreleaser](https://github.com/sensu/sensu-entity-manager/workflows/goreleaser/badge.svg)](https://github.com/sensu/sensu-entity-manager/actions?query=workflow%3Agoreleaser)

# Sensu Entity Manager

## Table of Contents
- [Overview](#overview)
- [Usage examples](#usage-examples)
- [Help output](#help-output)
- [Environment variables](#environment-variables)
- [Configuration](#configuration)
- [Asset registration](#asset-registration)
- [Handler definition](#handler-definition)
Expand All @@ -23,6 +25,8 @@ subscriptions) and other automation workflows.

## Usage examples

### Help output

```
$ sensu-entity-manager --help
Event-based Sensu entity management for service-discovery (add/remove subscriptions) and other automation workflows.
Expand All @@ -46,6 +50,21 @@ Flags:
Use "sensu-entity-manager [command] --help" for more information about a command.
```

### Environment variables

|Argument |Environment Variable |
|------------------|----------------------|
|--api-url |SENSU_API_URL |
|--api-key |SENSU_API_KEY |
|--access-token |SENSU_ACCESS_TOKEN |
|--trusted-ca-file |SENSU_TRUSTED_CA_FILE |

**Security Note:** Care should be taken to not expose the API key or access token for this handler
by specifying either on the command line or by directly setting the environment variable(s) in the
handler definition. It is suggested to make use of [secrets management][3] to surface either as an
environment variable. The [handler definition shown below](#handler-definition) references the API Key as a secret
using the built-in [env secrets provider][4].

## Configuration

### Asset registration
Expand All @@ -55,10 +74,10 @@ consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or late
following command to add the asset:

```
sensuctl asset add calebhailey/sensu-entity-manager
sensuctl asset add sensu/sensu-entity-manager
```

If you're using an earlier version of sensuctl, you can find the asset on the [Bonsai Asset Index][https://bonsai.sensu.io/assets/calebhailey/sensu-entity-manager].
If you're using an earlier version of sensuctl, you can find the asset on the [Bonsai Asset Index][2].

### Handler definition

Expand All @@ -75,7 +94,7 @@ spec:
--add-subscriptions
timeout: 5
runtime_assets:
- calebhailey/sensu-entity-manager:0.1.1
- sensu/sensu-entity-manager:0.1.1
secrets:
- name: SENSU_API_KEY
secret: entity-manager-api-key
Expand Down Expand Up @@ -136,7 +155,7 @@ metadata:

The preferred way of installing and deploying this plugin is to use it as an Asset. If you would
like to compile and install the plugin from source or contribute to it, download the latest version
or create an executable script from this source.
or create an executable from this source.

From the local path of the sensu-entity-manager repository:

Expand All @@ -157,13 +176,8 @@ go build
For more information about contributing to this plugin, see [Contributing][1].

[1]: https://github.com/sensu/sensu-go/blob/master/CONTRIBUTING.md
[2]: https://github.com/sensu-community/sensu-plugin-sdk
[3]: https://github.com/sensu-plugins/community/blob/master/PLUGIN_STYLEGUIDE.md
[4]: https://github.com/sensu-community/handler-plugin-template/blob/master/.github/workflows/release.yml
[5]: https://github.com/sensu-community/handler-plugin-template/actions
[6]: https://docs.sensu.io/sensu-go/latest/reference/handlers/
[7]: https://github.com/sensu-community/handler-plugin-template/blob/master/main.go
[8]: https://bonsai.sensu.io/
[9]: https://github.com/sensu-community/sensu-plugin-tool
[2]: https://bonsai.sensu.io/assets/sensu/sensu-entity-manager
[3]: https://docs.sensu.io/sensu-go/latest/guides/secrets-management/
[4]: https://docs.sensu.io/sensu-go/latest/guides/secrets-management/#use-env-for-secrets-management
[10]: https://docs.sensu.io/sensu-go/latest/reference/assets/
[11]: https://docs.sensu.io/sensu-go/latest/api/entities/#update-an-entity-with-patch
[11]: https://docs.sensu.io/sensu-go/latest/api/entities/#update-an-entity-with-patch
26 changes: 24 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,29 @@ module github.com/calebhailey/sensu-entity-manager
go 1.14

require (
github.com/coreos/etcd v3.3.25+incompatible // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.4.3 // indirect
github.com/google/uuid v1.2.0 // indirect
github.com/json-iterator/go v1.1.10 // indirect
github.com/magefile/mage v1.11.0 // indirect
github.com/magiconair/properties v1.8.4 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/pelletier/go-toml v1.8.1 // indirect
github.com/robertkrimen/otto v0.0.0-20200922221731-ef014fd054ac // indirect
github.com/sensu-community/sensu-plugin-sdk v0.11.0
github.com/sensu/sensu-go/api/core/v2 v2.3.0
github.com/sensu/sensu-go/types v0.3.0
github.com/sensu/sensu-go/types v0.5.0
github.com/sirupsen/logrus v1.8.0 // indirect
github.com/spf13/afero v1.5.1 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.3 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/viper v1.7.1 // indirect
golang.org/x/net v0.0.0-20210224082022-3d97a244fca7 // indirect
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20210224155714-063164c882e6 // indirect
google.golang.org/grpc v1.36.0 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
)
Loading

0 comments on commit ef81a46

Please sign in to comment.