config: Add method that forces the endpoint url to be set
@@ -27,6 +27,7 @@ import (
"net"
"net/http"
"net/url"
+ "os"
"strings"
"time"
@@ -90,6 +91,15 @@ type Config struct {
systemSecret []byte `yaml:"-"`
}
+func (c *Config) GetClusterURLWithoutTailingSlashOrFail(cmd *cobra.Command) string {
+ endpoint := c.GetClusterURLWithoutTailingSlash(cmd)
+ if endpoint == "" {
+ fmt.Println("To execute this command, the endpoint URL must point to the URL where ORY Hydra is located. To set the endpoint URL, use flag --endpoint or environment variable HYDRA_URL.")
+ os.Exit(1)
+ }
+ return endpoint
+}
+
func (c *Config) GetClusterURLWithoutTailingSlash(cmd *cobra.Command) string {
if endpoint, _ := cmd.Flags().GetString("endpoint"); endpoint != "" {
return strings.TrimRight(endpoint, "/")
