diff --git a/cmd/hauler/cli/completion.go b/cmd/hauler/cli/completion.go index af621777..e42bf20b 100644 --- a/cmd/hauler/cli/completion.go +++ b/cmd/hauler/cli/completion.go @@ -2,8 +2,9 @@ package cli import ( "fmt" - "github.com/spf13/cobra" "os" + + "github.com/spf13/cobra" ) func addCompletion(parent *cobra.Command) { @@ -34,19 +35,19 @@ func addCompletionZsh() *cobra.Command { Short: "Generates zsh completion scripts", Long: `The completion sub-command generates completion scripts for zsh.`, Example: `To load completion run - + . <(hauler completion zsh) - + To configure your zsh shell to load completions for each session add to your zshrc - + # ~/.zshrc or ~/.profile command -v hauler >/dev/null && . <(hauler completion zsh) - + or write a cached file in one of the completion directories in your ${fpath}: - + echo "${fpath// /\n}" | grep -i completion hauler completion zsh > _hauler - + mv _hauler ~/.oh-my-zsh/completions # oh-my-zsh mv _hauler ~/.zprezto/modules/completion/external/src/ # zprezto`, Run: func(cmd *cobra.Command, args []string) { @@ -64,11 +65,11 @@ func addCompletionBash() *cobra.Command { Short: "Generates bash completion scripts", Long: `The completion sub-command generates completion scripts for bash.`, Example: `To load completion run - + . <(hauler completion bash) - + To configure your bash shell to load completions for each session add to your bashrc - + # ~/.bashrc or ~/.profile command -v hauler >/dev/null && . <(hauler completion bash)`, Run: func(cmd *cobra.Command, args []string) { @@ -84,9 +85,9 @@ func addCompletionFish() *cobra.Command { Short: "Generates fish completion scripts", Long: `The completion sub-command generates completion scripts for fish.`, Example: `To configure your fish shell to load completions for each session write this script to your completions dir: - + hauler completion fish > ~/.config/fish/completions/hauler.fish - + See http://fishshell.com/docs/current/index.html#completion-own for more details`, Run: func(cmd *cobra.Command, args []string) { cmd.GenFishCompletion(os.Stdout, true) @@ -101,18 +102,18 @@ func addCompletionPowershell() *cobra.Command { Short: "Generates powershell completion scripts", Long: `The completion sub-command generates completion scripts for powershell.`, Example: `To load completion run - + . <(hauler completion powershell) - + To configure your powershell shell to load completions for each session add to your powershell profile - + Windows: - + cd "$env:USERPROFILE\Documents\WindowsPowerShell\Modules" hauler completion powershell >> hauler-completion.ps1 - + Linux: - + cd "${XDG_CONFIG_HOME:-"$HOME/.config/"}/powershell/modules" hauler completion powershell >> hauler-completions.ps1`, Run: func(cmd *cobra.Command, args []string) { diff --git a/cmd/hauler/cli/login.go b/cmd/hauler/cli/login.go index b7ae14c5..473bb7e9 100644 --- a/cmd/hauler/cli/login.go +++ b/cmd/hauler/cli/login.go @@ -3,11 +3,11 @@ package cli import ( "context" "fmt" - "github.com/spf13/cobra" "io" "os" "strings" + "github.com/spf13/cobra" "oras.land/oras-go/pkg/content" "github.com/rancherfederal/hauler/pkg/cosign" diff --git a/cmd/hauler/cli/store.go b/cmd/hauler/cli/store.go index 66fcf047..2f0c6f61 100644 --- a/cmd/hauler/cli/store.go +++ b/cmd/hauler/cli/store.go @@ -2,6 +2,7 @@ package cli import ( "fmt" + "github.com/spf13/cobra" "helm.sh/helm/v3/pkg/action" diff --git a/cmd/hauler/cli/store/add.go b/cmd/hauler/cli/store/add.go index ed0f26d2..e640a39a 100644 --- a/cmd/hauler/cli/store/add.go +++ b/cmd/hauler/cli/store/add.go @@ -8,15 +8,13 @@ import ( "github.com/spf13/cobra" "helm.sh/helm/v3/pkg/action" - "github.com/rancherfederal/hauler/pkg/artifacts/file" - - "github.com/rancherfederal/hauler/pkg/store" - "github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha1" + "github.com/rancherfederal/hauler/pkg/artifacts/file" "github.com/rancherfederal/hauler/pkg/content/chart" "github.com/rancherfederal/hauler/pkg/cosign" "github.com/rancherfederal/hauler/pkg/log" "github.com/rancherfederal/hauler/pkg/reference" + "github.com/rancherfederal/hauler/pkg/store" ) type AddFileOpts struct { diff --git a/cmd/hauler/cli/store/copy.go b/cmd/hauler/cli/store/copy.go index e77296f5..8694e85e 100644 --- a/cmd/hauler/cli/store/copy.go +++ b/cmd/hauler/cli/store/copy.go @@ -9,9 +9,8 @@ import ( "oras.land/oras-go/pkg/content" "github.com/rancherfederal/hauler/pkg/cosign" - "github.com/rancherfederal/hauler/pkg/store" - "github.com/rancherfederal/hauler/pkg/log" + "github.com/rancherfederal/hauler/pkg/store" ) type CopyOpts struct { diff --git a/cmd/hauler/cli/store/extract.go b/cmd/hauler/cli/store/extract.go index 22760522..835b70b6 100644 --- a/cmd/hauler/cli/store/extract.go +++ b/cmd/hauler/cli/store/extract.go @@ -9,11 +9,10 @@ import ( ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/cobra" - "github.com/rancherfederal/hauler/pkg/store" - "github.com/rancherfederal/hauler/internal/mapper" "github.com/rancherfederal/hauler/pkg/log" "github.com/rancherfederal/hauler/pkg/reference" + "github.com/rancherfederal/hauler/pkg/store" ) type ExtractOpts struct { diff --git a/cmd/hauler/cli/store/flags.go b/cmd/hauler/cli/store/flags.go index 0b4a2d15..9276affb 100644 --- a/cmd/hauler/cli/store/flags.go +++ b/cmd/hauler/cli/store/flags.go @@ -6,10 +6,10 @@ import ( "os" "path/filepath" - "github.com/rancherfederal/hauler/pkg/store" "github.com/spf13/cobra" "github.com/rancherfederal/hauler/pkg/log" + "github.com/rancherfederal/hauler/pkg/store" ) const ( diff --git a/cmd/hauler/cli/store/info.go b/cmd/hauler/cli/store/info.go index 45c1816c..8be77b60 100644 --- a/cmd/hauler/cli/store/info.go +++ b/cmd/hauler/cli/store/info.go @@ -4,18 +4,16 @@ import ( "context" "encoding/json" "fmt" - "github.com/olekukonko/tablewriter" "os" "sort" + "github.com/olekukonko/tablewriter" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/cobra" "github.com/rancherfederal/hauler/pkg/consts" - - "github.com/rancherfederal/hauler/pkg/store" - "github.com/rancherfederal/hauler/pkg/reference" + "github.com/rancherfederal/hauler/pkg/store" ) type InfoOpts struct { diff --git a/cmd/hauler/cli/store/load.go b/cmd/hauler/cli/store/load.go index 687c270e..22c3dd61 100644 --- a/cmd/hauler/cli/store/load.go +++ b/cmd/hauler/cli/store/load.go @@ -5,11 +5,11 @@ import ( "os" "github.com/mholt/archiver/v3" - "github.com/rancherfederal/hauler/pkg/content" - "github.com/rancherfederal/hauler/pkg/store" "github.com/spf13/cobra" + "github.com/rancherfederal/hauler/pkg/content" "github.com/rancherfederal/hauler/pkg/log" + "github.com/rancherfederal/hauler/pkg/store" ) type LoadOpts struct { diff --git a/cmd/hauler/cli/store/serve.go b/cmd/hauler/cli/store/serve.go index 140669d4..2ef90856 100644 --- a/cmd/hauler/cli/store/serve.go +++ b/cmd/hauler/cli/store/serve.go @@ -14,10 +14,9 @@ import ( "github.com/distribution/distribution/v3/version" "github.com/spf13/cobra" - "github.com/rancherfederal/hauler/pkg/store" - "github.com/rancherfederal/hauler/internal/server" "github.com/rancherfederal/hauler/pkg/log" + "github.com/rancherfederal/hauler/pkg/store" ) type ServeRegistryOpts struct { diff --git a/internal/mapper/filestore.go b/internal/mapper/filestore.go index c633b4f8..984266ec 100644 --- a/internal/mapper/filestore.go +++ b/internal/mapper/filestore.go @@ -2,7 +2,7 @@ package mapper import ( "context" - "io/ioutil" + "io" "os" "path/filepath" "strings" @@ -59,7 +59,7 @@ func (s *pusher) Push(ctx context.Context, desc ocispec.Descriptor) (ccontent.Wr // If no custom mapper found, fall back to content.File mapper if _, ok := s.mapper[desc.MediaType]; !ok { - return content.NewIoContentWriter(ioutil.Discard, content.WithOutputHash(desc.Digest)), nil + return content.NewIoContentWriter(io.Discard, content.WithOutputHash(desc.Digest)), nil } filename, err := s.mapper[desc.MediaType](desc) diff --git a/pkg/apis/hauler.cattle.io/v1alpha1/k3s.go b/pkg/apis/hauler.cattle.io/v1alpha1/k3s.go index 2040b634..da2fec4f 100644 --- a/pkg/apis/hauler.cattle.io/v1alpha1/k3s.go +++ b/pkg/apis/hauler.cattle.io/v1alpha1/k3s.go @@ -1,6 +1,8 @@ package v1alpha1 -import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) const K3sCollectionKind = "K3s" diff --git a/pkg/collection/chart/chart.go b/pkg/collection/chart/chart.go index 05be6c34..71103cc8 100644 --- a/pkg/collection/chart/chart.go +++ b/pkg/collection/chart/chart.go @@ -1,11 +1,11 @@ package chart import ( - "github.com/rancherfederal/hauler/pkg/artifacts" - "github.com/rancherfederal/hauler/pkg/artifacts/image" "helm.sh/helm/v3/pkg/action" "github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha1" + "github.com/rancherfederal/hauler/pkg/artifacts" + "github.com/rancherfederal/hauler/pkg/artifacts/image" "github.com/rancherfederal/hauler/pkg/content/chart" "github.com/rancherfederal/hauler/pkg/reference" ) diff --git a/pkg/collection/imagetxt/imagetxt.go b/pkg/collection/imagetxt/imagetxt.go index b9fc4055..b13c1b1e 100644 --- a/pkg/collection/imagetxt/imagetxt.go +++ b/pkg/collection/imagetxt/imagetxt.go @@ -9,12 +9,12 @@ import ( "strings" "sync" - "github.com/rancherfederal/hauler/pkg/log" - "github.com/google/go-containerregistry/pkg/name" + artifact "github.com/rancherfederal/hauler/pkg/artifacts" "github.com/rancherfederal/hauler/pkg/artifacts/file/getter" "github.com/rancherfederal/hauler/pkg/artifacts/image" + "github.com/rancherfederal/hauler/pkg/log" ) type ImageTxt struct { diff --git a/pkg/collection/k3s/k3s.go b/pkg/collection/k3s/k3s.go index 890db13a..624dad18 100644 --- a/pkg/collection/k3s/k3s.go +++ b/pkg/collection/k3s/k3s.go @@ -11,12 +11,9 @@ import ( "strings" "github.com/rancherfederal/hauler/pkg/artifacts" - "github.com/rancherfederal/hauler/pkg/artifacts/image" - "github.com/rancherfederal/hauler/pkg/artifacts/file" - "github.com/rancherfederal/hauler/pkg/artifacts/file/getter" - + "github.com/rancherfederal/hauler/pkg/artifacts/image" "github.com/rancherfederal/hauler/pkg/reference" ) diff --git a/pkg/content/chart/chart.go b/pkg/content/chart/chart.go index 40200762..718f3dda 100644 --- a/pkg/content/chart/chart.go +++ b/pkg/content/chart/chart.go @@ -24,9 +24,8 @@ import ( "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/registry" - "github.com/rancherfederal/hauler/pkg/layer" - "github.com/rancherfederal/hauler/pkg/consts" + "github.com/rancherfederal/hauler/pkg/layer" ) var ( diff --git a/pkg/content/chart/chart_test.go b/pkg/content/chart/chart_test.go index ce15dd1c..24fe79e1 100644 --- a/pkg/content/chart/chart_test.go +++ b/pkg/content/chart/chart_test.go @@ -10,7 +10,6 @@ import ( "helm.sh/helm/v3/pkg/action" "github.com/rancherfederal/hauler/pkg/consts" - "github.com/rancherfederal/hauler/pkg/content/chart" ) diff --git a/pkg/content/oci.go b/pkg/content/oci.go index b8df4cf7..00bc33c6 100644 --- a/pkg/content/oci.go +++ b/pkg/content/oci.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "os" "path/filepath" "sort" @@ -275,7 +274,7 @@ func (p *ociPusher) Push(ctx context.Context, d ocispec.Descriptor) (ccontent.Wr if _, err := os.Stat(blobPath); err == nil { // file already exists, discard (but validate digest) - return content.NewIoContentWriter(ioutil.Discard, content.WithOutputHash(d.Digest)), nil + return content.NewIoContentWriter(io.Discard, content.WithOutputHash(d.Digest)), nil } f, err := os.Create(blobPath) diff --git a/pkg/cosign/cosign.go b/pkg/cosign/cosign.go index 4a33b2d1..a1b57cb8 100644 --- a/pkg/cosign/cosign.go +++ b/pkg/cosign/cosign.go @@ -13,10 +13,11 @@ import ( "strings" "time" + "oras.land/oras-go/pkg/content" + "github.com/rancherfederal/hauler/pkg/artifacts/image" "github.com/rancherfederal/hauler/pkg/log" "github.com/rancherfederal/hauler/pkg/store" - "oras.land/oras-go/pkg/content" ) const maxRetries = 3