Skip to content

Commit

Permalink
Merge branch 'main' into update-go-version
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Rodriguez authored Jun 7, 2024
2 parents 704dc26 + 7ad3e53 commit ece6c72
Show file tree
Hide file tree
Showing 90 changed files with 175 additions and 125 deletions.
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ require (
github.com/anchore/clio v0.0.0-20240408173007-3c4abf89e72f
github.com/anchore/stereoscope v0.0.1
github.com/anchore/syft v0.100.0
github.com/defenseunicorns/pkg/helpers v1.1.1
github.com/defenseunicorns/pkg/oci v0.0.1
github.com/defenseunicorns/pkg/helpers/v2 v2.0.1
github.com/defenseunicorns/pkg/oci v1.0.1
github.com/derailed/k9s v0.31.7
github.com/distribution/reference v0.5.0
github.com/fairwindsops/pluto/v5 v5.18.4
Expand Down Expand Up @@ -61,8 +61,6 @@ require (
sigs.k8s.io/yaml v1.4.0
)

require cuelang.org/go v0.7.0 // indirect

require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
Expand All @@ -76,6 +74,7 @@ require (
cloud.google.com/go/longrunning v0.5.7 // indirect
cloud.google.com/go/storage v1.41.0 // indirect
cuelabs.dev/go/oci/ociregistry v0.0.0-20231103182354-93e78c079a13 // indirect
cuelang.org/go v0.7.0 // indirect
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,10 @@ github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX
github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c=
github.com/defenseunicorns/gojsonschema v0.0.0-20231116163348-e00f069122d6 h1:gwevOZ0fxT2nzM9hrtdPbsiOHjFqDRIYMzJHba3/G6Q=
github.com/defenseunicorns/gojsonschema v0.0.0-20231116163348-e00f069122d6/go.mod h1:StKLYMmPj1R5yIs6CK49EkcW1TvUYuw5Vri+LRk7Dy8=
github.com/defenseunicorns/pkg/helpers v1.1.1 h1:p3pKeK5SeFaoZUJZIX9sEsJqX1CGGMS8OpQMPgJtSqM=
github.com/defenseunicorns/pkg/helpers v1.1.1/go.mod h1:F4S5VZLDrlNWQKklzv4v9tFWjjZNhxJ1gT79j4XiLwk=
github.com/defenseunicorns/pkg/oci v0.0.1 h1:EFRp3NeiwzhOWKpQ6mAxi0l9chnrAvDcIgjMr0o0fkM=
github.com/defenseunicorns/pkg/oci v0.0.1/go.mod h1:zVBgRjckEAhfdvbnQrnfOP/3M/GYJkIgWtJtY7pjYdo=
github.com/defenseunicorns/pkg/helpers/v2 v2.0.1 h1:j08rz9vhyD9Bs+yKiyQMY2tSSejXRMxTqEObZ5M1Wbk=
github.com/defenseunicorns/pkg/helpers/v2 v2.0.1/go.mod h1:u1PAqOICZyiGIVA2v28g55bQH1GiAt0Bc4U9/rnWQvQ=
github.com/defenseunicorns/pkg/oci v1.0.1 h1:WPrWRrae1L19X1vuhy6yYMR2zrTzgBbJHp3ImgUm4ZM=
github.com/defenseunicorns/pkg/oci v1.0.1/go.mod h1:qZ3up/d0P81taW37fKR4lb19jJhQZJVtNOEJMu00dHQ=
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da h1:ZOjWpVsFZ06eIhnh4mkaceTiVoktdU67+M7KDHJ268M=
github.com/deitch/magic v0.0.0-20230404182410-1ff89d7342da/go.mod h1:B3tI9iGHi4imdLi4Asdha1Sc6feLMTfPLXh9IUYmysk=
github.com/depcheck-test/depcheck-test v0.0.0-20220607135614-199033aaa936 h1:foGzavPWwtoyBvjWyKJYDYsyzy+23iBV7NKTwdk+LRY=
Expand Down
17 changes: 16 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"context"
"embed"
"os"
"os/signal"
"syscall"

Expand All @@ -22,8 +23,22 @@ var cosignPublicKey string
var zarfSchema embed.FS

func main() {
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
signalCh := make(chan os.Signal, 1)
signal.Notify(signalCh, syscall.SIGINT, syscall.SIGTERM)
go func() {
first := true
for {
<-signalCh
if first {
first = false
cancel()
continue
}
os.Exit(1)
}
}()

config.CosignPublicKey = cosignPublicKey
lint.ZarfSchema = zarfSchema
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"os"
"regexp"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/cmd/common"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/config/lang"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/cmd/common"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/config/lang"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"

"github.com/AlecAivazis/survey/v2"
"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/pkg/oci"
"github.com/defenseunicorns/zarf/src/cmd/common"
"github.com/defenseunicorns/zarf/src/config"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"path/filepath"
"strings"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/cmd/common"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/internal/agent"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"oras.land/oras-go/v2/registry"

"github.com/AlecAivazis/survey/v2"
"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/packager"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/helm/repo_add.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"strings"
"time"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/message"
"github.com/gofrs/flock"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/helm/repo_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"os"
"path/filepath"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/pkg/message"
"github.com/pkg/errors"
"github.com/spf13/cobra"
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/helm/repo_remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"os"
"path/filepath"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/pkg/errors"
"github.com/spf13/cobra"

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/tools/zarf.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/sigstore/cosign/v2/pkg/cosign"
"github.com/spf13/cobra"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/pkg/oci"

"github.com/defenseunicorns/zarf/src/cmd/common"
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/bigbang/bigbang.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"time"

"github.com/Masterminds/semver/v3"
"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/internal/packager/helm"
"github.com/defenseunicorns/zarf/src/pkg/layout"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/bigbang/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path"
"path/filepath"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/internal/packager/kustomize"
"github.com/defenseunicorns/zarf/src/pkg/utils"
"github.com/defenseunicorns/zarf/src/types"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/agent/hooks/argocd-application.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"encoding/json"
"fmt"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/internal/agent/operations"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/agent/hooks/argocd-repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"encoding/json"
"fmt"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/internal/agent/operations"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/agent/hooks/flux.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"encoding/json"
"fmt"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/internal/agent/operations"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/yaml"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"

"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/helm/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package helm

import (
"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/pkg/message"
"github.com/goccy/go-yaml"
"helm.sh/helm/v3/pkg/chart/loader"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/helm/post-render.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"reflect"
"slices"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/helm/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"path/filepath"
"strings"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/internal/packager/git"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/helm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package helm
import (
"fmt"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/pkg/message"
"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/chart"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/images/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"net/http"
"time"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/message"
"github.com/defenseunicorns/zarf/src/pkg/transform"
Expand Down
27 changes: 26 additions & 1 deletion src/internal/packager/images/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"sync/atomic"
"time"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/layout"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down Expand Up @@ -246,6 +246,31 @@ func Pull(ctx context.Context, cfg PullConfig) (map[transform.Image]v1.Image, er
doneSaving <- nil
<-doneSaving

// Needed because when pulling from the local docker daemon, while using the docker containerd runtime
// Crane incorrectly names the blob of the docker image config to a sha that does not match the contents
// https://github.com/defenseunicorns/zarf/issues/2584
// This is a band aid fix while we wait for crane and or docker to create the permanent fix
blobDir := filepath.Join(cfg.DestinationDirectory, "blobs", "sha256")
err = filepath.Walk(blobDir, func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}

if fi.IsDir() {
return nil
}

hash, err := helpers.GetSHA256OfFile(path)
if err != nil {
return err
}
newFile := filepath.Join(blobDir, hash)
return os.Rename(path, newFile)
})
if err != nil {
return nil, err
}

return fetched, nil
}

Expand Down
6 changes: 3 additions & 3 deletions src/internal/packager/images/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"time"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/pkg/cluster"
"github.com/defenseunicorns/zarf/src/pkg/k8s"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down Expand Up @@ -53,7 +53,7 @@ func Push(ctx context.Context, cfg PushConfig) error {
)

progress := message.NewProgressBar(totalSize, fmt.Sprintf("Pushing %d images", len(toPush)))
defer progress.Stop()
defer progress.Close()

if err := helpers.Retry(func() error {
c, _ := cluster.NewCluster()
Expand Down Expand Up @@ -86,7 +86,7 @@ func Push(ctx context.Context, cfg PushConfig) error {
}()
for refInfo, img := range toPush {
refTruncated := helpers.Truncate(refInfo.Reference, 55, true)
progress.UpdateTitle(fmt.Sprintf("Pushing %s", refTruncated))
progress.Updatef(fmt.Sprintf("Pushing %s", refTruncated))

size, err := calcImgSize(img)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/kustomize/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"fmt"
"os"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"sigs.k8s.io/kustomize/api/krusty"
krustytypes "sigs.k8s.io/kustomize/api/types"
"sigs.k8s.io/kustomize/kyaml/filesys"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/sbom/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/anchore/syft/syft/pkg/cataloger"
"github.com/anchore/syft/syft/sbom"
"github.com/anchore/syft/syft/source"
"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/layout"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
2 changes: 1 addition & 1 deletion src/internal/packager/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/defenseunicorns/zarf/src/types"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/interactive"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cluster/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"strings"
"sync"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/k8s"
"github.com/defenseunicorns/zarf/src/pkg/layout"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cluster/injector.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"regexp"
"time"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/k8s"
"github.com/defenseunicorns/zarf/src/pkg/layout"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cluster/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/pkg/k8s"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cluster/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"

"github.com/defenseunicorns/zarf/src/pkg/k8s"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/cluster/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/defenseunicorns/pkg/helpers"
"github.com/defenseunicorns/pkg/helpers/v2"
"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/pkg/k8s"
"github.com/defenseunicorns/zarf/src/pkg/message"
Expand Down
Loading

0 comments on commit ece6c72

Please sign in to comment.