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

Add documentationURL to plugins #1320

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions internal/executor/doctor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ func NewExecutor(ver string) *Executor {
// Metadata returns details about the Doctor plugin.
func (d *Executor) Metadata(context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: d.pluginVersion,
Description: "Doctor is a ChatGPT integration project that knows how to diagnose Kubernetes problems and suggest solutions.",
Version: d.pluginVersion,
DocumentationURL: "https://docs.botkube.io/configuration/executor/doctor",
Description: "Doctor is a ChatGPT integration project that knows how to diagnose Kubernetes problems and suggest solutions.",
JSONSchema: api.JSONSchema{
Value: configJSONSchema,
},
Expand Down
7 changes: 4 additions & 3 deletions internal/executor/flux/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ func NewExecutor(cache *bigcache.BigCache, ver string) *Executor {
// Metadata returns details about the Flux plugin.
func (d *Executor) Metadata(context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: d.pluginVersion,
Description: description,
Dependencies: getPluginDependencies(),
Version: d.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/executor/flux",
Dependencies: getPluginDependencies(),
JSONSchema: api.JSONSchema{
Value: jsonschema,
},
Expand Down
7 changes: 4 additions & 3 deletions internal/executor/helm/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,10 @@ func NewExecutor(ver string) *Executor {
// Metadata returns details about Helm plugin.
func (e *Executor) Metadata(context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: e.pluginVersion,
Description: description,
JSONSchema: jsonSchema(),
Version: e.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/executor/helm/",
JSONSchema: jsonSchema(),
Dependencies: map[string]api.Dependency{
helmBinaryName: {
URLs: helmBinaryDownloadLinks,
Expand Down
7 changes: 4 additions & 3 deletions internal/executor/kubectl/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ func NewExecutor(ver string, kcRunner kcRunner) *Executor {
// Metadata returns details about Helm plugin.
func (e *Executor) Metadata(context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: e.pluginVersion,
Description: description,
JSONSchema: jsonSchema(description),
Version: e.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/executor/kubectl",
JSONSchema: jsonSchema(description),
Dependencies: map[string]api.Dependency{
binaryName: {
URLs: kcBinaryDownloadLinks,
Expand Down
15 changes: 8 additions & 7 deletions internal/plugin/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,14 @@ type (
}
// IndexEntry defines the plugin definition.
IndexEntry struct {
Name string `yaml:"name"`
Type Type `yaml:"type"`
Description string `yaml:"description"`
Version string `yaml:"version"`
URLs []IndexURL `yaml:"urls"`
JSONSchema JSONSchema `yaml:"jsonSchema"`
ExternalRequest ExternalRequest `yaml:"externalRequest,omitempty"`
Name string `yaml:"name"`
Type Type `yaml:"type"`
Description string `yaml:"description"`
DocumentationURL string `yaml:"documentationUrl"`
madebyrogal marked this conversation as resolved.
Show resolved Hide resolved
Version string `yaml:"version"`
URLs []IndexURL `yaml:"urls"`
JSONSchema JSONSchema `yaml:"jsonSchema"`
ExternalRequest ExternalRequest `yaml:"externalRequest,omitempty"`
}

// ExternalRequest contains the external request metadata for a given plugin.
Expand Down
11 changes: 6 additions & 5 deletions internal/plugin/index_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (i *IndexBuilder) Build(dir, urlBasePath, pluginNameFilter string, skipChec
for key, bins := range entries {
meta, err := i.getPluginMetadata(dir, bins)
if err != nil {
return Index{}, fmt.Errorf("while getting plugin metadata: %w", err)
return Index{}, fmt.Errorf("while getting %s plugin's metadata: %w", key, err)
}

urls, err := i.mapToIndexURLs(dir, bins, urlBasePath, meta.Dependencies, skipChecksum, useArchive)
Expand All @@ -84,10 +84,11 @@ func (i *IndexBuilder) Build(dir, urlBasePath, pluginNameFilter string, skipChec

pType, pName, _ := strings.Cut(key, "/")
out.Entries = append(out.Entries, IndexEntry{
Name: pName,
Type: Type(pType),
Description: meta.Description,
Version: meta.Version,
Name: pName,
Type: Type(pType),
Description: meta.Description,
DocumentationURL: meta.DocumentationURL,
Version: meta.Version,
JSONSchema: JSONSchema{
Value: meta.JSONSchema.Value,
RefURL: meta.JSONSchema.RefURL,
Expand Down
33 changes: 18 additions & 15 deletions internal/plugin/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ type (
storeRepository map[string][]storeEntry

storeEntry struct {
Description string
Version string
URLs map[string]URL
Dependencies map[string]map[string]string
JSONSchema JSONSchema
Description string
Version string
DocumentationURL string
URLs map[string]URL
Dependencies map[string]map[string]string
JSONSchema JSONSchema
}

URL struct {
Expand Down Expand Up @@ -95,19 +96,21 @@ func newStoreRepositories(indexes map[string][]byte) (storeRepository, storeRepo
switch entry.Type {
case TypeExecutor:
executorsRepositories.Insert(repo, entry.Name, storeEntry{
Description: entry.Description,
Version: entry.Version,
URLs: binURLs,
Dependencies: depURLs,
JSONSchema: entry.JSONSchema,
Description: entry.Description,
DocumentationURL: entry.DocumentationURL,
Version: entry.Version,
URLs: binURLs,
Dependencies: depURLs,
JSONSchema: entry.JSONSchema,
})
case TypeSource:
sourcesRepositories.Insert(repo, entry.Name, storeEntry{
Description: entry.Description,
Version: entry.Version,
URLs: binURLs,
Dependencies: depURLs,
JSONSchema: entry.JSONSchema,
Description: entry.Description,
DocumentationURL: entry.DocumentationURL,
Version: entry.Version,
URLs: binURLs,
Dependencies: depURLs,
JSONSchema: entry.JSONSchema,
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions internal/source/argocd/argocd.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ func (s *Source) HandleExternalRequest(_ context.Context, input source.ExternalR
// Metadata returns metadata of the ArgoCD configuration.
func (s *Source) Metadata(_ context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: s.pluginVersion,
Description: htmlDescription,
Version: s.pluginVersion,
Description: htmlDescription,
DocumentationURL: "https://docs.botkube.io/configuration/source/argocd",
JSONSchema: api.JSONSchema{
Value: configJSONSchema,
},
Expand Down
5 changes: 3 additions & 2 deletions internal/source/github_events/source_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ func (s *Source) Stream(ctx context.Context, input source.StreamInput) (source.S
// Metadata returns metadata for the GitHub source plugin.
func (s *Source) Metadata(_ context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: s.pluginVersion,
Description: description,
Version: s.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/source/github-events",
JSONSchema: api.JSONSchema{
Value: jsonschema,
},
Expand Down
7 changes: 4 additions & 3 deletions internal/source/keptn/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ func (p *Source) Stream(ctx context.Context, input source.StreamInput) (source.S
// Metadata returns metadata of Keptn configuration
func (p *Source) Metadata(_ context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: p.pluginVersion,
Description: description,
JSONSchema: jsonSchema(),
Version: p.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/source/keptn",
JSONSchema: jsonSchema(),
}, nil
}

Expand Down
5 changes: 3 additions & 2 deletions internal/source/kubernetes/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ func (*Source) Stream(ctx context.Context, input source.StreamInput) (source.Str
// Metadata returns metadata of Kubernetes configuration
func (s *Source) Metadata(_ context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: s.pluginVersion,
Description: description,
Version: s.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/source/kubernetes",
JSONSchema: api.JSONSchema{
Value: configJSONSchema,
},
Expand Down
7 changes: 4 additions & 3 deletions internal/source/prometheus/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func (p *Source) Stream(ctx context.Context, input source.StreamInput) (source.S
// Metadata returns metadata of prometheus configuration
func (p *Source) Metadata(_ context.Context) (api.MetadataOutput, error) {
return api.MetadataOutput{
Version: p.pluginVersion,
Description: description,
JSONSchema: jsonSchema(),
Version: p.pluginVersion,
Description: description,
DocumentationURL: "https://docs.botkube.io/configuration/source/prometheus",
JSONSchema: jsonSchema(),
}, nil
}

Expand Down
84 changes: 48 additions & 36 deletions pkg/api/executor/executor.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions pkg/api/executor/grpc_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,9 @@ func (p *grpcClient) Metadata(ctx context.Context) (api.MetadataOutput, error) {
}

return api.MetadataOutput{
Version: resp.Version,
Description: resp.Description,
Version: resp.Version,
Description: resp.Description,
DocumentationURL: resp.DocumentationUrl,
JSONSchema: api.JSONSchema{
Value: resp.GetJsonSchema().GetValue(),
RefURL: resp.GetJsonSchema().GetRefUrl(),
Expand Down Expand Up @@ -291,8 +292,9 @@ func (p *grpcServer) Metadata(ctx context.Context, _ *emptypb.Empty) (*MetadataR
return nil, err
}
return &MetadataResponse{
Version: meta.Version,
Description: meta.Description,
Version: meta.Version,
Description: meta.Description,
DocumentationUrl: meta.DocumentationURL,
JsonSchema: &JSONSchema{
Value: meta.JSONSchema.Value,
RefUrl: meta.JSONSchema.RefURL,
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ type MetadataOutput struct {
Version string
// Descriptions is a description of a given plugin.
Description string
// URL to plugin documentation.
DocumentationURL string
// JSONSchema is a JSON schema for a given plugin configuration.
JSONSchema JSONSchema

Expand Down
10 changes: 6 additions & 4 deletions pkg/api/source/grpc_adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ func (p *grpcClient) Metadata(ctx context.Context) (api.MetadataOutput, error) {
}

return api.MetadataOutput{
Version: resp.Version,
Description: resp.Description,
Version: resp.Version,
Description: resp.Description,
DocumentationURL: resp.DocumentationUrl,
JSONSchema: api.JSONSchema{
Value: resp.GetJsonSchema().GetValue(),
RefURL: resp.GetJsonSchema().GetRefUrl(),
Expand All @@ -260,8 +261,9 @@ func (p *grpcServer) Metadata(ctx context.Context, _ *emptypb.Empty) (*MetadataR
return nil, err
}
return &MetadataResponse{
Version: meta.Version,
Description: meta.Description,
Version: meta.Version,
Description: meta.Description,
DocumentationUrl: meta.DocumentationURL,
JsonSchema: &JSONSchema{
Value: meta.JSONSchema.Value,
RefUrl: meta.JSONSchema.RefURL,
Expand Down
Loading
Loading