Skip to content

Read ImageCatalog of Cloudnative pg #1630

Description

@vishaltanawade

I am using cloudnative pg as db operator. where we can create/ read/edit image catalog cluster.
In .net using this package I am able to successfully create image catalog.
but while reading it is in the form of plane string like structure. unable to convert it into key value pair like structure.

var config = KubernetesClientConfiguration.BuildDefaultConfig();
                var client = new Kubernetes(config);

                var imageCatalog = await client.GetNamespacedCustomObjectAsync(
                    appSetupK8SConfig.HelmChartGroup,
                    appSetupK8SConfig.HelmChartVersion,
                    appSetupK8SConfig.Namespace,
                    GlobalConstants.ImageCatalogPlural,
                    appSetupK8SConfig.ImageCatalogName
                    );

and imageCayalog is like this

ValueKind = Object : "{"apiVersion":"postgresql.cnpg.io/v1","kind":"ImageCatalog","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{"apiVersion":"postgresql.cnpg.io/v1","kind":"ImageCatalog","metadata":{"annotations":{},"name":"test-image-s-postgresql","namespace":"ingress-basic"},"spec":{"images":[{"image":"demo.azurecr.io/test-db-devl:17.2","major":17}]}}\n"},"creationTimestamp":"2025-05-16T06:20:44Z","generation":2,"labels":{"k8slens-edit-resource-version":"v1"},"managedFields":[{"apiVersion":"postgresql.cnpg.io/v1","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:annotations":{".":{},"f:kubectl.kubernetes.io/last-applied-configuration":{}}},"f:spec":{}},"manager":"kubectl-client-side-apply","operation":"Update","time":"2025-05-16T06:20:44Z"},{"apiVersion":"postgresql.cnpg.io/v1","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{".":{},"f:k8slens-edit-resource-version":{}}},"f:spec":{"f:images":{}}},"manager":"...

how can i convert this plain string like json into actual json or object so i can easily edit it.

i want to use ReplaceNamespacedCustomObjectAsync to edit catalog image.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions