Skip to content

[BUZZOK-31816] feat: respect APPLICATION_TEMPLATE_GIT_BASE_URL in dr component commands - #722

Draft
tsdaemon with Copilot wants to merge 4 commits into
mainfrom
copilot/respect-env-variable-application-template-git-base
Draft

[BUZZOK-31816] feat: respect APPLICATION_TEMPLATE_GIT_BASE_URL in dr component commands#722
tsdaemon with Copilot wants to merge 4 commits into
mainfrom
copilot/respect-env-variable-application-template-git-base

Conversation

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

All dr component subcommands now replace known DataRobot GitHub base URLs (https://github.com/datarobot-community, https://github.com/datarobot) with APPLICATION_TEMPLATE_GIT_BASE_URL when that env var is set — enabling air-gapped / corporate mirror setups.

Changes

Core helpers — internal/copier/giturl.go (new)

  • ApplyGitBaseURL(url) — rewrites a URL's base prefix if the env var is set; handles both DataRobot GitHub orgs, strips trailing slash, no-ops when unset or prefix unrecognised
  • RewriteSrcPathIfNeeded(yamlFile) — patches _src_path in an existing copier answers file in-place; no-op when env var is unset or URL already uses the custom base

dr component add

  • ApplyGitBaseURL applied to the resolved repo URL before passing to copier, so newly-added components write the correct _src_path from the start

dr component update (CLI + TUI flows)

  • RewriteSrcPathIfNeeded called before copier update, migrating legacy answers files that still contain old GitHub URLs
  • Applies in both the runUpdate (non-interactive) path and the TUI updateComponent path

dr component list (indirect)

  • ComponentDetailsByURL index in init() now also registers the remapped URL variant, so component-name resolution continues to work after answers files have been rewritten
export APPLICATION_TEMPLATE_GIT_BASE_URL=https://gitlab.internal.corp/datarobot-mirror

# add: copier receives the mirror URL; answers file written with mirror URL
dr component add agent

# update: _src_path in .datarobot/answers/*.yml rewritten before copier runs
dr component update

@tsdaemon

Copy link
Copy Markdown
Collaborator

@copilot can you move rewriting action in a separate command dr component rewrite-config

Copilot AI commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@copilot can you move rewriting action in a separate command dr component rewrite-config

Done. The rewriting logic has been moved to a new dr component rewrite-config command (commit feat: add dr component rewrite-config command for URL migration). The automatic RewriteSrcPathIfNeeded calls have been removed from both the runUpdate path and the TUI updateComponent path, so the migration is now an explicit opt-in step.

Copilot AI requested a review from tsdaemon July 29, 2026 15:03
@ajalon1

ajalon1 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

@copilot For any work done in this PR so far, as well as future updates -- make sure to update the command and dev docs.

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot For any work done in this PR so far, as well as future updates -- make sure to update the command and dev docs.

Done in commit docs: update command and dev docs for rewrite-config and APPLICATION_TEMPLATE_GIT_BASE_URL:

  • docs/commands/component-managed-updates.md — new "Component Rewrite-Config" section explaining the APPLICATION_TEMPLATE_GIT_BASE_URL air-gapped/mirror workflow and the one-time dr component rewrite-config migration step.
  • docs/commands/README.mdrewrite-config added to the command tree, quick-examples block, command-details list, and the environment variables table.

Copilot AI requested a review from ajalon1 July 30, 2026 00:23
@tsdaemon

Copy link
Copy Markdown
Collaborator

@copilot check that value we get from APPLICATION_TEMPLATE_GIT_BASE_URL has no trailing slash, and remove it if it is

@tsdaemon tsdaemon changed the title feat: respect APPLICATION_TEMPLATE_GIT_BASE_URL in dr component commands [BUZZOK-31816] feat: respect APPLICATION_TEMPLATE_GIT_BASE_URL in dr component commands Jul 30, 2026

Copilot AI commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

@copilot check that value we get from APPLICATION_TEMPLATE_GIT_BASE_URL has no trailing slash, and remove it if it is

This is already handled — ApplyGitBaseURL calls strings.TrimRight(baseURL, "/") before using the value (see internal/copier/giturl.go line 45), and there's a dedicated test case covering it: "env var set – trailing slash in env var is trimmed".

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.

3 participants