Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions apis/trivy/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions apis/trivy/time.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ func (t Time) MarshalJSON() ([]byte, error) {
return buf, nil
}

// OpenAPISchemaType and OpenAPISchemaFormat mirror metav1.Time so openapi-gen
// emits a scalar date-time string. Without them, defining Time as a new named
// type strips metav1.Time's methods and the generated schema becomes an object,
// breaking the server-side-apply type converter.
func (Time) OpenAPISchemaType() []string { return []string{"string"} }

func (Time) OpenAPISchemaFormat() string { return "date-time" }

func init() {
utilruntime.Must(
apiequality.Semantic.AddFunc(func(a, b Time) bool {
Expand Down
6 changes: 5 additions & 1 deletion pkg/cmds/server/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ func (o *ScannerServerOptions) Config() (*apiserver.Config, error) {
openapi.NewDefinitionNamer(apiserver.Scheme))
serverConfig.OpenAPIV3Config.Info.Title = "scanner"
serverConfig.OpenAPIV3Config.Info.Version = api.SchemeGroupVersion.Version
serverConfig.OpenAPIV3Config.IgnorePrefixes = ignore
// Do NOT reuse `ignore` here: the v3 config feeds the server-side-apply
// managed-fields type converter (getOpenAPIModels), and ignoring the scanner
// group prefix drops its resources from the converter, causing
// "no corresponding type for scanner.appscode.com/v1alpha1" on every write.
serverConfig.OpenAPIV3Config.IgnorePrefixes = []string{"/swaggerapi"}

extraConfig := apiserver.ExtraConfig{
ClientConfig: serverConfig.ClientConfig,
Expand Down
Loading