Skip to content

Commit 9de80c8

Browse files
mirkoCrobumirkoCrobu
authored andcommitted
make example doc optional for example details
1 parent d4409ec commit 9de80c8

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

internal/orchestrator/bricks/bricks.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,14 @@ func (s *Service) BricksDetails(id string) (BrickDetailsResult, error) {
154154
if err != nil {
155155
return BrickDetailsResult{}, fmt.Errorf("cannot open code examples for brick %s: %w", id, err)
156156
}
157-
codeExamples := f.Map(examplePaths, func(p *paths.Path) CodeExample {
158-
return CodeExample{
159-
Path: p.String(),
160-
}
161-
})
157+
var codeExamples []CodeExample
158+
if examplePaths != nil {
159+
codeExamples = f.Map(examplePaths, func(p *paths.Path) CodeExample {
160+
return CodeExample{
161+
Path: p.String(),
162+
}
163+
})
164+
}
162165

163166
return BrickDetailsResult{
164167
ID: id,

internal/store/store.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ func (s *StaticStore) GetBrickCodeExamplesPathFromID(brickID string) (paths.Path
9999
targetDir := paths.New(s.codeExamplesPath, namespace, brickName)
100100
dirEntries, err := targetDir.ReadDir()
101101
if err != nil {
102+
if errors.Is(err, os.ErrNotExist) {
103+
return nil, nil
104+
}
102105
return nil, fmt.Errorf("cannot read examples directory %q: %w", targetDir, err)
103106
}
104107
return dirEntries, nil

0 commit comments

Comments
 (0)