Skip to content

Commit

Permalink
Merge branch 'main' into konrad_natural_lang
Browse files Browse the repository at this point in the history
  • Loading branch information
konradjniemiec committed Jan 13, 2024
2 parents 3b02974 + e695609 commit cefa6a4
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/lekko/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ func featureEval() *cobra.Command {
}

fmt.Fprintf(os.Stderr, "[%s] ", fType)
fmt.Printf("%s", res)
fmt.Printf("%v", res)
fmt.Println()
if verbose {
fmt.Fprintf(os.Stderr, "[path] %v\n", path)
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/migueleliasweb/go-github-mock v0.0.16
github.com/mitchellh/go-homedir v1.1.0
github.com/olekukonko/tablewriter v0.0.5
github.com/shurcooL/githubv4 v0.0.0-20231126234147-1cffa1f02456
github.com/spf13/cobra v1.5.0
github.com/stoewer/go-strcase v1.2.0
github.com/stretchr/testify v1.8.0
Expand Down Expand Up @@ -72,6 +73,7 @@ require (
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 // indirect
github.com/skeema/knownhosts v1.1.1 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.9.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/githubv4 v0.0.0-20231126234147-1cffa1f02456 h1:6dExqsYngGEiixqa1vmtlUd+zbyISilg0Cf3GWVdeYM=
github.com/shurcooL/githubv4 v0.0.0-20231126234147-1cffa1f02456/go.mod h1:zqMwyHmnN/eDOZOdiTohqIUKUrTFX62PNlu7IJdu0q8=
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466 h1:17JxqqJY66GmZVHkmAsGEkcIu0oCe3AM420QDgGwZx0=
github.com/shurcooL/graphql v0.0.0-20230722043721-ed46e5a46466/go.mod h1:9dIRpgIY7hVhoqfe0/FcYp0bpInZaT7dc3BYOprrIUE=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/skeema/knownhosts v1.1.1 h1:MTk78x9FPgDFVFkDLTrsnnfCJl7g1C/nnKvePgrIngE=
github.com/skeema/knownhosts v1.1.1/go.mod h1:g4fPeYpque7P0xefxtGzV81ihjC8sX2IqpAoNkjxbMo=
Expand Down
2 changes: 2 additions & 0 deletions pkg/encoding/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func ParseFeature(ctx context.Context, rootPath string, featureFile feature.Feat
case feature.NamespaceVersionV1Beta5.String():
fallthrough
case feature.NamespaceVersionV1Beta6.String():
fallthrough
case feature.NamespaceVersionV1Beta7.String():
var f featurev1beta1.Feature
contents, err := provider.GetFileContents(ctx, filepath.Join(rootPath, nsMD.Name, featureFile.CompiledProtoBinFileName))
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions pkg/gh/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/go-git/go-git/v5"
"github.com/google/go-github/v52/github"
"github.com/pkg/errors"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
)

Expand All @@ -37,20 +38,20 @@ const (
// relevant to lekko.
type GithubClient struct {
*github.Client
Graphql *githubv4.Client
}

func NewGithubClient(h *http.Client) *GithubClient {
return &GithubClient{
Client: github.NewClient(h),
Client: github.NewClient(h),
Graphql: githubv4.NewClient(h),
}
}

func NewGithubClientFromToken(ctx context.Context, token string) *GithubClient {
ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
tc := oauth2.NewClient(ctx, ts)
return &GithubClient{
Client: github.NewClient(tc),
}
return NewGithubClient(tc)
}

func (gc *GithubClient) GetUser(ctx context.Context) (*github.User, error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/repo/feature.go
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ func (r *repository) Compile(ctx context.Context, req *CompileRequest) ([]*Featu
nsContextTypes := make(map[string]protoreflect.MessageType)
for ns, nsMd := range nsMDs {
if nsMd.ContextProto != "" {
r.Logf("%s: %s\n", ns, nsMd.ContextProto)
ct, err := registry.FindMessageByName(protoreflect.FullName(nsMd.ContextProto))
if err != nil {
return nil, err
Expand All @@ -442,7 +441,7 @@ func (r *repository) Compile(ctx context.Context, req *CompileRequest) ([]*Featu
"double",
"string":
default:
return nil, errors.New("Invalid context type thingy make this better")
return nil, errors.Errorf("proto message cannot be used as a context message because type: %v of key: %s is not allowed", f.Kind(), f.Name())
}
}
nsContextTypes[ns] = ct
Expand Down
10 changes: 10 additions & 0 deletions proto/lekko/bff/v1beta1/bff.proto
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,15 @@ message GetFeatureHistoryResponse {
repeated FeatureHistoryItem history = 1;
}

// The configs will have metadata fields populated based on the latest rolled
// out version of the repo.
// If a config was newly created since, created_at will not be set.
// If a config existed already but was updated, last_updated_at will not be set.
message ConfigMetadata {
google.protobuf.Timestamp created_at = 1;
google.protobuf.Timestamp last_updated_at = 2;
}

message Feature {
string name = 1;
string namespace_name = 2;
Expand All @@ -479,6 +488,7 @@ message Feature {
// the blob sha of the proto bin file according to git
string sha = 6;
lekko.feature.v1beta1.StaticFeature static_feature_new = 7;
ConfigMetadata metadata = 8;
}

message FeatureHistoryItem {
Expand Down

0 comments on commit cefa6a4

Please sign in to comment.