mirror of
https://github.com/harness-community/drone-helm-chart-container-registry.git
synced 2026-06-14 05:12:50 +08:00
added tests
This commit is contained in:
@@ -17,8 +17,9 @@ func main() {
|
||||
chartPath := os.Getenv("PLUGIN_CHART_PATH")
|
||||
namespace := os.Getenv("PLUGIN_REGISTRY_NAMESPACE")
|
||||
|
||||
if (registryUrl == "") || (username == "") || (token == "") || (namespace == "") || (chartPath == "") {
|
||||
fmt.Println("Missing required environment variables")
|
||||
err := verifyEnvVars()
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
@@ -82,3 +83,17 @@ func main() {
|
||||
|
||||
fmt.Printf("Successfully pushed chart to %s", ociURL)
|
||||
}
|
||||
|
||||
func verifyEnvVars() error {
|
||||
registryUrl := os.Getenv("PLUGIN_REGISTRY_URL")
|
||||
username := os.Getenv("PLUGIN_REGISTRY_USERNAME")
|
||||
token := os.Getenv("PLUGIN_REGISTRY_PASSWORD")
|
||||
chartPath := os.Getenv("PLUGIN_CHART_PATH")
|
||||
namespace := os.Getenv("PLUGIN_REGISTRY_NAMESPACE")
|
||||
|
||||
if (registryUrl == "") || (username == "") || (token == "") || (namespace == "") || (chartPath == "") {
|
||||
return fmt.Errorf("required environment variables not set")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user