diff --git a/.gitignore b/.gitignore index 0d531293..da798ac7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,5 @@ .DS_Store - -# Vagrant -.vagrant - -# Editor directories and files +**/.DS_Store .idea .vscode *.suo @@ -12,13 +8,9 @@ *.sln *.sw? *.dir-locals.el - -# old, ad-hoc ignores artifacts local-artifacts airgap-scp.sh - -# generated dist/ tmp/ bin/ diff --git a/cmd/hauler/cli/completion.go b/cmd/hauler/cli/completion.go index 67929a95..e42bf20b 100644 --- a/cmd/hauler/cli/completion.go +++ b/cmd/hauler/cli/completion.go @@ -3,23 +3,24 @@ package cli import ( "fmt" "os" + "github.com/spf13/cobra" ) func addCompletion(parent *cobra.Command) { cmd := &cobra.Command{ - Use: "completion", - Short: "Generates completion scripts for various shells", + Use: "completion", + Short: "Generates completion scripts for various shells", Long: `The completion sub-command generates completion scripts for various shells.`, } - + cmd.AddCommand( addCompletionZsh(), addCompletionBash(), addCompletionFish(), addCompletionPowershell(), ) - + parent.AddCommand(cmd) } @@ -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) { @@ -120,4 +121,4 @@ func addCompletionPowershell() *cobra.Command { }, } return cmd -} \ No newline at end of file +} diff --git a/cmd/hauler/cli/login.go b/cmd/hauler/cli/login.go index 0f28c649..473bb7e9 100644 --- a/cmd/hauler/cli/login.go +++ b/cmd/hauler/cli/login.go @@ -2,20 +2,20 @@ package cli import ( "context" - "strings" - "os" - "io" "fmt" - "github.com/spf13/cobra" + "io" + "os" + "strings" + "github.com/spf13/cobra" "oras.land/oras-go/pkg/content" "github.com/rancherfederal/hauler/pkg/cosign" ) type Opts struct { - Username string - Password string + Username string + Password string PasswordStdin bool } @@ -35,7 +35,7 @@ func addLogin(parent *cobra.Command) { Example: ` # Log in to reg.example.com hauler login reg.example.com -u bob -p haulin`, - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, arg []string) error { ctx := cmd.Context() @@ -47,7 +47,7 @@ hauler login reg.example.com -u bob -p haulin`, o.Password = strings.TrimSuffix(string(contents), "\n") o.Password = strings.TrimSuffix(o.Password, "\r") } - + if o.Username == "" && o.Password == "" { return fmt.Errorf("username and password required") } @@ -62,14 +62,14 @@ hauler login reg.example.com -u bob -p haulin`, func login(ctx context.Context, o *Opts, registry string) error { ropts := content.RegistryOptions{ - Username: o.Username, - Password: o.Password, + Username: o.Username, + Password: o.Password, } err := cosign.RegistryLogin(ctx, nil, registry, ropts) if err != nil { return err } - + return nil -} \ No newline at end of file +} diff --git a/cmd/hauler/cli/store.go b/cmd/hauler/cli/store.go index 9985bb13..2f0c6f61 100644 --- a/cmd/hauler/cli/store.go +++ b/cmd/hauler/cli/store.go @@ -1,9 +1,10 @@ package cli import ( + "fmt" + "github.com/spf13/cobra" "helm.sh/helm/v3/pkg/action" - "fmt" "github.com/rancherfederal/hauler/cmd/hauler/cli/store" ) @@ -125,11 +126,11 @@ func addStoreServe() *cobra.Command { // RegistryCmd serves the embedded registry func addStoreServeRegistry() *cobra.Command { - o := &store.ServeRegistryOpts{RootOpts: rootStoreOpts} + o := &store.ServeRegistryOpts{RootOpts: rootStoreOpts} cmd := &cobra.Command{ - Use: "registry", - Short: "Serve the embedded registry", - RunE: func(cmd *cobra.Command, args []string) error { + Use: "registry", + Short: "Serve the embedded registry", + RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() s, err := o.Store(ctx) @@ -138,21 +139,21 @@ func addStoreServeRegistry() *cobra.Command { } return store.ServeRegistryCmd(ctx, o, s) - }, - } + }, + } - o.AddFlags(cmd) + o.AddFlags(cmd) - return cmd + return cmd } // FileServerCmd serves the file server func addStoreServeFiles() *cobra.Command { - o := &store.ServeFilesOpts{RootOpts: rootStoreOpts} + o := &store.ServeFilesOpts{RootOpts: rootStoreOpts} cmd := &cobra.Command{ - Use: "fileserver", - Short: "Serve the file server", - RunE: func(cmd *cobra.Command, args []string) error { + Use: "fileserver", + Short: "Serve the file server", + RunE: func(cmd *cobra.Command, args []string) error { ctx := cmd.Context() s, err := o.Store(ctx) @@ -161,12 +162,12 @@ func addStoreServeFiles() *cobra.Command { } return store.ServeFilesCmd(ctx, o, s) - }, - } + }, + } - o.AddFlags(cmd) + o.AddFlags(cmd) - return cmd + return cmd } func addStoreSave() *cobra.Command { @@ -210,7 +211,7 @@ func addStoreInfo() *cobra.Command { if err != nil { return err } - + for _, allowed := range allowedValues { if o.TypeFilter == allowed { return store.InfoCmd(ctx, o, s) diff --git a/cmd/hauler/cli/store/add.go b/cmd/hauler/cli/store/add.go index 6d45e98f..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 { @@ -103,7 +101,7 @@ func storeImage(ctx context.Context, s *store.Layout, i v1alpha1.Image, platform if err != nil { return err } - + err = cosign.SaveImage(ctx, s, r.Name(), platform) if err != nil { return err @@ -147,7 +145,7 @@ func AddChartCmd(ctx context.Context, o *AddChartOpts, s *store.Layout, chartNam func storeChart(ctx context.Context, s *store.Layout, cfg v1alpha1.Chart, opts *action.ChartPathOptions) error { l := log.FromContext(ctx) l.Infof("adding 'chart' [%s] to the store", cfg.Name) - + // TODO: This shouldn't be necessary opts.RepoURL = cfg.RepoURL opts.Version = cfg.Version diff --git a/cmd/hauler/cli/store/copy.go b/cmd/hauler/cli/store/copy.go index d70fe1e9..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 { @@ -55,7 +54,7 @@ func CopyCmd(ctx context.Context, o *CopyOpts, s *store.Layout, targetRef string Insecure: o.Insecure, PlainHTTP: o.PlainHTTP, } - + if ropts.Username != "" { err := cosign.RegistryLogin(ctx, s, components[1], ropts) if err != nil { diff --git a/cmd/hauler/cli/store/extract.go b/cmd/hauler/cli/store/extract.go index 3d9630da..835b70b6 100644 --- a/cmd/hauler/cli/store/extract.go +++ b/cmd/hauler/cli/store/extract.go @@ -2,18 +2,17 @@ package store import ( "context" - "strings" "encoding/json" "fmt" + "strings" 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 { @@ -37,7 +36,7 @@ func ExtractCmd(ctx context.Context, o *ExtractOpts, s *store.Layout, ref string found := false if err := s.Walk(func(reference string, desc ocispec.Descriptor) error { - + if !strings.Contains(reference, r.Name()) { return nil } 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 57a788c6..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 { @@ -47,7 +45,7 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error { } defer rc.Close() - // handle multi-arch images + // handle multi-arch images if desc.MediaType == consts.OCIImageIndexSchema || desc.MediaType == consts.DockerManifestListSchema2 { var idx ocispec.Index if err := json.NewDecoder(rc).Decode(&idx); err != nil { @@ -72,13 +70,13 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error { items = append(items, i) } } - // handle "non" multi-arch images + // handle "non" multi-arch images } else if desc.MediaType == consts.DockerManifestSchema2 || desc.MediaType == consts.OCIManifestSchema1 { var m ocispec.Manifest if err := json.NewDecoder(rc).Decode(&m); err != nil { return err } - + rc, err := s.FetchManifest(ctx, m) if err != nil { return err @@ -90,7 +88,7 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error { if err := json.NewDecoder(rc).Decode(&internalManifest); err != nil { return err } - + if internalManifest.Architecture != "" { i := newItem(s, desc, m, fmt.Sprintf("%s/%s", internalManifest.OS, internalManifest.Architecture), o) var emptyItem item @@ -104,8 +102,8 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error { items = append(items, i) } } - // handle the rest - } else { + // handle the rest + } else { var m ocispec.Manifest if err := json.NewDecoder(rc).Decode(&m); err != nil { return err @@ -144,7 +142,7 @@ func buildTable(items ...item) { table.SetHeaderAlignment(tablewriter.ALIGN_LEFT) table.SetRowLine(false) table.SetAutoMergeCellsByColumnIndex([]int{0}) - + totalSize := int64(0) for _, i := range items { if i.Type != "" { @@ -173,11 +171,11 @@ func buildJson(item ...item) string { } type item struct { - Reference string - Type string - Platform string - Layers int - Size int64 + Reference string + Type string + Platform string + Layers int + Size int64 } type byReferenceAndArch []item @@ -227,7 +225,7 @@ func newItem(s *store.Layout, desc ocispec.Descriptor, m ocispec.Manifest, plat case "dev.cosignproject.cosign/sboms": ctype = "sbom" } - + ref, err := reference.Parse(desc.Annotations[ocispec.AnnotationRefName]) if err != nil { return item{} @@ -238,11 +236,11 @@ func newItem(s *store.Layout, desc ocispec.Descriptor, m ocispec.Manifest, plat } return item{ - Reference: ref.Name(), - Type: ctype, - Platform: plat, - Layers: len(m.Layers), - Size: size, + Reference: ref.Name(), + Type: ctype, + Platform: plat, + Layers: len(m.Layers), + Size: size, } } 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 119108b5..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" @@ -15,7 +15,8 @@ import ( ) // NewMapperFileStore creates a new file store that uses mapper functions for each detected descriptor. -// This extends content.File, and differs in that it allows much more functionality into how each descriptor is written. +// +// This extends content.File, and differs in that it allows much more functionality into how each descriptor is written. func NewMapperFileStore(root string, mapper map[string]Fn) *store { fs := content.NewFile(root) return &store{ @@ -58,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/internal/server/registry.go b/internal/server/registry.go index 6e2f3dcc..9f27b6d3 100644 --- a/internal/server/registry.go +++ b/internal/server/registry.go @@ -47,7 +47,7 @@ func NewTempRegistry(ctx context.Context, root string) *tmpRegistryServer { } // Add validation configuration cfg.Validation.Manifests.URLs.Allow = []string{".+"} - + cfg.Log.Level = "error" cfg.HTTP.Headers = http.Header{ "X-Content-Type-Options": []string{"nosniff"}, diff --git a/internal/version/version.go b/internal/version/version.go index 96e07b27..86de4f15 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -226,4 +226,4 @@ func (i *Info) CheckFontName(fontName string) bool { fmt.Fprintln(os.Stderr, "font not valid, using default") return false -} \ No newline at end of file +} diff --git a/pkg/apis/hauler.cattle.io/v1alpha1/image.go b/pkg/apis/hauler.cattle.io/v1alpha1/image.go index 0b894e28..23fb3c1f 100644 --- a/pkg/apis/hauler.cattle.io/v1alpha1/image.go +++ b/pkg/apis/hauler.cattle.io/v1alpha1/image.go @@ -20,7 +20,7 @@ type ImageSpec struct { type Image struct { // Name is the full location for the image, can be referenced by tags or digests Name string `json:"name"` - + // Path is the path to the cosign public key used for verifying image signatures //Key string `json:"key,omitempty"` Key string `json:"key"` 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/artifacts/image/image.go b/pkg/artifacts/image/image.go index e3bd20a0..5cd87e2b 100644 --- a/pkg/artifacts/image/image.go +++ b/pkg/artifacts/image/image.go @@ -54,27 +54,27 @@ func NewImage(name string, opts ...remote.Option) (*Image, error) { } func IsMultiArchImage(name string, opts ...remote.Option) (bool, error) { - ref, err := gname.ParseReference(name) - if err != nil { - return false, fmt.Errorf("parsing reference %q: %v", name, err) - } + ref, err := gname.ParseReference(name) + if err != nil { + return false, fmt.Errorf("parsing reference %q: %v", name, err) + } defaultOpts := []remote.Option{ remote.WithAuthFromKeychain(authn.DefaultKeychain), } opts = append(opts, defaultOpts...) - desc, err := remote.Get(ref, opts...) - if err != nil { - return false, fmt.Errorf("getting image %q: %v", name, err) - } + desc, err := remote.Get(ref, opts...) + if err != nil { + return false, fmt.Errorf("getting image %q: %v", name, err) + } - _, err = desc.ImageIndex() - if err != nil { - // If the descriptor could not be converted to an image index, it's not a multi-arch image - return false, nil - } + _, err = desc.ImageIndex() + if err != nil { + // If the descriptor could not be converted to an image index, it's not a multi-arch image + return false, nil + } - // If the descriptor could be converted to an image index, it's a multi-arch image - return true, nil -} \ No newline at end of file + // If the descriptor could be converted to an image index, it's a multi-arch image + return true, nil +} diff --git a/pkg/artifacts/ocis.go b/pkg/artifacts/ocis.go index c1fe25be..fa432b10 100644 --- a/pkg/artifacts/ocis.go +++ b/pkg/artifacts/ocis.go @@ -3,8 +3,9 @@ package artifacts import "github.com/google/go-containerregistry/pkg/v1" // OCI is the bare minimum we need to represent an artifact in an oci layout -// At a high level, it is not constrained by an Image's config, manifests, and layer ordinality -// This specific implementation fully encapsulates v1.Layer's within a more generic form +// +// At a high level, it is not constrained by an Image's config, manifests, and layer ordinality +// This specific implementation fully encapsulates v1.Layer's within a more generic form type OCI interface { MediaType() string 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/consts/consts.go b/pkg/consts/consts.go index a3853e2d..1c1d9517 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -50,8 +50,8 @@ const ( KindAnnotationName = "kind" KindAnnotation = "dev.cosignproject.cosign/image" - CarbideRegistry = "rgcrprod.azurecr.us" - ImageAnnotationKey = "hauler.dev/key" + CarbideRegistry = "rgcrprod.azurecr.us" + ImageAnnotationKey = "hauler.dev/key" ImageAnnotationPlatform = "hauler.dev/platform" ImageAnnotationRegistry = "hauler.dev/registry" ) 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 442c3401..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 @@ -276,4 +277,4 @@ func getCosignPath() (string, error) { binaryPath := filepath.Join(haulerDir, binaryName) return binaryPath, nil -} \ No newline at end of file +} diff --git a/pkg/log/log.go b/pkg/log/log.go index b99e9a75..82de3b29 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -30,13 +30,13 @@ type Fields map[string]string // NewLogger returns a new Logger func NewLogger(out io.Writer) Logger { - customTimeFormat := "2006-01-02 15:04:05" - zerolog.TimeFieldFormat = customTimeFormat - output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: customTimeFormat} - l := log.Output(output) - return &logger{ - zl: l.With().Timestamp().Logger(), - } + customTimeFormat := "2006-01-02 15:04:05" + zerolog.TimeFieldFormat = customTimeFormat + output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: customTimeFormat} + l := log.Output(output) + return &logger{ + zl: l.With().Timestamp().Logger(), + } } // FromContext returns a Logger from a context if it exists diff --git a/pkg/reference/reference.go b/pkg/reference/reference.go index 22fb8a9b..5f007719 100644 --- a/pkg/reference/reference.go +++ b/pkg/reference/reference.go @@ -1,7 +1,7 @@ // Package reference provides general types to represent oci content within a registry or local oci layout // Grammar (stolen mostly from containerd's grammar) // -// reference := +// reference := package reference import (