add oci_image and runtime to VersionedPlugin (#22866)

---------

Co-authored-by: Tom Proctor <tomhjp@users.noreply.github.com>
This commit is contained in:
Thy Ton
2023-09-07 13:42:47 -07:00
committed by GitHub
parent cbc567895c
commit f96ecf3800
5 changed files with 14 additions and 2 deletions

View File

@@ -36,6 +36,8 @@ type ListPluginsResponse struct {
type PluginDetails struct {
Type string `json:"type"`
Name string `json:"name"`
OCIImage string `json:"oci_image,omitempty" mapstructure:"oci_image"`
Runtime string `json:"runtime,omitempty"`
Version string `json:"version,omitempty"`
Builtin bool `json:"builtin"`
DeprecationStatus string `json:"deprecation_status,omitempty" mapstructure:"deprecation_status"`

View File

@@ -160,9 +160,9 @@ func (c *PluginListCommand) simpleResponse(plugins *api.ListPluginsResponse, plu
}
func (c *PluginListCommand) detailedResponse(plugins *api.ListPluginsResponse) []string {
out := []string{"Name | Type | Version | Deprecation Status"}
out := []string{"Name | Type | Version | Container | Deprecation Status"}
for _, plugin := range plugins.Details {
out = append(out, fmt.Sprintf("%s | %s | %s | %s", plugin.Name, plugin.Type, plugin.Version, plugin.DeprecationStatus))
out = append(out, fmt.Sprintf("%s | %s | %s | %v | %s", plugin.Name, plugin.Type, plugin.Version, plugin.OCIImage != "", plugin.DeprecationStatus))
}
return out

View File

@@ -131,6 +131,8 @@ type VersionedPlugin struct {
Type string `json:"type"` // string instead of consts.PluginType so that we get the string form in API responses.
Name string `json:"name"`
Version string `json:"version"`
OCIImage string `json:"oci_image,omitempty"`
Runtime string `json:"runtime,omitempty"`
SHA256 string `json:"sha256,omitempty"`
Builtin bool `json:"builtin"`
DeprecationStatus string `json:"deprecation_status,omitempty"`

View File

@@ -467,6 +467,12 @@ func (b *SystemBackend) handlePluginCatalogUntypedList(ctx context.Context, _ *l
"version": p.Version,
"builtin": p.Builtin,
}
if p.OCIImage != "" {
entry["oci_image"] = p.OCIImage
}
if p.Runtime != "" {
entry["runtime"] = p.Runtime
}
if p.SHA256 != "" {
entry["sha256"] = p.SHA256
}

View File

@@ -1122,6 +1122,8 @@ func (c *PluginCatalog) listInternal(ctx context.Context, pluginType consts.Plug
result = append(result, pluginutil.VersionedPlugin{
Name: plugin.Name,
Type: plugin.Type.String(),
OCIImage: plugin.OCIImage,
Runtime: plugin.Runtime,
Version: plugin.Version,
SHA256: hex.EncodeToString(plugin.Sha256),
SemanticVersion: semanticVersion,