github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/nodeagent/dep/k8s/kubectl/dep.go (about)

     1  package kubectl
     2  
     3  import (
     4  	"github.com/caos/orbos/internal/operator/common"
     5  	"github.com/caos/orbos/internal/operator/nodeagent"
     6  	"github.com/caos/orbos/internal/operator/nodeagent/dep"
     7  	"github.com/caos/orbos/internal/operator/nodeagent/dep/k8s"
     8  	"github.com/caos/orbos/internal/operator/nodeagent/dep/middleware"
     9  )
    10  
    11  type Installer interface {
    12  	isKubectl()
    13  	nodeagent.Installer
    14  }
    15  
    16  type kubectlDep struct {
    17  	common *k8s.Common
    18  }
    19  
    20  func New(os dep.OperatingSystem, manager *dep.PackageManager) Installer {
    21  	return &kubectlDep{k8s.New(os, manager, "kubectl")}
    22  }
    23  
    24  func (kubectlDep) isKubectl() {}
    25  
    26  func (kubectlDep) Is(other nodeagent.Installer) bool {
    27  	_, ok := middleware.Unwrap(other).(Installer)
    28  	return ok
    29  }
    30  
    31  func (k kubectlDep) String() string { return "Kubectl" }
    32  
    33  func (*kubectlDep) Equals(other nodeagent.Installer) bool {
    34  	_, ok := other.(*kubectlDep)
    35  	return ok
    36  }
    37  
    38  func (k *kubectlDep) InstalledFilter() []string {
    39  	return []string{"kubectl"}
    40  }
    41  
    42  func (k *kubectlDep) Current() (common.Package, error) {
    43  	return k.common.Current()
    44  }
    45  
    46  func (k *kubectlDep) Ensure(remove common.Package, install common.Package, leaveOSRepositories bool) error {
    47  	return k.common.Ensure(remove, install, leaveOSRepositories)
    48  }