turbot / pipe-fittings

Shared components for use across pipe projects.
https://github.com/turbot
GNU Affero General Public License v3.0
14 stars 6 forks source link

throw an error if same profile is available in both locations ~/.flowpipe/config and the mod working directory #251

Closed vkumbha closed 9 months ago

vkumbha commented 11 months ago

Using the same profile in flowpipe config and mod location should throw an error.

I have the same profile called my_server in the ~/.flowpipe/config/workspaces.fpc file and also in the mod location ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination. Irrespective of whether the settings in these profiles are same/different. When using same profile name in both locations, flowpipe should throw an error.

Looks like it is loading the mod location configuration for now.

$ lsof -nP -iTCP -sTCP:LISTEN | grep 7104
flowpipe  10097 venu   17u  IPv4 0x59187e75f578a54f      0t0  TCP 127.0.0.1:7104 (LISTEN)
20:42:33 ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination (use-creds) 🐣 $ flowpipe -v
Flowpipe v0.1.0-beta.202312091322
20:42:37 ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination (use-creds) 🐣 $ more ~/.flowpipe/config/workspaces.fpc
workspace "my_server" {
  output        = "table"
  host          = "http://localhost:7103"
  port          = 7103
  log_level     = "info"
}

20:42:51 ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination (use-creds) 🐣 $ 
20:42:51 ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination (use-creds) 🐣 $ more workspace.fpc 
workspace "my_server" {
  output        = "pretty"
  host          = "http://localhost:7104"
  port          = 7104
  log_level     = "debug"
}
20:42:55 ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination (use-creds) 🐣 $ 
20:42:56 ~/turbie/turbot/flowpipe-samples/simple/http_list_pagination (use-creds) 🐣 $ flowpipe server --workspace my_server
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)

[GIN-debug] GET    /api/:api_version/service --> github.com/turbot/flowpipe/internal/service/api/service.serviceGet (5 handlers)
[GIN-debug] GET    /api/:api_version/pipeline --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listPipelines-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/pipeline/:pipeline_name --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getPipeline-fm (5 handlers)
[GIN-debug] POST   /api/:api_version/pipeline/:pipeline_name/command --> github.com/turbot/flowpipe/internal/service/api.(*APIService).cmdPipeline-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/trigger --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listTriggers-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/trigger/:trigger_name --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getTrigger-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/variable --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listVariables-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/variable/:variable_name --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getVariable-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listProcess-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process/:process_id --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getProcess-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process/:process_id/output --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getProcessOutput-fm (5 handlers)
[GIN-debug] POST   /api/:api_version/process/:process_id/command --> github.com/turbot/flowpipe/internal/service/api.(*APIService).cmdProcess-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process/:process_id/log/process.json --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listProcessEventLog-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process/:process_id/log/process.jsonl --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listProcessEventLogJSONLine-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process/:process_id/log/process.sps --> github.com/turbot/flowpipe/internal/service/api.(*APIService).listProcessSps-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/process/:process_id/execution --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getProcessExecution-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/docs/openapi.json --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getOpenAPIDocs-fm (5 handlers)
[GIN-debug] POST   /api/:api_version/hook/:trigger/:hash --> github.com/turbot/flowpipe/internal/service/api.(*APIService).runWebhook-fm (5 handlers)
[GIN-debug] POST   /api/:api_version/input/slack/:input/:hash --> github.com/turbot/flowpipe/internal/service/api.(*APIService).runSlackInputPost-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/input/email/:input/:hash --> github.com/turbot/flowpipe/internal/service/api.(*APIService).runInputEmailGet-fm (5 handlers)
[GIN-debug] GET    /api/:api_version/mod/:mod_name --> github.com/turbot/flowpipe/internal/service/api.(*APIService).getMod-fm (5 handlers)
github-actions[bot] commented 9 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

vhadianto commented 9 months ago

@vkumbha this is the expected behaviour.

https://flowpipe.io/docs/reference/config-files

Flowpipe will load ALL configuration files (*.fpc) from every directory in the [configuration search path](https://flowpipe.io/docs/reference/env-vars/flowpipe_config_path), with decreasing precedence. By default, the configuration search path includes the current directory (or --mod-location if specified) followed by the config directory in the [FLOWPIPE_INSTALL_DIR](https://flowpipe.io/docs/reference/env-vars/flowpipe_install_dir): .:$FLOWPIPE_INSTALL_DIR/config. This allows you to manage your workspaces and credentials centrally in the ~/.flowpipe/config directory, but override them in the working directory / mod location if desired.

You're meant to be able to override the configuration resources.