Skip to content

Commit

Permalink
[operator] Uninstall logic completed
Browse files Browse the repository at this point in the history
  • Loading branch information
mfordjody committed Dec 24, 2024
1 parent a01bbbc commit 6243f22
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion operator/cmd/cluster/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"strings"
)

var installerScope = log.RegisterScope("installer", "installer")
var installerScope = log.RegisterScope("installer")

type installArgs struct {
files []string
Expand Down
10 changes: 6 additions & 4 deletions operator/pkg/uninstall/uninstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ func DeleteObjectsList(c kube.CLIClient, dryRun bool, log clog.Logger, objectsLi
return errs.ToErrors()
}

func DeleteResource(kc kube.CLIClient, dryRun bool, log clog.Logger, obj *unstructured.Unstructured) error {
func DeleteResource(kc kube.CLIClient, dryRun bool, _ clog.Logger, obj *unstructured.Unstructured) error {
name := fmt.Sprintf("%v/%s.%s", obj.GroupVersionKind(), obj.GetName(), obj.GetNamespace())
if dryRun {
log.LogAndPrintf("Not pruning object %s because of dry run.", name)
fmt.Printf("Not pruning object %s because of dry run.", name)
return nil
}

Expand All @@ -98,10 +98,12 @@ func DeleteResource(kc kube.CLIClient, dryRun bool, log clog.Logger, obj *unstru
if !kerrors.IsNotFound(err) {
return err
}
log.LogAndPrintf("object: %s is not being deleted because it no longer exists", name)
fmt.Printf("object: %s is not being deleted because it no longer exists", name)

return nil
}

log.LogAndPrintf(" ✔︎ Removed %s.", name)
fmt.Printf("✔︎ Removed %s.\n", name)

return nil
}
2 changes: 1 addition & 1 deletion operator/pkg/util/clog/clog.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type Logger interface {
func NewConsoleLogger(stdOut, stdErr io.Writer, scope *log.Scope) *ConsoleLogger {
s := scope
if s == nil {
s = log.RegisterScope(log.DefaultScopeName, log.DefaultScopeName)
s = log.RegisterScope(log.DefaultScopeName)
}
return &ConsoleLogger{
stdOut: stdOut,
Expand Down
2 changes: 1 addition & 1 deletion operator/pkg/util/clog/log/default.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package log

func registerDefaultScopes() (defaults *Scope) {
return registerScope(DefaultScopeName, "Unscoped logging messages.", 1)
return registerScope(DefaultScopeName, 1)
}

var defaultScope = registerDefaultScopes()
6 changes: 3 additions & 3 deletions operator/pkg/util/clog/log/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ var (
lock sync.RWMutex
)

func RegisterScope(name string, desc string) *Scope {
return registerScope(name, desc, 0)
func RegisterScope(name string) *Scope {
return registerScope(name, 0)
}

func registerScope(name string, desc string, callerSkip int) *Scope {
func registerScope(name string, callerSkip int) *Scope {
if strings.ContainsAny(name, ":,.") {
panic(fmt.Sprintf("scope name %s is invalid, it cannot contain colons, commas, or periods", name))
}
Expand Down

0 comments on commit 6243f22

Please sign in to comment.