diff --git a/pkg/registry/apps/application/rest.go b/pkg/registry/apps/application/rest.go index 361f31be..ee189e26 100644 --- a/pkg/registry/apps/application/rest.go +++ b/pkg/registry/apps/application/rest.go @@ -75,13 +75,6 @@ const ( ApplicationNameLabel = appsv1alpha1.ApplicationNameLabel ) -// Define the GroupVersionResource for HelmRelease -var helmReleaseGVR = schema.GroupVersionResource{ - Group: "helm.toolkit.fluxcd.io", - Version: "v2", - Resource: "helmreleases", -} - // REST implements the RESTStorage interface for Application resources type REST struct { c client.Client @@ -445,9 +438,8 @@ func (r *REST) Update(ctx context.Context, name string, objInfo rest.UpdatedObje // Assert the new object is of type Application app, ok := newObj.(*appsv1alpha1.Application) if !ok { - errMsg := fmt.Sprintf("expected *appsv1alpha1.Application object, got %T", newObj) - klog.Errorf(errMsg) - return nil, false, fmt.Errorf(errMsg) + klog.Errorf("expected *appsv1alpha1.Application object, got %T", newObj) + return nil, false, fmt.Errorf("expected *appsv1alpha1.Application object, got %T", newObj) } // Convert Application to HelmRelease @@ -760,7 +752,7 @@ func (r *REST) getNamespace(ctx context.Context) (string, error) { namespace, ok := request.NamespaceFrom(ctx) if !ok { err := fmt.Errorf("namespace not found in context") - klog.Errorf(err.Error()) + klog.Error(err) return "", err } return namespace, nil @@ -916,8 +908,8 @@ func (r *REST) convertApplicationToHelmRelease(app *appsv1alpha1.Application) (* Namespace: app.Namespace, Labels: addPrefixedMap(app.Labels, LabelPrefix), Annotations: addPrefixedMap(app.Annotations, AnnotationPrefix), - ResourceVersion: app.ObjectMeta.ResourceVersion, - UID: app.ObjectMeta.UID, + ResourceVersion: app.ResourceVersion, + UID: app.UID, }, Spec: helmv2.HelmReleaseSpec{ Chart: &helmv2.HelmChartTemplate{ @@ -959,10 +951,10 @@ func (r *REST) ConvertToTable(ctx context.Context, object runtime.Object, tableO switch obj := object.(type) { case *appsv1alpha1.ApplicationList: table = r.buildTableFromApplications(obj.Items) - table.ListMeta.ResourceVersion = obj.ListMeta.ResourceVersion + table.ResourceVersion = obj.ResourceVersion case *appsv1alpha1.Application: table = r.buildTableFromApplication(*obj) - table.ListMeta.ResourceVersion = obj.GetResourceVersion() + table.ResourceVersion = obj.GetResourceVersion() default: resource := schema.GroupResource{} if info, ok := request.RequestInfoFrom(ctx); ok { diff --git a/pkg/registry/apps/application/rest_defaulting.go b/pkg/registry/apps/application/rest_defaulting.go index 6630a08b..36518af6 100644 --- a/pkg/registry/apps/application/rest_defaulting.go +++ b/pkg/registry/apps/application/rest_defaulting.go @@ -72,7 +72,7 @@ func applyDefaults(v any, s *structuralschema.Structural, top bool) (any, error) return v, nil } - effType := s.Generic.Type + effType := s.Type if effType == "" { switch { case len(s.Properties) > 0 || (s.AdditionalProperties != nil && s.AdditionalProperties.Structural != nil): @@ -88,8 +88,8 @@ func applyDefaults(v any, s *structuralschema.Structural, top bool) (any, error) case "object": mv, isMap := v.(map[string]any) if !isMap || v == nil { - if s.Generic.Default.Object != nil && !top { - if dm, ok := s.Generic.Default.Object.(map[string]any); ok { + if s.Default.Object != nil && !top { + if dm, ok := s.Default.Object.(map[string]any); ok { mv = cloneMap(dm) } } @@ -100,8 +100,8 @@ func applyDefaults(v any, s *structuralschema.Structural, top bool) (any, error) for name, ps := range s.Properties { if _, ok := mv[name]; !ok { - if ps.Generic.Default.Object != nil { - mv[name] = clone(ps.Generic.Default.Object) + if ps.Default.Object != nil { + mv[name] = clone(ps.Default.Object) } } if cur, ok := mv[name]; ok { @@ -131,8 +131,8 @@ func applyDefaults(v any, s *structuralschema.Structural, top bool) (any, error) case "array": sl, isSlice := v.([]any) if !isSlice || v == nil { - if s.Generic.Default.Object != nil { - if ds, ok := s.Generic.Default.Object.([]any); ok { + if s.Default.Object != nil { + if ds, ok := s.Default.Object.([]any); ok { sl = cloneSlice(ds) } } @@ -152,8 +152,8 @@ func applyDefaults(v any, s *structuralschema.Structural, top bool) (any, error) return sl, nil default: - if v == nil && s.Generic.Default.Object != nil { - return clone(s.Generic.Default.Object), nil + if v == nil && s.Default.Object != nil { + return clone(s.Default.Object), nil } return v, nil } diff --git a/pkg/registry/core/tenantmodule/rest.go b/pkg/registry/core/tenantmodule/rest.go index 7e2f7249..12da0e0d 100644 --- a/pkg/registry/core/tenantmodule/rest.go +++ b/pkg/registry/core/tenantmodule/rest.go @@ -61,13 +61,6 @@ const ( singularName = "tenantmodule" ) -// Define the GroupVersionResource for HelmRelease -var helmReleaseGVR = schema.GroupVersionResource{ - Group: "helm.toolkit.fluxcd.io", - Version: "v2", - Resource: "helmreleases", -} - // REST implements the RESTStorage interface for TenantModule resources type REST struct { c client.Client @@ -517,7 +510,7 @@ func (r *REST) getNamespace(ctx context.Context) (string, error) { namespace, ok := request.NamespaceFrom(ctx) if !ok { err := fmt.Errorf("namespace not found in context") - klog.Errorf(err.Error()) + klog.Error(err) return "", err } return namespace, nil @@ -596,10 +589,10 @@ func (r *REST) ConvertToTable(ctx context.Context, object runtime.Object, tableO switch obj := object.(type) { case *corev1alpha1.TenantModuleList: table = r.buildTableFromTenantModules(obj.Items) - table.ListMeta.ResourceVersion = obj.ListMeta.ResourceVersion + table.ResourceVersion = obj.ResourceVersion case *corev1alpha1.TenantModule: table = r.buildTableFromTenantModule(*obj) - table.ListMeta.ResourceVersion = obj.GetResourceVersion() + table.ResourceVersion = obj.GetResourceVersion() default: resource := schema.GroupResource{} if info, ok := request.RequestInfoFrom(ctx); ok {