Skip to content

Commit

Permalink
showbyid fix for generating nofiltering
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-fbudzynski committed Dec 5, 2024
1 parent b02da54 commit 9cd65c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 4 additions & 12 deletions pkg/sdk/poc/generator/show_by_id_filtering.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ func newShowByIDFiltering(name, kind, args string) ShowByIDFiltering {
}
}

func newShowByIDNoFiltering() ShowByIDFiltering {
return newShowByIDFiltering("NoFiltering", "", "")
}

func newShowByIDLikeFiltering() ShowByIDFiltering {
return newShowByIDFiltering("Like", "Like", "Pattern: String(id.Name())")
}
Expand All @@ -70,7 +74,6 @@ func newShowByIDExtendedInFiltering(identifierKind idPrefix) ShowByIDFiltering {
return newShowByIDFiltering("In", "ExtendedIn", fmt.Sprintf("In: In{%[1]v: id.%[1]vId()}", identifierKind))
}

// ApplicationName filtering for application_roles
type showByIDApplicationFilter struct {
showByIDFilter
}
Expand All @@ -89,17 +92,6 @@ func newShowByIDApplicationFiltering() ShowByIDFiltering {
}
}

// noop for NoFiltering
type showByIDNoFilter struct{}

func (s *showByIDNoFilter) WithFiltering() string {
return ""
}

func newShowByIDNoFiltering() ShowByIDFiltering {
return &showByIDNoFilter{}
}

func (s *Operation) withFiltering(filtering ...ShowByIDFilteringKind) *Operation {
for _, filteringKind := range filtering {
switch filteringKind {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
func (v *{{ $impl }}) ShowByID(ctx context.Context, id {{ .ObjectInterface.IdentifierKind }}) (*{{ .ObjectInterface.NameSingular }}, error) {
request := NewShow{{ .ObjectInterface.NameSingular }}Request()
{{- range .ShowByIDFiltering }}
{{- .WithFiltering -}}
{{- if not (eq .Name "NoFiltering") -}}.
{{ .WithFiltering }}
{{- end }}
{{- end }}
{{ $impl }}, err := v.Show(ctx, request)
if err != nil {
Expand Down

0 comments on commit 9cd65c3

Please sign in to comment.