mirror of https://github.com/helm/helm
Co-authored-by: George Jenkins <gvjenkins@gmail.com> Signed-off-by: Scott Rigby <scott@r6by.com>pull/31146/head
parent
be74ab72a0
commit
a7578fec74
@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package plugin
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// MetadataV1 is the APIVersion V1 plugin.yaml format
|
||||
type MetadataV1 struct {
|
||||
// APIVersion specifies the plugin API version
|
||||
APIVersion string `yaml:"apiVersion"`
|
||||
|
||||
// Name is the name of the plugin
|
||||
Name string `yaml:"name"`
|
||||
|
||||
// Type of plugin (eg, cli/v1, getter/v1)
|
||||
Type string `yaml:"type"`
|
||||
|
||||
// Runtime specifies the runtime type (subprocess, wasm)
|
||||
Runtime string `yaml:"runtime"`
|
||||
|
||||
// Version is a SemVer 2 version of the plugin.
|
||||
Version string `yaml:"version"`
|
||||
|
||||
// SourceURL is the URL where this plugin can be found
|
||||
SourceURL string `yaml:"sourceURL,omitempty"`
|
||||
|
||||
// Config contains the type-specific configuration for this plugin
|
||||
Config map[string]any `yaml:"config"`
|
||||
|
||||
// RuntimeConfig contains the runtime-specific configuration
|
||||
RuntimeConfig map[string]any `yaml:"runtimeConfig"`
|
||||
}
|
||||
|
||||
func (m *MetadataV1) Validate() error {
|
||||
if !validPluginName.MatchString(m.Name) {
|
||||
return fmt.Errorf("invalid plugin `name`")
|
||||
}
|
||||
|
||||
if m.APIVersion != "v1" {
|
||||
return fmt.Errorf("invalid `apiVersion`: %q", m.APIVersion)
|
||||
}
|
||||
|
||||
if m.Type == "" {
|
||||
return fmt.Errorf("`type` missing")
|
||||
}
|
||||
|
||||
if m.Runtime == "" {
|
||||
return fmt.Errorf("`runtime` missing")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
name: "duplicate-entries"
|
||||
version: "0.1.0"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "test duplicate entries"
|
||||
longHelp: |-
|
||||
description
|
||||
ignoreFlags: true
|
||||
runtimeConfig:
|
||||
command: "echo hello"
|
||||
hooks:
|
||||
install: "echo installing..."
|
||||
hooks:
|
||||
install: "echo installing something different"
|
@ -0,0 +1,15 @@
|
||||
---
|
||||
name: "echo-v1"
|
||||
version: "1.2.3"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "echo something"
|
||||
longHelp: |-
|
||||
This is a testing fixture.
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "echo Hello"
|
||||
hooks:
|
||||
install: "echo Installing"
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
name: "getter"
|
||||
version: "1.2.3"
|
||||
type: getter/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
protocols:
|
||||
- "myprotocol"
|
||||
- "myprotocols"
|
||||
runtimeConfig:
|
||||
protocolCommands:
|
||||
- command: "echo getter"
|
||||
protocols:
|
||||
- "myprotocol"
|
||||
- "myprotocols"
|
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env pwsh
|
||||
|
||||
Write-Host "Hello, world!"
|
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Hello from a Helm plugin"
|
||||
|
||||
echo "PARAMS"
|
||||
echo $*
|
||||
|
||||
$HELM_BIN ls --all
|
||||
|
@ -0,0 +1,32 @@
|
||||
---
|
||||
name: "hello-v1"
|
||||
version: "0.1.0"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
usage: hello [params]...
|
||||
shortHelp: "echo hello message"
|
||||
longHelp: |-
|
||||
description
|
||||
ignoreFlags: true
|
||||
runtimeConfig:
|
||||
platformCommand:
|
||||
- os: linux
|
||||
arch:
|
||||
command: "sh"
|
||||
args: ["-c", "${HELM_PLUGIN_DIR}/hello.sh"]
|
||||
- os: windows
|
||||
arch:
|
||||
command: "pwsh"
|
||||
args: ["-c", "${HELM_PLUGIN_DIR}/hello.ps1"]
|
||||
platformHooks:
|
||||
install:
|
||||
- os: linux
|
||||
arch: ""
|
||||
command: "sh"
|
||||
args: ["-c", 'echo "installing..."']
|
||||
- os: windows
|
||||
arch: ""
|
||||
command: "pwsh"
|
||||
args: ["-c", 'echo "installing..."']
|
@ -1,4 +1,10 @@
|
||||
name: fullenv
|
||||
usage: "show env vars"
|
||||
description: "show all env vars"
|
||||
command: "$HELM_PLUGIN_DIR/fullenv.sh"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "show env vars"
|
||||
longHelp: "show all env vars"
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "$HELM_PLUGIN_DIR/fullenv.sh"
|
||||
|
@ -1,4 +1,10 @@
|
||||
name: args
|
||||
usage: "echo args"
|
||||
description: "This echos args"
|
||||
command: "$HELM_PLUGIN_DIR/args.sh"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "echo args"
|
||||
longHelp: "This echos args"
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "$HELM_PLUGIN_DIR/args.sh"
|
||||
|
@ -1,4 +1,10 @@
|
||||
name: echo
|
||||
usage: "echo stuff"
|
||||
description: "This echos stuff"
|
||||
command: "echo hello"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "echo stuff"
|
||||
longHelp: "This echos stuff"
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "echo hello"
|
||||
|
@ -1,4 +1,10 @@
|
||||
name: env
|
||||
usage: "env stuff"
|
||||
description: "show the env"
|
||||
command: "echo $HELM_PLUGIN_NAME"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "env stuff"
|
||||
longHelp: "show the env"
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "echo $HELM_PLUGIN_NAME"
|
||||
|
@ -1,4 +1,10 @@
|
||||
name: exitwith
|
||||
usage: "exitwith code"
|
||||
description: "This exits with the specified exit code"
|
||||
command: "$HELM_PLUGIN_DIR/exitwith.sh"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "exitwith code"
|
||||
longHelp: "This exits with the specified exit code"
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "$HELM_PLUGIN_DIR/exitwith.sh"
|
||||
|
@ -1,4 +1,10 @@
|
||||
name: fullenv
|
||||
usage: "show env vars"
|
||||
description: "show all env vars"
|
||||
command: "$HELM_PLUGIN_DIR/fullenv.sh"
|
||||
type: cli/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
shortHelp: "show env vars"
|
||||
longHelp: "show all env vars"
|
||||
ignoreFlags: false
|
||||
runtimeConfig:
|
||||
command: "$HELM_PLUGIN_DIR/fullenv.sh"
|
||||
|
@ -1,6 +1,13 @@
|
||||
name: "testgetter"
|
||||
version: "0.1.0"
|
||||
downloaders:
|
||||
- command: "echo"
|
||||
protocols:
|
||||
- "test"
|
||||
type: getter/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
protocols:
|
||||
- "test"
|
||||
runtimeConfig:
|
||||
protocolCommands:
|
||||
- command: "echo"
|
||||
protocols:
|
||||
- "test"
|
||||
|
@ -1,6 +1,13 @@
|
||||
name: "testgetter2"
|
||||
version: "0.1.0"
|
||||
downloaders:
|
||||
- command: "echo"
|
||||
protocols:
|
||||
- "test2"
|
||||
type: getter/v1
|
||||
apiVersion: v1
|
||||
runtime: subprocess
|
||||
config:
|
||||
protocols:
|
||||
- "test2"
|
||||
runtimeConfig:
|
||||
protocolCommands:
|
||||
- command: "echo"
|
||||
protocols:
|
||||
- "test2"
|
||||
|
Loading…
Reference in new issue