Skip to content

Commit

Permalink
Publish IsInstalled method
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Mar 6, 2020
1 parent 79727d3 commit bb83d8f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

build: vfs
build: vfs test
go build -o snap ./cmd/

vfs:
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/snap.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ func (s *Snap) Install(ctx context.Context) error {
return nil
}

func (s *Snap) IsInstalled(ctx context.Context) (bool, error) {
return s.installerModule.IsInstalled(ctx, s.namespace)
}

func (s *Snap) GetEndpoint(ctx context.Context) (string, error) {
host, err := s.installerModule.GetDirectConnectionHost(ctx, s.namespace)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/installer/installer.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewInstaller(config *restclient.Config, client ctrl.Client, stdOut, stdErr
}
}

func (i *Installer) isInstalled(ctx context.Context, ns string) (bool, error) {
func (i *Installer) IsInstalled(ctx context.Context, ns string) (bool, error) {
deploymentList := appsv1.DeploymentList{}
if err := i.client.List(ctx, &deploymentList, ctrl.InNamespace(ns), ctrl.MatchingLabels(serverLabels)); err != nil {
return false, err
Expand Down Expand Up @@ -95,7 +95,7 @@ func (i *Installer) GetDirectConnectionHost(ctx context.Context, ns string) (str
}

func (i *Installer) EnsureInstalled(ctx context.Context, ns string) error {
if installed, err := i.isInstalled(ctx, ns); err != nil {
if installed, err := i.IsInstalled(ctx, ns); err != nil {
return err
} else if installed {
logger.Info("Snap is already installed: skipping")
Expand Down

0 comments on commit bb83d8f

Please # to comment.