fix: ensure Kind and APIVersion are set in returned YAML
This commit is contained in:
@@ -517,6 +517,13 @@ func K8sResourceFetch(ctx context.Context, db *gorm.DB, store store.Store) fiber
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return resp.R500(c, "", nil, fmt.Errorf("failed to get deployment: %w", err))
|
return resp.R500(c, "", nil, fmt.Errorf("failed to get deployment: %w", err))
|
||||||
}
|
}
|
||||||
|
// Ensure Kind and APIVersion are set
|
||||||
|
if deployment.Kind == "" {
|
||||||
|
deployment.Kind = "Deployment"
|
||||||
|
}
|
||||||
|
if deployment.APIVersion == "" {
|
||||||
|
deployment.APIVersion = "apps/v1"
|
||||||
|
}
|
||||||
// Clean up managed fields and other metadata that cause conflicts
|
// Clean up managed fields and other metadata that cause conflicts
|
||||||
deployment.ManagedFields = nil
|
deployment.ManagedFields = nil
|
||||||
deployment.ResourceVersion = ""
|
deployment.ResourceVersion = ""
|
||||||
@@ -535,6 +542,13 @@ func K8sResourceFetch(ctx context.Context, db *gorm.DB, store store.Store) fiber
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return resp.R500(c, "", nil, fmt.Errorf("failed to get statefulset: %w", err))
|
return resp.R500(c, "", nil, fmt.Errorf("failed to get statefulset: %w", err))
|
||||||
}
|
}
|
||||||
|
// Ensure Kind and APIVersion are set
|
||||||
|
if statefulset.Kind == "" {
|
||||||
|
statefulset.Kind = "StatefulSet"
|
||||||
|
}
|
||||||
|
if statefulset.APIVersion == "" {
|
||||||
|
statefulset.APIVersion = "apps/v1"
|
||||||
|
}
|
||||||
// Clean up managed fields and other metadata that cause conflicts
|
// Clean up managed fields and other metadata that cause conflicts
|
||||||
statefulset.ManagedFields = nil
|
statefulset.ManagedFields = nil
|
||||||
statefulset.ResourceVersion = ""
|
statefulset.ResourceVersion = ""
|
||||||
@@ -553,6 +567,13 @@ func K8sResourceFetch(ctx context.Context, db *gorm.DB, store store.Store) fiber
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return resp.R500(c, "", nil, fmt.Errorf("failed to get service: %w", err))
|
return resp.R500(c, "", nil, fmt.Errorf("failed to get service: %w", err))
|
||||||
}
|
}
|
||||||
|
// Ensure Kind and APIVersion are set
|
||||||
|
if service.Kind == "" {
|
||||||
|
service.Kind = "Service"
|
||||||
|
}
|
||||||
|
if service.APIVersion == "" {
|
||||||
|
service.APIVersion = "v1"
|
||||||
|
}
|
||||||
// Clean up managed fields and other metadata that cause conflicts
|
// Clean up managed fields and other metadata that cause conflicts
|
||||||
service.ManagedFields = nil
|
service.ManagedFields = nil
|
||||||
service.ResourceVersion = ""
|
service.ResourceVersion = ""
|
||||||
@@ -571,6 +592,13 @@ func K8sResourceFetch(ctx context.Context, db *gorm.DB, store store.Store) fiber
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return resp.R500(c, "", nil, fmt.Errorf("failed to get configmap: %w", err))
|
return resp.R500(c, "", nil, fmt.Errorf("failed to get configmap: %w", err))
|
||||||
}
|
}
|
||||||
|
// Ensure Kind and APIVersion are set
|
||||||
|
if configmap.Kind == "" {
|
||||||
|
configmap.Kind = "ConfigMap"
|
||||||
|
}
|
||||||
|
if configmap.APIVersion == "" {
|
||||||
|
configmap.APIVersion = "v1"
|
||||||
|
}
|
||||||
// Clean up managed fields and other metadata that cause conflicts
|
// Clean up managed fields and other metadata that cause conflicts
|
||||||
configmap.ManagedFields = nil
|
configmap.ManagedFields = nil
|
||||||
configmap.ResourceVersion = ""
|
configmap.ResourceVersion = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user