Skip to content

Commit

Permalink
comments
Browse files Browse the repository at this point in the history
  • Loading branch information
konradjniemiec committed Jan 16, 2024
1 parent 8c426ba commit ff86ff0
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions cmd/lekko/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ var typeRegistry *protoregistry.Types
const StaticBytes = false
const UnSafeClient = false

// Natural language codegen is in super alpha, only handles a subset
// of what is available, namely only supports protos that are one level
// deep with non-repeated primitives, a subset of ruleslang (== and in ops)
// Also doesn't support external types.
func genGoCmd() *cobra.Command {
var ns string
var wd string
Expand Down Expand Up @@ -115,14 +119,18 @@ func genGoCmd() *cobra.Command {
protoAsByteStrings = append(protoAsByteStrings, protoAsBytes)
}
}
// TODOs for the template:
// proper handling of gofmt for imports, importing slices
// depending on the go version.
const templateBody = `package lekko{{$.Namespace}}
import (
"context"
{{range $.ProtoImports}}
{{ . }}{{end}}
"context"
"golang.org/x/exp/slices"
client "github.com/lekkodev/go-sdk/client"
"golang.org/x/exp/slices"
)
type LekkoClient struct {
Expand Down Expand Up @@ -245,9 +253,9 @@ func (c *SafeLekkoClient) {{$.FuncName}}(ctx *{{$.StaticType}}) {{$.RetType}} {
const protoTemplateBody = `{{if $.UnSafeClient}}
// {{$.Description}}
func (c *LekkoClient) {{$.FuncName}}(ctx context.Context) (*{{$.RetType}}, error) {
result := &{{$.RetType}}{}
err := c.{{$.GetFunction}}(ctx, "{{$.Namespace}}", "{{$.Key}}", result)
return result, err
result := &{{$.RetType}}{}
err := c.{{$.GetFunction}}(ctx, "{{$.Namespace}}", "{{$.Key}}", result)
return result, err
}
{{end}}
// {{$.Description}}
Expand Down

0 comments on commit ff86ff0

Please sign in to comment.