Skip to content

Conversation

@carsongee
Copy link
Contributor

RATIONALE

Implements managed component updates with preconfigured answers to enable reproducible component installations with minimal user interaction. This feature follows copier's data_file semantics, allowing teams to standardize component configurations and reduce manual input during setup.

Key Use Cases:

  • Enterprise teams can define organization-wide component defaults
  • Developers can share project-specific configurations via repo-level configs
  • CI/CD pipelines can perform non-interactive component installations
  • Reduces setup friction and ensures consistency across team members

CHANGES

Core Features

1. Configuration System (internal/config/component.go)

  • Added LoadComponentDefaults() with priority-based resolution:
    1. Explicit --data-file path (highest priority)
    2. Repository-level: .datarobot/.copier-answers-defaults.yaml
    3. Home directory: ~/.config/datarobot/.copier-answers-defaults.yaml
    4. Legacy location: ~/.config/datarobot/component-defaults.yaml
  • Implemented MergeWithCLIData() to allow CLI flags to override config values
  • YAML format keyed by component repository URL

2. Enhanced Copier Integration (internal/copier/exec.go)

  • Added AddWithData() and UpdateWithData() to pass --data arguments to copier
  • Comprehensive type handling via formatDataValue():
    • All primitive types: strings, booleans, integers, floats
    • Lists/arrays for multiselect questions: [3.10, 3.11, 3.12]
    • Maps/objects for complex data: {key: value}
    • Null values
  • Performance-optimized using strconv for numeric conversions

3. CLI Commands

  • Added --data key=value flag (repeatable) to both component add and component update
  • Added --data-file path flag for explicit config file path
  • Implemented merge logic: CLI args override config file values

Documentation

  • Complete feature guide: docs/commands/component-managed-updates.md
  • Real-world examples: docs/examples/.copier-answers-defaults.yaml
  • Additional legacy example: docs/component-defaults-example.yaml

Testing

New Test Suites (63 test cases total):

  • TestParseDataArgs - Data argument parsing with various types and formats
  • TestConfigHierarchy - Configuration file priority order
  • TestMergeWithCLIData - CLI override behavior with lists and maps
  • TestFormatDataValue - All copier data types including multiselect
  • TestFormatYAMLList - List formatting for multiselect questions
  • TestFormatYAMLMap - Map formatting for complex objects

TESTING

# All tests passing
go test ./cmd/component/... ./internal/copier/... ./internal/config/...

# Example usage
dr component add agent --data owner_name="DataRobot"
dr component update ./my-component --data enable_auth=true --data python_versions=[3.10,3.11,3.12]
dr component add base --data-file ./team-defaults.yaml

@carsongee
Copy link
Contributor Author

I'm leaving this as a draft for now since it is a "nice to have" more than a hard requirement. At some point, it would be good to add

Copy link

@damon-sava-stanley damon-sava-stanley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think --data args and intermediary configuration files should be straightforward enough to support in studio. Seems a nice feature for the CLI :).

{
name: "list of strings",
value: []interface{}{"postgres", "mysql", "sqlite"},
expected: "[postgres, mysql, sqlite]",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we want to force quotes around strings here (in case the strings are reserved identifiers). (Maybe just JSON format? As a YAML subset)

// Priority order:
// 1. Explicitly provided path (if not empty)
// 2. .datarobot/.copier-answers-defaults.yaml in repo root
// 3. ~/.config/datarobot/.copier-answers-defaults.yaml

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably me not being up to date, but what's the use case for 3/4? (I guess naively I would expect us just to refer to defaults in copier.yml in the repos.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants