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

Update and validate plugin JSON schemas, produce second plugin index #1013

Merged
merged 12 commits into from
Mar 15, 2023
5 changes: 5 additions & 0 deletions .github/workflows/upload-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ jobs:
with:
path: 'plugins-index.yaml'
destination: 'botkube-plugins-latest/'
- name: Upload plugin index to GCS
uses: google-github-actions/upload-cloud-storage@v1
with:
path: 'plugins-dev-index.yaml'
destination: 'botkube-plugins-latest/'
- name: 'Disable caching'
run: 'gsutil -m setmeta -h "Cache-Control: no-cache, no-store" gs://botkube-plugins-latest/*'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ tags
# Release
dist/
plugin-dist/
plugins-dev-index.yaml
plugins-index.yaml
CHANGELOG.md
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ release:
- glob: ./plugin-dist/executor_*
- glob: ./plugin-dist/source_*
- glob: ./plugins-index.yaml
- glob: ./plugins-dev-index.yaml

changelog:
skip: false
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ system-check:
gen-grpc-resources:
@./hack/gen-grpc-resources.sh

# Generate plugins YAML index file.
# Generate plugins YAML index files for both all plugins and end-user ones.
gen-plugins-index: build-plugins
go run ./hack/gen-plugin-index.go
go run ./hack/gen-plugin-index.go -output-path ./plugins-dev-index.yaml
go run ./hack/gen-plugin-index.go -output-path ./plugins-index.yaml -plugin-name-filter 'kubectl|helm|kubernetes|prometheus'

# Pre-build checks
pre-build: system-check
Expand Down
2 changes: 1 addition & 1 deletion cmd/executor/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func main() {
func jsonSchema() api.JSONSchema {
return api.JSONSchema{
Value: heredoc.Docf(`{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "botkube/echo",
"description": "%s",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion cmd/source/cm-watcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func exitOnError(err error) {
func jsonSchema() api.JSONSchema {
return api.JSONSchema{
Value: heredoc.Docf(`{
"$schema": "http://json-schema.org/draft-04/schema#",
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "botkube/cm-watcher",
"description": "%s",
"type": "object",
Expand Down
2 changes: 1 addition & 1 deletion global_config.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ sources:
# You can enable or disable filters with `@Botkube enable/disable filters` commands.
filters:
kubernetes:
# If true, enables support for `botkube.io/disable` and `botkube.io/channel` resource annotations.
# If true, enables support for `botkube.io/disable` resource annotation.
objectAnnotationChecker: true
# If true, filters out Node-related events that are not important.
nodeEventsChecker: true
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ require (
github.com/spiffe/spire v1.5.3
github.com/stretchr/testify v1.8.1
github.com/vrischmann/envconfig v1.3.0
github.com/xeipuuv/gojsonschema v1.2.0
golang.org/x/exp v0.0.0-20230307190834-24139beb5833
golang.org/x/sync v0.1.0
golang.org/x/text v0.7.0
Expand Down Expand Up @@ -169,6 +170,8 @@ require (
github.com/wiggin77/cfg v1.0.2 // indirect
github.com/wiggin77/merror v1.0.3 // indirect
github.com/wiggin77/srslog v1.0.1 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xlab/treeprint v1.1.0 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1934,8 +1934,12 @@ github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I=
github.com/xdg/stringprep v1.0.0/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y=
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v0.0.0-20180618132009-1d523034197f/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
Expand Down
20 changes: 12 additions & 8 deletions hack/gen-plugin-index.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ const filePerm = 0o644

func main() {
var (
urlBasePath = flag.String("url-base-path", os.Getenv("PLUGIN_DOWNLOAD_URL_BASE_PATH"), "Defines the URL base path for downloading the plugin binaries")
binsDir = flag.String("binaries-path", "./plugin-dist", "Defines the local path to plugins binaries folder")
output = flag.String("output-path", "./plugins-index.yaml", "Defines the local path where index YAML should be saved")
urlBasePath = flag.String("url-base-path", os.Getenv("PLUGIN_DOWNLOAD_URL_BASE_PATH"), "Defines the URL base path for downloading the plugin binaries")
binsDir = flag.String("binaries-path", "./plugin-dist", "Defines the local path to plugins binaries folder")
output = flag.String("output-path", "./plugins-index.yaml", "Defines the local path where index YAML should be saved")
pluginNameFilter = flag.String("plugin-name-filter", "", "Defines the plugin name regex for plugins which should be included in the index. Other plugins will be skipped.")
)

flag.Parse()
Expand All @@ -29,11 +30,14 @@ func main() {
absBinsDir, err := filepath.Abs(*binsDir)
exitOnError("while resolving an absolute path of binaries folder", err)

logger.WithFields(logrus.Fields{
"binDir": absBinsDir,
"urlBasePath": *urlBasePath,
}).Info("Building index..")
idx, err := idxBuilder.Build(absBinsDir, *urlBasePath)
log := logger.WithFields(logrus.Fields{
"binDir": absBinsDir,
"urlBasePath": *urlBasePath,
"pluginNameFilter": *pluginNameFilter,
})

log.Info("Building index..")
idx, err := idxBuilder.Build(absBinsDir, *urlBasePath, *pluginNameFilter)
exitOnError("while building plugin index", err)

raw, err := yaml.Marshal(idx)
Expand Down
Loading