Complete session defaults within the ConfigKit lifecycle
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"gitea.maximumdirect.net/eric/narratio/internal/config"
|
||||
"go.maximumdirect.net/ckconfig"
|
||||
"go.maximumdirect.net/commandkit"
|
||||
)
|
||||
@@ -22,7 +23,8 @@ func operationOutcome(err error) commandkit.Outcome {
|
||||
}
|
||||
|
||||
func classifyOperationError(err error) commandkit.OutcomeKind {
|
||||
if _, ok := err.(*inputError); ok {
|
||||
switch err.(type) {
|
||||
case *inputError, *config.SessionIdentityError:
|
||||
return commandkit.OutcomeUsage
|
||||
}
|
||||
switch wrapped := err.(type) {
|
||||
|
||||
@@ -92,6 +92,7 @@ func TestOperationOutcomePreservesCausesAndOperationalPrecedence(t *testing.T) {
|
||||
status int
|
||||
}{
|
||||
{nil, 0}, {input, 2}, {invalid, 2},
|
||||
{&config.SessionIdentityError{Source: "session.yml", Field: "session_id", Expected: "one", Actual: "two"}, 2},
|
||||
{fmt.Errorf("request: %w", errors.Join(input, invalid)), 2},
|
||||
{errors.Join(input, operational), 1},
|
||||
{fmt.Errorf("request: %w", errors.Join(invalid, context.Canceled)), 1},
|
||||
|
||||
@@ -54,6 +54,9 @@ func loadCommandConfigWithDependencies(ctx context.Context, pipelineFlag, campai
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sessionOpts.Campaign = base.Campaign
|
||||
sessionOpts.CampaignPath = base.CampaignPath
|
||||
|
||||
if explicitSession := strings.TrimSpace(sessionFlag); explicitSession != "" {
|
||||
cfg, err := config.LoadSessionWithPipelineCampaignOptions(*base, explicitSession, sessionOpts)
|
||||
if err != nil {
|
||||
|
||||
@@ -97,6 +97,8 @@ func sessionInitWithDependencies(ctx context.Context, args []string, out io.Writ
|
||||
authoringPath = resolveSessionInitTemplatePath(input.CampaignPath, input.TemplateFile)
|
||||
}
|
||||
sessionCfg, err := config.LoadSessionAuthoringBytes(authoringPath, data, config.SessionLoadOptions{
|
||||
Campaign: base.Campaign,
|
||||
CampaignPath: base.CampaignPath,
|
||||
SessionID: sessionID,
|
||||
PreviousSessionID: previousSessionID,
|
||||
})
|
||||
|
||||
@@ -28,7 +28,7 @@ func TestSessionInitMaterializesLocalTemplateImports(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if loaded.Title != "Shared metadata" || loaded.Inputs.SpeakersFile != "" {
|
||||
if loaded.Title != "Shared metadata" || loaded.Inputs.SpeakersFile != filepath.Join(filepath.Dir(campaign), "speakers.yml") {
|
||||
t.Fatalf("unexpected standalone session: %#v", loaded)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user