Skip to content

Commit 8fd85c7

Browse files
Prepare work for well known types (#2973)
## Changes Prepare work for well known types. Well Known Types have a different wire format than the desired SDK type. We are introducing dedicated types in the genkit model. This PR updates the CLI to recognise these new types, but continue generating the fields with the same type. A follow-up PR will be created to include full support. ## Why Generated CLI with an empty diff. ## Tests <!-- How have you tested the changes? --> <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 1dc39ff commit 8fd85c7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

.codegen/service.go.tmpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func new{{.PascalName}}() *cobra.Command {
128128

129129
var {{.CamelName}}Req {{.Service.Package.Name}}.{{.Request.PascalName}}
130130
{{- if .RequestBodyField }}
131-
{{.CamelName}}Req.{{.RequestBodyField.PascalName}} = {{ if .RequestBodyField.IsOptionalObject }}&{{end}}{{.Service.Package.Name}}.{{.RequestBodyField.Entity.PascalName}}{}
131+
{{.CamelName}}Req.{{.RequestBodyField.PascalName}} = {{ if .RequestBodyField.IsOptionalObjectPb }}&{{end}}{{.Service.Package.Name}}.{{.RequestBodyField.Entity.PascalName}}{}
132132
{{- end }}
133133
{{- if $canUseJson}}
134134
var {{.CamelName}}Json flags.JsonFlag
@@ -390,6 +390,9 @@ func new{{.PascalName}}() *cobra.Command {
390390

391391
{{- define "arg-type" -}}
392392
{{- if .IsString}}StringVar
393+
{{- else if .IsTimestamp}}StringVar{{/* TODO: add support for well known types */}}
394+
{{- else if .IsDuration}}StringVar{{/* TODO: add support for well known types */}}
395+
{{- else if .IsFieldMask}}StringVar{{/* TODO: add support for well known types */}}
393396
{{- else if .IsBool}}BoolVar
394397
{{- else if .IsInt64}}Int64Var
395398
{{- else if .IsFloat64}}Float64Var
@@ -409,7 +412,7 @@ func new{{.PascalName}}() *cobra.Command {
409412
{{- if $optionalIfJsonIsUsed }}
410413
if !cmd.Flags().Changed("json") {
411414
{{- end }}
412-
{{if not $field.Entity.IsString -}}
415+
{{if and (not $field.Entity.IsString) (not $field.Entity.IsFieldMask) (not $field.Entity.IsTimestamp) (not $field.Entity.IsDuration) -}} {{/* TODO: add support for well known types */}}
413416
_, err = fmt.Sscan(args[{{$arg}}], &{{- template "request-body-obj" (dict "Method" $method "Field" $field)}})
414417
if err != nil {
415418
return fmt.Errorf("invalid {{$field.ConstantName}}: %s", args[{{$arg}}])

0 commit comments

Comments
 (0)