Skip to content

Commit

Permalink
Try removing schema fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
jveski committed Nov 20, 2023
1 parent a016174 commit 859af5b
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions internal/controllers/reconciliation/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/jsonmergepatch"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -39,7 +38,6 @@ func New(mgr *reconstitution.Manager, upstream *rest.Config) error {
}
disc.UseLegacyDiscovery = true // don't bother with aggregated APIs since they may be unavailable

// TODO: Refresh sometimes?
doc, err := disc.OpenAPISchema()
if err != nil {
return err
Expand Down Expand Up @@ -176,10 +174,7 @@ func (c *Controller) buildPatch(ctx context.Context, prev, resource *reconstitut

model := c.openapi.LookupResource(resource.Object.GroupVersionKind())
if model == nil {
// TODO: Remove?
// Fall back to non-strategic merge
logr.FromContextOrDiscard(ctx).Info("falling back to non-strategic merge patch because resource was not found in openapi spec")
return jsonmergepatch.CreateThreeWayJSONMergePatch(prevManifest, []byte(resource.Manifest), desiredJS)
return nil, fmt.Errorf("resource is not known") // TODO: Refresh cache?
}

patchmeta := strategicpatch.NewPatchMetaFromOpenAPI(model)
Expand Down

0 comments on commit 859af5b

Please sign in to comment.