From c36daca19d93a634794cea1892696c3b1ca890da Mon Sep 17 00:00:00 2001 From: tczekajlo Date: Tue, 12 Oct 2021 16:38:39 +0200 Subject: [PATCH] Remove useless functions --- pkg/helm/install.go | 5 ----- pkg/rasactl/delete.go | 11 ----------- pkg/utils/utils.go | 35 ----------------------------------- 3 files changed, 51 deletions(-) diff --git a/pkg/helm/install.go b/pkg/helm/install.go index c029c08e..c6284c1c 100644 --- a/pkg/helm/install.go +++ b/pkg/helm/install.go @@ -105,11 +105,6 @@ func (h *Helm) Install() error { ) h.Log.V(1).Info("Merging values", "result", h.Values) - // Add host to /etc/hosts - required sudo - //if err := utils.AddHostToEtcHosts(host, ip); err != nil { - // return err - //} - //h.Log.V(1).Info("Adding host", "host", host, "ip", ip) } else if h.KubernetesBackendType == types.KubernetesBackendLocal && h.CloudProvider.Name != types.CloudProviderUnknown { h.Values = utils.MergeMaps(valuesNginxNodePort(), h.Values) diff --git a/pkg/rasactl/delete.go b/pkg/rasactl/delete.go index 57bb7b05..8f227b51 100644 --- a/pkg/rasactl/delete.go +++ b/pkg/rasactl/delete.go @@ -76,17 +76,6 @@ func (r *RasaCtl) Delete() error { } } - /*if r.KubernetesClient.GetBackendType() == types.KubernetesBackendLocal && r.CloudProvider.Name == types.CloudProviderUnknown { - host := fmt.Sprintf("%s.%s", r.Namespace, types.RasaCtlLocalDomain) - - r.Log.V(1).Info("Deleting a hostname from /etc/hosts", "host", host) - - err := utils.DeleteHostToEtcHosts(host) - if err != nil && !force { - return err - } - }*/ - if prune { r.Log.Info("Deleting namespace", "namespace", r.Namespace) if err := r.KubernetesClient.DeleteNamespace(); err != nil && !force { diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go index 8beb73e0..94d78e08 100644 --- a/pkg/utils/utils.go +++ b/pkg/utils/utils.go @@ -37,7 +37,6 @@ import ( "github.com/imdario/mergo" "github.com/pkg/errors" "github.com/spf13/viper" - "github.com/txn2/txeh" "golang.org/x/term" "github.com/RasaHQ/rasactl/pkg/types" @@ -78,40 +77,6 @@ func MergeMaps(maps ...map[string]interface{}) map[string]interface{} { return result } -// AddHostToEtcHosts adds a host with a given IP address to /etc/hosts, -// for Windows it is C:\Windows\System32\Drivers\etc\hosts. -func AddHostToEtcHosts(host, ip string) error { - hosts, err := txeh.NewHostsDefault() - if err != nil { - return err - } - - hosts.AddHost(ip, host) - - if err := hosts.Save(); err != nil { - return errors.Errorf("Can't add a host, try to run the command as administrator, error: %s", err) - } - - return nil -} - -// DeleteHostToEtcHosts removes a host from /etc/hosts (linux, darwin), or -// C:\Windows\System32\Drivers\etc\hosts (Windows). -func DeleteHostToEtcHosts(host string) error { - hosts, err := txeh.NewHostsDefault() - if err != nil { - return err - } - - hosts.RemoveHost(host) - - if err := hosts.Save(); err != nil { - return errors.Errorf("Can't remove a host, try to run the command as administrator, error: %s", err) - } - - return nil -} - func ValidateName(name string) error { if !validName.MatchString(name) {