Skip to content

Commit

Permalink
Merge pull request #2 from sensu/initial-implementation
Browse files Browse the repository at this point in the history
Initial Implementation of cert-checks
  • Loading branch information
Jef Spaleta authored Dec 18, 2021
2 parents bce2501 + aeb2107 commit 4aaab71
Show file tree
Hide file tree
Showing 10 changed files with 1,142 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.14.x
go-version: 1.17.x
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Go 1.14
- name: Set up Go 1.17
uses: actions/setup-go@v1
with:
go-version: 1.14
go-version: 1.17
id: go
- name: Test
run: go test -v ./...
116 changes: 25 additions & 91 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,44 @@
![Go Test](https://github.com/sensu/cert-checks/workflows/Go%20Test/badge.svg)
![goreleaser](https://github.com/sensu/cert-checks/workflows/goreleaser/badge.svg)

# Check Plugin Template
# Check Certs

## Overview
check-plugin-template is a template repository which wraps the [Sensu Plugin SDK][2].
To use this project as a template, click the "Use this template" button from the main project page.
Once the repository is created from this template, you can use the [Sensu Plugin Tool][9] to
populate the templated fields with the proper values.
The [Sensu Cert Check][1] is a cross-platform [Sensu Metrics Check][2] that provides certificate metrics in prometheus format.

## Functionality
### Output Metrics

After successfully creating a project from this template, update the `Config` struct with any
configuration options for the plugin, map those values as plugin options in the variable `options`,
and customize the `checkArgs` and `executeCheck` functions in [main.go][7].
| Name | Description |
|-----------------------|---------------|
| cert_days_left | Number of days until certificate expiry. Expired certificates produce a negative number. |
| cert_seconds_left | Number of seconds until certificate expiry. Expired certificates produce a negative number. |
| cert_issued_days | Number of days the certificate has been issued. |
| cert_issued_seconds | Number of seconds the certificate has been issued. |

When writing or updating a plugin's README from this template, review the Sensu Community
[plugin README style guide][3] for content suggestions and guidance. Remove everything
prior to `# Cert Checks` from the generated README file, and add additional context about the
plugin per the style guide.

## Releases with Github Actions
## Usage Examples

To release a version of your project, simply tag the target sha with a semver release without a `v`
prefix (ex. `1.0.0`). This will trigger the [GitHub action][5] workflow to [build and release][4]
the plugin with goreleaser. Register the asset with [Bonsai][8] to share it with the community!
### Help Output

***

# Cert Checks

## Table of Contents
- [Overview](#overview)
- [Files](#files)
- [Usage examples](#usage-examples)
- [Configuration](#configuration)
- [Asset registration](#asset-registration)
- [Check definition](#check-definition)
- [Installation from source](#installation-from-source)
- [Additional notes](#additional-notes)
- [Contributing](#contributing)

## Overview

The Cert Checks is a [Sensu Check][6] that ...

## Files

## Usage examples

## Configuration

### Asset registration

[Sensu Assets][10] are the best way to make use of this plugin. If you're not using an asset, please
consider doing so! If you're using sensuctl 5.13 with Sensu Backend 5.13 or later, you can use the
following command to add the asset:

```
sensuctl asset add sensu/cert-checks
```
Inspects certificate data
If you're using an earlier version of sensuctl, you can find the asset on the [Bonsai Asset Index][https://bonsai.sensu.io/assets/sensu/cert-checks].

### Check definition

```yml
---
type: CheckConfig
api_version: core/v2
metadata:
name: cert-checks
namespace: default
spec:
command: cert-checks --example example_arg
subscriptions:
- system
runtime_assets:
- sensu/cert-checks
```
Usage:
cert-checks [flags]
cert-checks [command]
## Installation from source
Available Commands:
help Help about any command
version Print the version number of this plugin
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.
Flags:
-c, --cert string URL or file path to certificate
-h, --help help for cert-checks
-s, --servername string optional TLS servername extension argument
From the local path of the cert-checks repository:
```
go build
Use "cert-checks [command] --help" for more information about a command.
```

## Additional notes

## Contributing

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/check-plugin-template/blob/master/.github/workflows/release.yml
[5]: https://github.com/sensu-community/check-plugin-template/actions
[6]: https://docs.sensu.io/sensu-go/latest/reference/checks/
[7]: https://github.com/sensu-community/check-plugin-template/blob/master/main.go
[8]: https://bonsai.sensu.io/
[9]: https://github.com/sensu-community/sensu-plugin-tool
[10]: https://docs.sensu.io/sensu-go/latest/reference/assets/
[1]: https://github.com/sensu/system-check
[2]: https://docs.sensu.io/sensu-go/latest/reference/checks/
45 changes: 42 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,48 @@
module github.com/sensu/cert-checks

go 1.14
go 1.17

require (
github.com/sensu-community/sensu-plugin-sdk v0.11.0
github.com/sensu/sensu-go/api/core/v2 v2.3.0
github.com/sensu-community/sensu-plugin-sdk v0.12.0
github.com/sensu/sensu-go/types v0.3.0
)

require (
github.com/coreos/etcd v3.3.22+incompatible // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
github.com/echlebek/timeproxy v1.0.0 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/gogo/protobuf v1.3.1 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/uuid v1.1.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.9 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/pelletier/go-toml v1.2.0 // indirect
github.com/robertkrimen/otto v0.0.0-20191219234010-c382bd3c16ff // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/sensu/sensu-go/api/core/v2 v2.3.0 // indirect
github.com/sensu/sensu-licensing v0.1.2 // indirect
github.com/sirupsen/logrus v1.6.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/cobra v1.0.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/spf13/viper v1.7.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
golang.org/x/net v0.0.0-20190620200207-3b0461eec859 // indirect
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0 // indirect
golang.org/x/text v0.3.2 // indirect
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a // indirect
google.golang.org/grpc v1.24.0 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/sourcemap.v1 v1.0.5 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
)
Loading

0 comments on commit 4aaab71

Please sign in to comment.