Skip to content

Commit f9a0cb2

Browse files
committed
refactor: split onboarding message contracts by domain
1 parent b2db0d4 commit f9a0cb2

12 files changed

Lines changed: 158 additions & 153 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package msgs
2+
3+
import "github.com/usetero/cli/internal/domain"
4+
5+
// AccountSelected is emitted when user selects an account.
6+
type AccountSelected struct {
7+
Org domain.Organization
8+
Account domain.Account
9+
}
10+
11+
// NoAccounts is emitted when no accounts exist for the org.
12+
type NoAccounts struct {
13+
Org domain.Organization
14+
}
15+
16+
// AccountCreated is emitted when a new account is created.
17+
type AccountCreated struct {
18+
Org domain.Organization
19+
Account domain.Account
20+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package msgs
2+
3+
import "github.com/usetero/cli/internal/auth"
4+
5+
// Authenticated is emitted when authentication succeeds.
6+
type Authenticated struct {
7+
User auth.User
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package msgs
2+
3+
import (
4+
"github.com/usetero/cli/internal/auth"
5+
"github.com/usetero/cli/internal/domain"
6+
)
7+
8+
// OnboardingComplete is emitted to the root model when onboarding finishes.
9+
type OnboardingComplete struct {
10+
User *auth.User
11+
Org domain.Organization
12+
Account domain.Account
13+
Workspace domain.Workspace
14+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package msgs
2+
3+
import "github.com/usetero/cli/internal/domain"
4+
5+
// DatadogReady is emitted when datadog is already configured.
6+
type DatadogReady struct{}
7+
8+
// DatadogNeeded is emitted when datadog setup is required.
9+
type DatadogNeeded struct{}
10+
11+
// DatadogRegionSelected is emitted when user selects a datadog region.
12+
type DatadogRegionSelected struct {
13+
Site domain.DatadogSite
14+
}
15+
16+
// DatadogAPIKeyEntered is emitted when user enters API key.
17+
type DatadogAPIKeyEntered struct {
18+
APIKey string
19+
}
20+
21+
// DatadogAccountCreated is emitted when datadog account is created.
22+
type DatadogAccountCreated struct {
23+
DatadogAccountID domain.DatadogAccountID
24+
}
25+
26+
// DatadogDiscoveryComplete is emitted when discovery finishes.
27+
type DatadogDiscoveryComplete struct{}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package msgs defines onboarding message contracts between steps and orchestrator.
2+
package msgs

‎internal/app/onboarding/msgs/msgs.go‎

Lines changed: 0 additions & 153 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package msgs
2+
3+
import "github.com/usetero/cli/internal/domain"
4+
5+
// OrgSelected is emitted when user selects an organization.
6+
type OrgSelected struct {
7+
Org domain.Organization
8+
}
9+
10+
// NoOrgs is emitted when no organizations exist.
11+
type NoOrgs struct{}
12+
13+
// OrgCreated is emitted when a new organization is created.
14+
type OrgCreated struct {
15+
Org domain.Organization
16+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package msgs
2+
3+
import "github.com/usetero/cli/internal/domain"
4+
5+
// PreflightOutcome indicates confidence in preflight-derived routing.
6+
type PreflightOutcome string
7+
8+
const (
9+
PreflightOutcomeResolved PreflightOutcome = "resolved"
10+
PreflightOutcomeInconclusive PreflightOutcome = "inconclusive"
11+
PreflightOutcomeFailed PreflightOutcome = "failed"
12+
)
13+
14+
// PreflightState captures startup readiness signals used to choose the first gate.
15+
type PreflightState struct {
16+
Outcome PreflightOutcome
17+
HasValidAuth bool
18+
Role string
19+
ActiveOrgID domain.OrganizationID
20+
DefaultAccountID domain.AccountID
21+
DefaultWorkspaceID domain.WorkspaceID
22+
Org *domain.Organization
23+
Account *domain.Account
24+
Workspace *domain.Workspace
25+
HasDatadog bool
26+
Error string
27+
}
28+
29+
// PreflightResolved is emitted after startup preflight completes.
30+
type PreflightResolved struct {
31+
State PreflightState
32+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package msgs
2+
3+
// Role constants.
4+
const (
5+
RolePlatform = "platform"
6+
RoleEngineer = "engineer"
7+
)
8+
9+
// RoleSelected is emitted when user selects their role.
10+
type RoleSelected struct {
11+
Role string
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package msgs
2+
3+
import "github.com/usetero/cli/internal/domain"
4+
5+
// EnsureRuntime requests runtime initialization for the selected account.
6+
type EnsureRuntime struct {
7+
Org domain.Organization
8+
Account domain.Account
9+
}
10+
11+
// RuntimeReady is emitted when account runtime is initialized.
12+
type RuntimeReady struct {
13+
Org domain.Organization
14+
Account domain.Account
15+
}

0 commit comments

Comments
 (0)