@@ -24,6 +24,7 @@ import (
2424 "github.com/devtron-labs/common-lib/utils"
2525 http2 "github.com/devtron-labs/common-lib/utils/http"
2626 "github.com/devtron-labs/common-lib/utils/k8s/commonBean"
27+ "github.com/devtron-labs/common-lib/utils/k8s/configMap"
2728 "io"
2829 "k8s.io/client-go/dynamic"
2930 "k8s.io/client-go/kubernetes/scheme"
@@ -237,6 +238,27 @@ func (impl *K8sServiceImpl) CreateConfigMap(namespace string, cm *v1.ConfigMap,
237238 }
238239}
239240
241+ func (impl * K8sServiceImpl ) CreateConfigMapObject (name , namespace string , client * v12.CoreV1Client , opts ... configMap.ConfigMapOption ) (* v1.ConfigMap , error ) {
242+ configMap := & v1.ConfigMap {
243+ ObjectMeta : metav1.ObjectMeta {
244+ Name : name ,
245+ },
246+ }
247+ for _ , option := range opts {
248+ option (configMap )
249+ }
250+ return impl .CreateConfigMap (namespace , configMap , client )
251+ }
252+
253+ func (impl * K8sServiceImpl ) DeleteConfigMap (namespace string , name string , client * v12.CoreV1Client ) error {
254+ err := client .ConfigMaps (namespace ).Delete (context .Background (), name , metav1.DeleteOptions {})
255+ if err != nil {
256+ impl .logger .Errorw ("error in deleting cm" , "namespace" , namespace , "err" , err )
257+ return err
258+ }
259+ return nil
260+ }
261+
240262func (impl * K8sServiceImpl ) UpdateConfigMap (namespace string , cm * v1.ConfigMap , client * v12.CoreV1Client ) (* v1.ConfigMap , error ) {
241263 cm , err := client .ConfigMaps (namespace ).Update (context .Background (), cm , metav1.UpdateOptions {})
242264 if err != nil {
0 commit comments