Skip to content

Add workspace flag and env var for running commands outside the workspace directory #433

@gvauter

Description

@gvauter

Is your feature request related to a problem? Please describe.

Currently complyctl commands expect to find the complytime.yaml config file in the current working directory. This can be a disruptive flow as a user navigates their file system they need to cd back into the config directory before executing a command.

Currently NewWorkspace() hardcodes "complytime.yaml" relative to cwd scan output, generation state, logs all use "." and ".complytime/" relative to cwd. Plugins then receive workspace: "." as a variable, persist state.json relative to cwd

Describe the solution you'd like

Make the workspace directory a configurable value and treat workspace directory is the anchor. Config, scan output, generation state, and plugin state all live relative to it.

  1. Add a --workspace / -w flag to Common options
  2. Add env var fallback COMPLYTIME_WORKSPACE
  3. Update NewWorkspace to accept a base directory
  4. Pass the workspace dir through all commands. Every command that calls NewWorkspace() would use the resolved dir instead. The hardcoded "." references would use the resolved workspace dir.
  5. Update plugin target variables. The workspace variable passed to plugins in the Target.Variables map should use the resolved dir instead of ".".
  6. Update log file writer. The lazyLogWriter in root.go uses complytime.WorkspaceDir (relative ".complytime"). This needs the resolved path.

Describe alternatives you've considered
Do nothing, keep as is.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Ready 🚀

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions