Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: delete server side fields in kubernetes runtime #761

Merged
merged 2 commits into from
Jan 25, 2024
Merged
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
21 changes: 13 additions & 8 deletions pkg/engine/runtime/kubernetes/kubernetes_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ func (k *KubernetesRuntime) Apply(ctx context.Context, request *runtime.ApplyReq
res = planObj
}

// Ignore the redundant fields automatically added by the K8s server for a
// more concise and clean resource object.
normalizeServerSideFields(res)

return &runtime.ApplyResponse{Resource: &apiv1.Resource{
ID: planState.ResourceKey(),
Type: planState.Type,
Expand Down Expand Up @@ -194,6 +198,10 @@ func (k *KubernetesRuntime) Read(ctx context.Context, request *runtime.ReadReque
return &runtime.ReadResponse{Status: v1.NewErrorStatus(err)}
}

// Ignore the redundant fields automatically added by the K8s server for a
// more concise and clean resource object.
normalizeServerSideFields(v)

return &runtime.ReadResponse{Resource: &apiv1.Resource{
ID: requestResource.ResourceKey(),
Type: requestResource.Type,
Expand Down Expand Up @@ -225,17 +233,14 @@ func (k *KubernetesRuntime) Import(ctx context.Context, request *runtime.ImportR
if err != nil {
return &runtime.ImportResponse{Status: v1.NewErrorStatusWithCode(v1.IllegalManifest, err)}
}
} else {
} else if convertor.Service == ur.GetKind() {
// normalize resources
if convertor.Service == ur.GetKind() {
if err := normalizeService(ur); err != nil {
return &runtime.ImportResponse{
Resource: nil,
Status: v1.NewErrorStatusWithCode(v1.IllegalManifest, err),
}
if err := normalizeService(ur); err != nil {
return &runtime.ImportResponse{
Resource: nil,
Status: v1.NewErrorStatusWithCode(v1.IllegalManifest, err),
}
}
normalizeServerSideFields(ur)
SparkYuan marked this conversation as resolved.
Show resolved Hide resolved
}
response.Resource.Attributes = ur.Object
return &runtime.ImportResponse{
Expand Down
Loading