Fix assigning APIHost in NewClientFromConfig refs #15045
[arvados.git] / lib / dispatchcloud / cmd.go
index f8143ac8ce5f50a06a4bdd39ed363bc6699c5563..22ceb8aebe787ae79c1274cc0c714bc39df04640 100644 (file)
@@ -6,6 +6,7 @@ package dispatchcloud
 
 import (
        "context"
+       "fmt"
 
        "git.curoverse.com/arvados.git/lib/cmd"
        "git.curoverse.com/arvados.git/lib/service"
@@ -14,10 +15,15 @@ import (
 
 var Command cmd.Handler = service.Command(arvados.ServiceNameDispatchCloud, newHandler)
 
-func newHandler(ctx context.Context, cluster *arvados.Cluster, _ *arvados.NodeProfile, token string) service.Handler {
+func newHandler(ctx context.Context, cluster *arvados.Cluster, np *arvados.NodeProfile, token string) service.Handler {
+       ac, err := arvados.NewClientFromConfig(cluster)
+       if err != nil {
+               return service.ErrorHandler(ctx, cluster, np, fmt.Errorf("error initializing client from cluster config: %s", err))
+       }
        d := &dispatcher{
                Cluster:   cluster,
                Context:   ctx,
+               ArvClient: ac,
                AuthToken: token,
        }
        go d.Start()