Skip to content

Commit

Permalink
fix: err when deploying with BubbleTea with no cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleGedd committed Mar 26, 2024
1 parent cc4f2c3 commit c2c8ab1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
20 changes: 6 additions & 14 deletions src/pkg/bundle/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
"github.com/defenseunicorns/uds-cli/src/config"
"github.com/defenseunicorns/uds-cli/src/pkg/bundler/fetcher"
"github.com/defenseunicorns/uds-cli/src/types"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/message"
"github.com/defenseunicorns/zarf/src/pkg/oci"
Expand Down Expand Up @@ -264,22 +263,15 @@ func ValidateBundleSignature(bundleYAMLPath, signaturePath, publicKeyPath string
return zarfUtils.CosignVerifyBlob(bundleYAMLPath, signaturePath, publicKeyPath)
}

// GetDeployedPackages returns packages that have been deployed
func GetDeployedPackages() ([]zarfTypes.DeployedPackage, error) {
cluster := cluster.NewClusterOrDie()
deployedPackages, errs := cluster.GetDeployedZarfPackages()
if len(errs) > 0 {
return nil, lang.ErrUnableToGetPackages
}
return deployedPackages, nil
}

// GetDeployedPackageNames returns the names of the packages that have been deployed
func GetDeployedPackageNames() []string {
var deployedPackageNames []string
deployedPackages, _ := GetDeployedPackages()
for _, pkg := range deployedPackages {
deployedPackageNames = append(deployedPackageNames, pkg.Name)
c, _ := cluster.NewCluster()
if c != nil {
deployedPackages, _ := c.GetDeployedZarfPackages()
for _, pkg := range deployedPackages {
deployedPackageNames = append(deployedPackageNames, pkg.Name)
}
}
return deployedPackageNames
}
Expand Down
14 changes: 11 additions & 3 deletions src/pkg/bundle/tui/deploy/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ import (
)

func (m *model) handleNewPackage(pkgName string, currentPkgIdx int) tea.Cmd {
// see if pkg has already been deployed
deployedPkg, _ := c.GetDeployedPackage(pkgName)
// check if pkg has already been deployed
var deployedPkg *zarfTypes.DeployedPackage
if c != nil {
deployedPkg, _ = c.GetDeployedPackage(pkgName)
}
newPkg := pkgState{
name: pkgName,
}
Expand Down Expand Up @@ -141,7 +144,12 @@ func (m *model) handleDeployTick() (tea.Model, tea.Cmd) {
if p.complete {
continue
}
deployedPkg, _ := c.GetDeployedPackage(p.name)

var deployedPkg *zarfTypes.DeployedPackage
if c != nil {
deployedPkg, _ = c.GetDeployedPackage(p.name)
}

// if deployedPkg is nil, the package hasn't been deployed yet
if deployedPkg == nil {
break
Expand Down

0 comments on commit c2c8ab1

Please sign in to comment.