Documentation
¶
Overview ¶
Package dtdemo provides the SSH demo's welcome screen, Save-to-GitHub workspace module, and in-memory per-session GitHub authentication state.
Index ¶
- Constants
- func ClassifyChanges(repoDir string, changes []demogit.Change) (projectFiles, dbFiles []demogit.Change)
- func FormatErrorFor(err error, canonical demogit.Repo) string
- func NewSaveScreen(cfg Config) nav.Screen
- func SaveModule(cfg Config) datatugui.Module
- func ScopeExplanation(canonical demogit.Repo) string
- func SessionWarningAt(deadline time.Time) time.Time
- type AuthState
- type Config
- type GitClient
- type WelcomeModel
- type WelcomeOutcome
- type WelcomeResult
Constants ¶
const ( // ModuleID is the datatugui root module ID for Save-to-GitHub. ModuleID = "demo_save" // ModuleText is the menu label for Save-to-GitHub. ModuleText = "Save to GitHub" // GitHubScope is the minimum OAuth scope required to fork a public repo // and push to the visitor's fork. GitHubScope = "public_repo" // DefaultSaveBranch is the default branch name on the visitor's fork. DefaultSaveBranch = "datatug-demo" // SaveNotConfiguredNotice is displayed in the Save module when the demo // server was started against a non-GitHub repository. SaveNotConfiguredNotice = "Saving to GitHub is not configured on this demo server." // ExternalDatabasesNotice states that external databases are not part of the repo. ExternalDatabasesNotice = "" /* 151-byte string literal not displayed */ // SessionWarning is shown just before the supervisor ends a session. SessionWarning = "Your SSH demo session ends in one minute or less." )
Variables ¶
This section is empty.
Functions ¶
func ClassifyChanges ¶
func ClassifyChanges(repoDir string, changes []demogit.Change) (projectFiles, dbFiles []demogit.Change)
ClassifyChanges splits workspace changes into project files and database files (*.sqlite, *.db, SQLite sidecars, and inGitDB data directories).
func FormatErrorFor ¶
FormatErrorFor turns a demogit or device-flow error into plain words for the visitor.
func NewSaveScreen ¶
NewSaveScreen constructs the Save-to-GitHub workspace screen.
func SaveModule ¶
SaveModule returns the Save-to-GitHub root module entry for the workspace menu.
func ScopeExplanation ¶
ScopeExplanation explains what the public_repo OAuth scope allows and how DataTug uses and discards the token.
Types ¶
type AuthState ¶
type AuthState struct {
// contains filtered or unexported fields
}
AuthState holds one visitor's GitHub sign-in state in process memory only. The token is never persisted, logged, written to git config, or printed.
func NewAuthState ¶
func NewAuthState() *AuthState
NewAuthState creates an empty in-memory GitHub sign-in state.
type Config ¶
type Config struct {
Canonical demogit.Repo
RepoDir string
ProjectDir string
SaveBranch string
GitHubClientID string
Deadline time.Time
Auth *AuthState
// Optional overrides for the device-flow screen in tests.
RequestDeviceCode func(ctx context.Context, clientID, scope string) (*ghauth.DeviceCodeResponse, error)
PollForToken func(ctx context.Context, clientID, clientSecret, deviceCode string, interval int, onAttempt func(int)) (*oauth2.Token, error)
}
Config holds the session-wide parameters shared by the welcome screen and the Save-to-GitHub workspace module.
func (Config) GitHubEnabled ¶
GitHubEnabled reports whether GitHub sign-in, fork opening, and saving are configured for this demo session (i.e. Canonical names a GitHub owner/repo).
type GitClient ¶
type GitClient interface {
User(ctx context.Context) (string, error)
FindFork(ctx context.Context) (demogit.Repo, error)
EnsureFork(ctx context.Context) (fork demogit.Repo, created bool, err error)
Save(ctx context.Context, repoDir string, fork demogit.Repo, opts demogit.SaveOptions) (demogit.SaveResult, error)
Open(ctx context.Context, fork demogit.Repo, destDir, projectDir string) (branch string, err error)
NewBranchName() string
}
GitClient is the subset of *demogit.Client used by dtdemo screens. Production uses demogit.New; tests substitute a fake through newGitClient.
type WelcomeModel ¶
type WelcomeModel struct {
// contains filtered or unexported fields
}
WelcomeModel is the Bubble Tea model shown at the start of an SSH demo session before the full DataTug workspace launches.
func NewWelcomeModel ¶
func NewWelcomeModel(cfg Config) WelcomeModel
NewWelcomeModel creates the initial welcome screen model.
func (WelcomeModel) Result ¶
func (m WelcomeModel) Result() WelcomeResult
Result returns the visitor's outcome once the model quits.
type WelcomeOutcome ¶
type WelcomeOutcome int
WelcomeOutcome describes how the visitor left the demo welcome screen.
const ( // OutcomeQuit means the visitor quit before entering the workspace. OutcomeQuit WelcomeOutcome = iota // OutcomeExplore means the visitor chose to explore the fresh demo template. OutcomeExplore // OutcomeOpenedFork means the visitor signed in and opened their fork into RepoDir. OutcomeOpenedFork )
type WelcomeResult ¶
type WelcomeResult struct {
Outcome WelcomeOutcome
Fork demogit.Repo
Branch string
}
WelcomeResult is the outcome of the welcome screen.
func RunWelcome ¶
func RunWelcome(cfg Config, opts ...tea.ProgramOption) (WelcomeResult, error)
RunWelcome displays the demo welcome screen and returns the visitor's choice.