more shared scaffolding between 'zrok' and 'zrokloop' (#40)

This commit is contained in:
Michael Quigley
2022-09-30 15:20:15 -04:00
parent 175f8e8167
commit 779eb8fb24
3 changed files with 20 additions and 5 deletions

View File

@@ -6,9 +6,19 @@ import (
"github.com/go-openapi/strfmt"
"github.com/openziti-test-kitchen/zrok/rest_client_zrok"
"github.com/pkg/errors"
"github.com/spf13/pflag"
"net/url"
"os"
)
func AddZrokApiEndpointFlag(v *string, flags *pflag.FlagSet) {
defaultEndpoint := os.Getenv("ZROK_API_ENDPOINT")
if defaultEndpoint == "" {
defaultEndpoint = "https://api.zrok.io"
}
flags.StringVarP(v, "endpoint", "e", defaultEndpoint, "zrok API endpoint address")
}
func ZrokClient(endpoint string) (*rest_client_zrok.Zrok, error) {
apiUrl, err := url.Parse(endpoint)
if err != nil {