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

chore: remove dead code #25

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ require (
github.com/vmware/govmomi v0.37.3
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.30.2
k8s.io/apimachinery v0.30.2
k8s.io/client-go v0.30.2
Expand Down Expand Up @@ -97,6 +96,7 @@ require (
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.30.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect
Expand Down
8 changes: 0 additions & 8 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,3 @@ func (c *Config) Load() error {
}
return c.Decrypt()
}

func (c *Config) Kubeconfig() string {
return filepath.Join(c.RunLoc, "kubeconfig")
}

func (c *Config) ManifestDir() string {
return filepath.Join(c.RunLoc, "manifests")
}
9 changes: 0 additions & 9 deletions pkg/logging/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,6 @@ func SetLevel(logLevel string) {
log.SetLevel(level)
}

func GetLevel() logrus.Level {
return log.Level
}

func SetOutput(runLoc string) {
logFile = filepath.Join(runLoc, "logs", "validator.log")
statusFile = filepath.Join(runLoc, "status", "status")
Expand Down Expand Up @@ -152,8 +148,3 @@ func HeaderCustom(s string, bgColor, textColor pterm.Color) {
Println(s)
fmt.Fprintf(os.Stdout, "\n")
}

// Out returns the io.Writer used to write messages to the console
func Out() *os.File {
return os.Stdout
}
42 changes: 0 additions & 42 deletions pkg/services/k8s_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@ package services

import (
"context"
"fmt"
"os"
"path"
"regexp"

"golang.org/x/exp/slices"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"

prompt_utils "github.com/spectrocloud-labs/prompts-tui/prompts"

cfg "github.com/validator-labs/validatorctl/pkg/config"
log "github.com/validator-labs/validatorctl/pkg/logging"
kube_utils "github.com/validator-labs/validatorctl/pkg/utils/kube"
)
Expand Down Expand Up @@ -155,42 +152,3 @@ func readNamespace(k8sClient kubernetes.Interface, prompt, defaultVal string) (s
}
return namespace, nil
}

func readAccessMode(prompt, defaultVal string, optional bool) (string, error) {
accessMode, err := prompt_utils.ReadText(prompt, defaultVal, optional, 13)
if err != nil {
return "", err
}
if !slices.Contains([]string{"", "ReadOnlyMany", "ReadWriteMany", "ReadWriteOnce"}, accessMode) {
log.InfoCLI("Access mode %s is invalid. Please try again.", accessMode)
return readAccessMode(prompt, defaultVal, optional)
}
return accessMode, nil
}

func readStorageClass(ctx context.Context, k8sClient kubernetes.Interface, prompt string) (string, error) {
var choices []prompt_utils.ChoiceItem

storageClassList, err := k8sClient.StorageV1().StorageClasses().List(ctx, metav1.ListOptions{})
if err != nil {
return "", err
}

for _, sc := range storageClassList.Items {
var storageClassInfo string

if sc.Annotations[cfg.DefaultStorageClassAnnotation] == "true" {
storageClassInfo = " (default)"
}
choices = append(choices, prompt_utils.ChoiceItem{
ID: sc.Name,
Name: fmt.Sprintf("%s%s", sc.Name, storageClassInfo),
})
}

storageClass, err := prompt_utils.SelectID(prompt, choices)
if err != nil {
return readStorageClass(ctx, k8sClient, prompt)
}
return storageClass.ID, nil
}