@@ -33,10 +33,19 @@ type WorkflowStatus struct {
3333}
3434
3535// getServerURL returns the server URL from environment or default
36+ // Supports both WATERFLOW_TEST_URL (preferred) and SERVER_URL (legacy)
3637func getServerURL () string {
38+ if url := os .Getenv ("WATERFLOW_TEST_URL" ); url != "" {
39+ return url
40+ }
3741 return getEnvOrDefault ("SERVER_URL" , "http://localhost:18080" )
3842}
3943
44+ // getAgentURL returns the agent URL from environment or default
45+ func getAgentURL () string {
46+ return getEnvOrDefault ("WATERFLOW_AGENT_URL" , "http://localhost:18081" )
47+ }
48+
4049// getEnvOrDefault returns the environment variable value or a default
4150func getEnvOrDefault (key , defaultValue string ) string {
4251 if value := os .Getenv (key ); value != "" {
@@ -48,7 +57,7 @@ func getEnvOrDefault(key, defaultValue string) string {
4857// submitWorkflow submits a workflow YAML to the server
4958func submitWorkflow (ctx context.Context , serverURL , yamlContent string ) (* WorkflowSubmitResponse , error ) {
5059 req , err := http .NewRequestWithContext (ctx , http .MethodPost ,
51- serverURL + "/api/ v1/workflows" ,
60+ serverURL + "/v1/workflows" ,
5261 bytes .NewBufferString (yamlContent ))
5362 if err != nil {
5463 return nil , fmt .Errorf ("failed to create request: %w" , err )
@@ -83,7 +92,7 @@ func submitWorkflow(ctx context.Context, serverURL, yamlContent string) (*Workfl
8392// getWorkflowStatus retrieves the current status of a workflow
8493func getWorkflowStatus (ctx context.Context , serverURL , workflowID string ) (* WorkflowStatus , error ) {
8594 req , err := http .NewRequestWithContext (ctx , http .MethodGet ,
86- serverURL + "/api/ v1/workflows/" + workflowID ,
95+ serverURL + "/v1/workflows/" + workflowID ,
8796 nil )
8897 if err != nil {
8998 return nil , fmt .Errorf ("failed to create request: %w" , err )
@@ -153,7 +162,7 @@ func waitForWorkflowCompletion(ctx context.Context, serverURL, workflowID string
153162// cancelWorkflow cancels a running workflow
154163func cancelWorkflow (ctx context.Context , serverURL , workflowID string ) error {
155164 req , err := http .NewRequestWithContext (ctx , http .MethodPost ,
156- serverURL + "/api/ v1/workflows/" + workflowID + "/cancel" ,
165+ serverURL + "/v1/workflows/" + workflowID + "/cancel" ,
157166 nil )
158167 if err != nil {
159168 return fmt .Errorf ("failed to create request: %w" , err )
@@ -177,7 +186,7 @@ func cancelWorkflow(ctx context.Context, serverURL, workflowID string) error {
177186// getWorkflowLogs retrieves the logs for a workflow
178187func getWorkflowLogs (ctx context.Context , serverURL , workflowID string ) (string , error ) {
179188 req , err := http .NewRequestWithContext (ctx , http .MethodGet ,
180- serverURL + "/api/ v1/workflows/" + workflowID + "/logs" ,
189+ serverURL + "/v1/workflows/" + workflowID + "/logs" ,
181190 nil )
182191 if err != nil {
183192 return "" , fmt .Errorf ("failed to create request: %w" , err )
@@ -223,7 +232,7 @@ func loadTestWorkflow(filename string) (string, error) {
223232// rerunWorkflow triggers a rerun of a completed workflow
224233func rerunWorkflow (ctx context.Context , serverURL , workflowID string ) (* WorkflowSubmitResponse , error ) {
225234 req , err := http .NewRequestWithContext (ctx , http .MethodPost ,
226- serverURL + "/api/ v1/workflows/" + workflowID + "/rerun" ,
235+ serverURL + "/v1/workflows/" + workflowID + "/rerun" ,
227236 nil )
228237 if err != nil {
229238 return nil , fmt .Errorf ("failed to create request: %w" , err )
0 commit comments