Skip to content

Commit

Permalink
Merge pull request #97 from loopholelabs/staging
Browse files Browse the repository at this point in the history
Release v0.4.3
  • Loading branch information
ShivanshVij authored Apr 20, 2022
2 parents 83a7cc1 + aefc2f9 commit e869d8d
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 21 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [v0.4.3] - 2022-04-20 (Beta)

## Fixes

- Version [v0.4.2][v0.4.2] did not embed the templates for RPC generation into frisbee, leading to runtime panics when
generating RPC frameworks from outside the frisbee repository directory. This has now been fixed by embedding the
templates into the compiled plugin binary file.

## [v0.4.2] - 2022-04-20 (Beta)

## Changes
Expand Down Expand Up @@ -219,7 +227,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

Initial Release of Frisbee

[unreleased]: https://github.com/loopholelabs/frisbee/compare/v0.4.2...HEAD
[unreleased]: https://github.com/loopholelabs/frisbee/compare/v0.4.3...HEAD
[v0.4.3]: https://github.com/loopholelabs/frisbee/compare/v0.4.2...v0.4.3
[v0.4.2]: https://github.com/loopholelabs/frisbee/compare/v0.4.1...v0.4.2
[v0.4.1]: https://github.com/loopholelabs/frisbee/compare/v0.4.0...v0.4.1
[v0.4.0]: https://github.com/loopholelabs/frisbee/compare/v0.3.2...v0.4.0
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/loopholelabs/frisbee

go 1.15
go 1.16

require (
github.com/loopholelabs/testing v0.2.3
Expand Down
4 changes: 2 additions & 2 deletions protoc-gen-frisbee/dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang as builder

ENV GOOS=linux GOARCH=amd64 CGO_ENABLED=0

RUN go install github.com/loopholelabs/frisbee/[email protected].1
RUN go install github.com/loopholelabs/frisbee/[email protected].3

# Note, the Docker images must be built for amd64. If the host machine architecture is not amd64
# you need to cross-compile the binary and move it into /go/bin.
Expand All @@ -12,7 +12,7 @@ FROM scratch

# Runtime dependencies
LABEL "build.buf.plugins.runtime_library_versions.0.name"="github.com/loopholelabs/frisbee"
LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.4.1"
LABEL "build.buf.plugins.runtime_library_versions.0.version"="v0.4.3"

COPY --from=builder /go/bin /

Expand Down
39 changes: 22 additions & 17 deletions protoc-gen-frisbee/pkg/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package generator
import (
"github.com/loopholelabs/frisbee/protoc-gen-frisbee/internal/utils"
"github.com/loopholelabs/frisbee/protoc-gen-frisbee/internal/version"
"github.com/loopholelabs/frisbee/protoc-gen-frisbee/templates"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/pluginpb"
Expand All @@ -29,6 +30,27 @@ type Generator struct {
options *protogen.Options
}

var templ *template.Template

func init() {
templ = template.Must(template.New("main").Funcs(template.FuncMap{
"CamelCase": utils.CamelCaseFullName,
"CamelCaseName": utils.CamelCaseName,
"MakeIterable": utils.MakeIterable,
"Counter": utils.Counter,
"FirstLowerCase": utils.FirstLowerCase,
"FirstLowerCaseName": utils.FirstLowerCaseName,
"FindValue": findValue,
"GetKind": getKind,
"GetLUTEncoder": getLUTEncoder,
"GetLUTDecoder": getLUTDecoder,
"GetEncodingFields": getEncodingFields,
"GetDecodingFields": getDecodingFields,
"GetKindLUT": getKindLUT,
"GetServerFields": getServerFields,
}).ParseFS(templates.FS, "*"))
}

func New() *Generator {
return &Generator{
options: &protogen.Options{
Expand All @@ -53,23 +75,6 @@ func (g *Generator) Generate(req *pluginpb.CodeGeneratorRequest) (res *pluginpb.
return nil, err
}

templ := template.Must(template.New("main").Funcs(template.FuncMap{
"CamelCase": utils.CamelCaseFullName,
"CamelCaseName": utils.CamelCaseName,
"MakeIterable": utils.MakeIterable,
"Counter": utils.Counter,
"FirstLowerCase": utils.FirstLowerCase,
"FirstLowerCaseName": utils.FirstLowerCaseName,
"FindValue": findValue,
"GetKind": getKind,
"GetLUTEncoder": getLUTEncoder,
"GetLUTDecoder": getLUTDecoder,
"GetEncodingFields": getEncodingFields,
"GetDecodingFields": getDecodingFields,
"GetKindLUT": getKindLUT,
"GetServerFields": getServerFields,
}).ParseGlob("protoc-gen-frisbee/templates/*"))

for _, f := range plugin.Files {
if !f.Generate {
continue
Expand Down
22 changes: 22 additions & 0 deletions protoc-gen-frisbee/templates/templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2022 Loophole Labs
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package templates

import "embed"

//go:embed *
var FS embed.FS

0 comments on commit e869d8d

Please sign in to comment.