Skip to content

Commit

Permalink
feat: code samples config path (#1243)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-timothy-albert authored Feb 3, 2025
1 parent 347356a commit 98553eb
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions internal/run/target.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,17 +232,20 @@ func (w *Workflow) runTarget(ctx context.Context, target string) (*SourceResult,
}

// Returns codeSamples namespace name and digest
func (w *Workflow) runCodeSamples(ctx context.Context, codeSamplesStep *workflowTracking.WorkflowStep, codeSamples workflow.CodeSamples, target, sourcePath string, baseOutputPath *string) (string, string, error) {
func (w *Workflow) runCodeSamples(ctx context.Context, codeSamplesStep *workflowTracking.WorkflowStep, codeSamples workflow.CodeSamples, target, sourcePath string, targetOutputPath *string) (string, string, error) {
configPath := "."
outputPath := codeSamples.Output

// If an output path is specified, make sure it's relative to the base output path
if baseOutputPath != nil && outputPath != "" {
configPath = *baseOutputPath
outputPath = filepath.Join(*baseOutputPath, outputPath)
writeFileLocation := codeSamples.Output

if targetOutputPath != nil {
// configPath should be relative to the target output path for nested SDKs
configPath = *targetOutputPath
// If a write file location is specified, make sure it's relative to the target output path
if writeFileLocation != "" {
writeFileLocation = filepath.Join(*targetOutputPath, writeFileLocation)
}
}

overlayString, err := codesamples.GenerateOverlay(ctx, sourcePath, "", "", configPath, outputPath, []string{target}, true, false, codeSamples)
overlayString, err := codesamples.GenerateOverlay(ctx, sourcePath, "", "", configPath, writeFileLocation, []string{target}, true, false, codeSamples)
if err != nil {
return "", "", err
}
Expand Down

0 comments on commit 98553eb

Please sign in to comment.