kubernetes-client/python

Can't append data

Open

#2,110 创建于 2023年8月27日

在 GitHub 查看
 (8 评论) (0 反应) (0 负责人)Python (3,323 fork)batch import
help wantedkind/bug

仓库指标

Star
 (6,225 star)
PR 合并指标
 (平均合并 10天 3小时) (30 天内合并 2 个 PR)

描述

What happened (please include outputs or screenshots):

I have created a config map via create_namespaced_config_map. I am attempting to patch it by appending existing data. Tried like this

cm = client.V1ConfigMap() cm.metadata = client.V1ObjectMeta(name=name) cm.data = cm_data existingCM = v1.read_namespaced_config_map("test-cm", "test-ns") print(existingCM)

# print(existingCM)

 
if existingCM == False:
    print(self.v1.read_namespaced_config_map(test-cm", "test-ns"))
    self.v1.create_namespaced_config_map(namespace=namespace, body=cm)
    print(f"Created ConfigMap {name} in namespace {namespace}") 

else:
    # print(existingCM)
    print(existingCM.update(cm.data))
    v1.patch_namespaced_config_map(name=name, namespace=namespace, body=cm)
    print(f"Updated ConfigMap {name} in namespace {namespace}") 

This wouldn't work. Is there an example that I can follow?

Describe the solution you'd like to see: Example to achieve successful data append

贡献者指南