added tests

This commit is contained in:
Akshit Agrawal
2024-01-19 13:59:27 +05:30
parent de5e722cdf
commit b37585eb55
5 changed files with 85 additions and 10 deletions
+17 -2
View File
@@ -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
}