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 d540c14
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 20 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/nightly-uds-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ jobs:
run: |
chmod +x build/uds
- name: Setup K3d
uses: ./.github/actions/k3d
- name: install-k3d
run: "curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash"
shell: bash

- name: Deploy UDS Core bundle
# renovate: datasource=github-tags depName=defenseunicorns/uds-core versioning=semver
run: build/uds deploy ghcr.io/defenseunicorns/packages/uds/bundles/k3d-core-istio-dev:0.13.1 --confirm --no-progress
run: build/uds deploy k3d-core-istio-dev:0.16.1 --confirm
shell: bash

- name: Validate UDS Core deployment
Expand Down
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
21 changes: 18 additions & 3 deletions src/pkg/bundle/tui/deploy/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ import (
"github.com/defenseunicorns/uds-cli/src/config"
"github.com/defenseunicorns/uds-cli/src/pkg/bundle/tui"
"github.com/defenseunicorns/uds-cli/src/pkg/utils"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/message"
zarfTypes "github.com/defenseunicorns/zarf/src/types"
)

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)
} else {
// keep checking for cluster connectivity
c, _ = cluster.NewCluster()
}
newPkg := pkgState{
name: pkgName,
}
Expand Down Expand Up @@ -141,7 +148,15 @@ 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)
} else {
// keep checking for cluster connectivity
c, _ = cluster.NewCluster()
}

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

0 comments on commit d540c14

Please sign in to comment.