Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: function CreateNsWithLabelsIfNotExists removed #138

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions common-lib/utils/k8s/K8sUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ type K8sService interface {
GetConfigMapWithCtx(ctx context.Context, namespace string, name string, client *v12.CoreV1Client) (*v1.ConfigMap, error)
GetNsIfExists(namespace string, client *v12.CoreV1Client) (ns *v1.Namespace, exists bool, err error)
CreateNsIfNotExists(namespace string, clusterConfig *ClusterConfig) (ns *v1.Namespace, nsCreated bool, err error)
CreateNsWithLabelsIfNotExists(namespace string, labels map[string]string, clusterConfig *ClusterConfig) (ns *v1.Namespace, nsCreated bool, err error)
UpdateNSLabels(namespace *v1.Namespace, labels map[string]string, clusterConfig *ClusterConfig) (ns *v1.Namespace, err error)
GetK8sDiscoveryClientInCluster() (*discovery.DiscoveryClient, error)
GetK8sDiscoveryClient(clusterConfig *ClusterConfig) (*discovery.DiscoveryClient, error)
Expand Down Expand Up @@ -319,32 +318,6 @@ func (impl *K8sServiceImpl) CreateNsIfNotExists(namespace string, clusterConfig
return ns, nsCreated, err
}

func (impl *K8sServiceImpl) CreateNsWithLabelsIfNotExists(namespace string, labels map[string]string, clusterConfig *ClusterConfig) (ns *v1.Namespace, nsCreated bool, err error) {
v12Client, err := impl.GetCoreV1Client(clusterConfig)
if err != nil {
impl.logger.Errorw("error", "error", err, "clusterConfig", clusterConfig)
return nil, false, err
}
ns, exists, err := impl.GetNsIfExists(namespace, v12Client)
if err != nil {
impl.logger.Errorw("error", "error", err)
return ns, false, err
}
if exists {
nsCreated = false
impl.logger.Infow("namespace already exist", "namespace", namespace)
return ns, nsCreated, nil
}
impl.logger.Infow("ns not exists creating", "ns", namespace)
ns, err = impl.CreateNsWithLabels(namespace, labels, v12Client)
if err != nil {
impl.logger.Errorw("error in creating ns", "namespace", namespace, "err", err)
return nil, false, err
}
nsCreated = true
return ns, nsCreated, err
}

func (impl *K8sServiceImpl) UpdateNSLabels(namespace *v1.Namespace, labels map[string]string, clusterConfig *ClusterConfig) (ns *v1.Namespace, err error) {
v12Client, err := impl.GetCoreV1Client(clusterConfig)
if err != nil {
Expand Down
Loading