Skip to content

Add deployment registry selector#371

Merged
timothyF95 merged 17 commits intomainfrom
add-deployment-registry-selector
Apr 16, 2026
Merged

Add deployment registry selector#371
timothyF95 merged 17 commits intomainfrom
add-deployment-registry-selector

Conversation

@timothyF95
Copy link
Copy Markdown
Contributor

@timothyF95 timothyF95 commented Apr 14, 2026

Summary

Adds an optional deployment-registry field to user-workflow settings that lets workflow commands resolve registry configuration dynamically from context.yaml instead of using hardcoded environments.yaml defaults. When omitted, behaviour is unchanged (backward compatible). Off-chain registries are gated in production and rejected by on-chain-only commands (deploy, pause, activate, delete) with a clear error until off-chain routing is implemented.

Changes:

  • New DeploymentRegistry field on UserWorkflowSettings, read via Viper
  • ResolveRegistry helper resolves registry by ID from tenant context, branching on type (on-chain / off-chain), with fallback to EnvironmentSet defaults
  • ResolvedRegistry wired into runtime.Context; deploy, pause, activate, delete read from it instead of EnvironmentSet directly
  • RequireOnChainRegistry guard rejects off-chain registries early with an actionable error message

Example workflow.yaml

staging-settings:
  user-workflow:
    workflow-name: "my-workflow-staging"
    deployment-registry: "onchain:ethereum-testnet-sepolia"           <--- new (optional)
  workflow-artifacts:
    workflow-path: "."
    config-path: "./config.staging.json"
    secrets-path: ""

Precedence hierarchy

deployment-registry set?
├── YES → context.yaml registry entry (env vars ignored)
└── NO  → CRE_CLI_WORKFLOW_REGISTRY_* env var
          └── not set → embedded environments.yaml default

@@ -1,4 +1,4 @@
package testutil
package testsettings
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This was moved to avoid an import cycle

@timothyF95 timothyF95 marked this pull request as ready for review April 14, 2026 12:24
@timothyF95 timothyF95 requested a review from a team as a code owner April 14, 2026 12:24
Comment thread internal/settings/registry_resolution.go Outdated
Comment thread internal/settings/registry_resolution.go Outdated
Comment thread internal/settings/registry_resolution.go Outdated
@timothyF95 timothyF95 force-pushed the add-deployment-registry-selector branch from 5accbfc to f57f2be Compare April 15, 2026 16:55
Comment on lines +65 to +67
if deploymentRegistry == "" {
return defaultFromEnvironmentSet(envSet), nil
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should add a follow up task to plan full migration and clean up? E.g. introduce extra warning and deprecation message, automatically "fix" user settings without this registry, and after some time clean up this branch, after majority of users will migrate.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you clarify what you mean by automatically "fix"? Fetch tenantCtx again and rebuild struct?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, run the login flow in the background to fetch tenant ctx

Comment on lines +69 to +71
if tenantCtx == nil {
return nil, fmt.Errorf("deployment-registry %q is set but user context is not available — run `cre login` and retry", deploymentRegistry)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What if we started the login flow here, so we make the experience more smooth?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a good suggestion 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So I looked into this and it's more complicated than I first thought. I suggest we follow up as a UX enhancement and keep this PR scope down

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you add a task for it?

Comment thread internal/settings/registry_resolution.go Outdated
Comment thread internal/settings/registry_resolution.go Outdated
Comment thread internal/settings/registry_resolution.go Outdated
Comment thread internal/settings/registry_resolution.go
Comment thread cmd/workflow/deploy/deploy.go
// ChainNameFromSelectorString parses a raw chain-selector string and resolves
// it to a chain name. It combines the string-to-uint64 conversion with the
// selector-to-name lookup in a single call.
func ChainNameFromSelectorString(raw string) (string, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: we could have some tests for that

Copy link
Copy Markdown
Contributor

@j-nowak j-nowak left a comment

Choose a reason for hiding this comment

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

Approved, can you add tickets for follow ups?

@timothyF95 timothyF95 added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit fbb6c20 Apr 16, 2026
22 checks passed
@timothyF95 timothyF95 deleted the add-deployment-registry-selector branch April 16, 2026 09:01
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