Skip to content

Commit 80869cb

Browse files
authored
chore: Enable local workflow source inputs with frozen workflow lockfile (#1648)
Reference: https://linear.app/speakeasy/issue/TFGEN-165/bug-snapshot-test-failures-due-to-custom-code Previously, the internal usage frozen workflow lockfile flag would always download OAS from the registry. For various reasons, local sources may not be fully synchronized with the registry. This change checks the workflow source inputs to determine if any are remote and only then downloads from the registry for ensured access and consistency.
1 parent 3a5f9fc commit 80869cb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

internal/run/source.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func (e *LintingError) Error() string {
7979
func (w *Workflow) RunSource(ctx context.Context, parentStep *workflowTracking.WorkflowStep, sourceID, targetID, targetLanguage string) (string, *SourceResult, error) {
8080
rootStep := parentStep.NewSubstep(fmt.Sprintf("Source: %s", sourceID))
8181
source := w.workflow.Sources[sourceID]
82+
hasRemoteInputs := workflowSourceHasRemoteInputs(source)
8283
sourceRes := &SourceResult{
8384
Source: sourceID,
8485
Diagnosis: suggestions.Diagnosis{},
@@ -109,7 +110,7 @@ func (w *Workflow) RunSource(ctx context.Context, parentStep *workflowTracking.W
109110
rootStep.NewSubstep("Using Source Location Override")
110111
currentDocument = w.SourceLocation
111112
frozenSource = true
112-
} else if w.FrozenWorkflowLock {
113+
} else if w.FrozenWorkflowLock && hasRemoteInputs {
113114
frozenSource = true
114115
currentDocument, err = NewFrozenSource(w, rootStep, sourceID).Do(ctx, "unused")
115116
if err != nil {
@@ -312,6 +313,17 @@ func getTempApplyPath(path string) string {
312313
return filepath.Join(workflow.GetTempDir(), fmt.Sprintf("applied_%s%s", randStringBytes(10), filepath.Ext(path)))
313314
}
314315

316+
// Returns true if any of the source inputs are remote.
317+
func workflowSourceHasRemoteInputs(source workflow.Source) bool {
318+
for _, input := range source.Inputs {
319+
if input.IsRemote() {
320+
return true
321+
}
322+
}
323+
324+
return false
325+
}
326+
315327
// Reformats yaml to json if necessary and writes to the output location
316328
func writeToOutputLocation(ctx context.Context, documentPath string, outputLocation string) error {
317329
// If paths are the same, no need to do anything

0 commit comments

Comments
 (0)