Skip to content

Commit

Permalink
Super basic argless calls (#463)
Browse files Browse the repository at this point in the history
* Super basic argless calls

* merge

* super simple e2e

* comment out test
  • Loading branch information
lekko-jonathan authored Sep 27, 2024
1 parent 6403b17 commit 158cf2f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmd/lekko/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,26 @@ func Test_ProtoJsonToTs(t *testing.T) {
})
}
*/
/*
func Test_blobToTs(t *testing.T) {
repoContents, err := repo.DecodeRepositoryContents([]byte("Cp0CCgdkZWZhdWx0EnUKDWJhbm5lci1jb25maWcaYgovCi10eXBlLmdvb2dsZWFwaXMuY29tL2dvb2dsZS5wcm90b2J1Zi5Cb29sVmFsdWUaLwotdHlwZS5nb29nbGVhcGlzLmNvbS9nb29nbGUucHJvdG9idWYuQm9vbFZhbHVlIAESmgEKBXRoaW5nGo4BCkUKMnR5cGUuZ29vZ2xlYXBpcy5jb20vbGVra28ucnVsZXMudjFiZXRhMy5Db25maWdDYWxsEg8aDWJhbm5lci1jb25maWcaRQoydHlwZS5nb29nbGVhcGlzLmNvbS9sZWtrby5ydWxlcy52MWJldGEzLkNvbmZpZ0NhbGwSDxoNYmFubmVyLWNvbmZpZyABEuwLCvsBCh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8SD2dvb2dsZS5wcm90b2J1ZiI6CghEdXJhdGlvbhIYCgdzZWNvbmRzGAEgASgDUgdzZWNvbmRzEhQKBW5hbm9zGAIgASgFUgVuYW5vc0KDAQoTY29tLmdvb2dsZS5wcm90b2J1ZkINRHVyYXRpb25Qcm90b1ABWjFnb29nbGUuZ29sYW5nLm9yZy9wcm90b2J1Zi90eXBlcy9rbm93bi9kdXJhdGlvbnBi+AEBogIDR1BCqgIeR29vZ2xlLlByb3RvYnVmLldlbGxLbm93blR5cGVzYgZwcm90bzMK4gUKHGdvb2dsZS9wcm90b2J1Zi9zdHJ1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2YWx1ZSIiCgpGbG9hdFZhbHVlEhQKBXZhbHVlGAEgASgCUgV2YWx1ZSIiCgpJbnQ2NFZhbHVlEhQKBXZhbHVlGAEgASgDUgV2YWx1ZSIjCgtVSW50NjRWYWx1ZRIUCgV2YWx1ZRgBIAEoBFIFdmFsdWUiIgoKSW50MzJWYWx1ZRIUCgV2YWx1ZRgBIAEoBVIFdmFsdWUiIwoLVUludDMyVmFsdWUSFAoFdmFsdWUYASABKA1SBXZhbHVlIiEKCUJvb2xWYWx1ZRIUCgV2YWx1ZRgBIAEoCFIFdmFsdWUiIwoLU3RyaW5nVmFsdWUSFAoFdmFsdWUYASABKAlSBXZhbHVlIiIKCkJ5dGVzVmFsdWUSFAoFdmFsdWUYASABKAxSBXZhbHVlQoMBChNjb20uZ29vZ2xlLnByb3RvYnVmQg1XcmFwcGVyc1Byb3RvUAFaMWdvb2dsZS5nb2xhbmcub3JnL3Byb3RvYnVmL3R5cGVzL2tub3duL3dyYXBwZXJzcGL4AQGiAgNHUEKqAh5Hb29nbGUuUHJvdG9idWYuV2VsbEtub3duVHlwZXNiBnByb3RvMw=="))
if err != nil {
panic(err)
}
typeRegistry, err := protoutils.FileDescriptorSetToTypeRegistry(repoContents.FileDescriptorSet)
if err != nil {
panic(err)
}
for _, namespace := range repoContents.Namespaces {
for _, f := range namespace.Features {
code, err := gen.GenTSForFeature(f, namespace.Name, "", typeRegistry)
if err != nil {
panic(err)
}
fmt.Println(code)
}
}
}
*/
15 changes: 15 additions & 0 deletions pkg/gen/ts.go
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,21 @@ func FieldValueToTS(f protoreflect.FieldDescriptor, val protoreflect.Value, type
}

func translateRetValueTS(val *anypb.Any, t featurev1beta1.FeatureType, typeRegistry *protoregistry.Types) string {
// TODO - move to lekkoAny
if val.TypeUrl == "type.googleapis.com/lekko.rules.v1beta3.ConfigCall" {
call := &rulesv1beta3.ConfigCall{}
err := proto.Unmarshal(val.Value, call)
if err != nil {
panic(err)
}
var funcNameBuilder strings.Builder
funcNameBuilder.WriteString("get")
for _, word := range regexp.MustCompile("[_-]+").Split(call.Key, -1) {
funcNameBuilder.WriteString(strings.ToUpper(word[:1]) + word[1:])
}
funcName := funcNameBuilder.String()
return fmt.Sprintf("%s()", funcName)
}
//var dypb *dynamicpb.Message
marshalOptions := protojson.MarshalOptions{
UseProtoNames: true,
Expand Down

0 comments on commit 158cf2f

Please sign in to comment.