Skip to content

Commit

Permalink
refactor(api/proto): optimize
Browse files Browse the repository at this point in the history
  • Loading branch information
bounoable committed Sep 24, 2022
1 parent 8f1da76 commit 4ef6cce
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ generate:
.PHONY: test
test:
@go test -v ./...
@go test -v ./api/proto/...
@go test -v ./goes/esgallery/...
6 changes: 3 additions & 3 deletions api/proto/gen/gallery/v0/gallery.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ func NewStack[StackID, ImageID gallery.ID](s gallery.Stack[StackID, ImageID]) *S
return &Stack{
Id: s.ID.String(),
Variants: slicex.Map(s.Variants, NewVariant[ImageID]),
Tags: slicex.Ensure(s.Tags),
Tags: s.Tags,
}
}

func AsStack[StackID, ImageID gallery.ID](s *Stack, toStackID func(string) StackID, toImageID func(string) ImageID) gallery.Stack[StackID, ImageID] {
return gallery.Stack[StackID, ImageID]{
ID: toStackID(s.GetId()),
Variants: slicex.Map(s.GetVariants(), func(img *Image) gallery.Image[ImageID] {
Variants: slicex.Ensure(slicex.Map(s.GetVariants(), func(img *Image) gallery.Image[ImageID] {
return AsImage(img, toImageID)
}),
})),
Tags: slicex.Ensure(s.GetTags()),
}
}
Expand Down

0 comments on commit 4ef6cce

Please sign in to comment.