diff --git a/cmd/hauler/cli/store/info.go b/cmd/hauler/cli/store/info.go index f4de62df..f8cd38cc 100644 --- a/cmd/hauler/cli/store/info.go +++ b/cmd/hauler/cli/store/info.go @@ -38,7 +38,6 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error { if _, ok := desc.Annotations[ocispec.AnnotationRefName]; !ok { return nil } - rc, err := s.Fetch(ctx, desc) if err != nil { return err @@ -49,9 +48,11 @@ func InfoCmd(ctx context.Context, o *InfoOpts, s *store.Layout) error { if err := json.NewDecoder(rc).Decode(&m); err != nil { return err } - i := newItem(s, desc, m) - items = append(items, i) + var emptyItem item + if i != emptyItem { + items = append(items, i) + } return nil }); err != nil { @@ -78,7 +79,7 @@ func buildTable(items ...item) string { fmt.Fprintf(tw, "---------\t----\t--------\t----\n") for _, i := range items { - if i.Type != "unknown" { + if i.Type != "" { fmt.Fprintf(tw, "%s\t%s\t%d\t%s\n", i.Reference, i.Type, i.Layers, i.Size, ) @@ -104,6 +105,12 @@ type item struct { } func newItem(s *store.Layout, desc ocispec.Descriptor, m ocispec.Manifest) item { + if desc.Annotations["kind"] == "dev.cosignproject.cosign/atts" || + desc.Annotations["kind"] == "dev.cosignproject.cosign/sigs" || + desc.Annotations["kind"] == "dev.cosignproject.cosign/sboms" { + return item{} + } + var size int64 = 0 for _, l := range m.Layers { size = +l.Size @@ -119,7 +126,7 @@ func newItem(s *store.Layout, desc ocispec.Descriptor, m ocispec.Manifest) item case consts.FileLocalConfigMediaType, consts.FileHttpConfigMediaType: ctype = "file" default: - ctype = "unknown" + ctype = "image" } ref, err := reference.Parse(desc.Annotations[ocispec.AnnotationRefName]) diff --git a/cmd/hauler/cli/store/sync.go b/cmd/hauler/cli/store/sync.go index 7f90b345..065e21e1 100644 --- a/cmd/hauler/cli/store/sync.go +++ b/cmd/hauler/cli/store/sync.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "os" + "strings" "github.com/spf13/cobra" "helm.sh/helm/v3/pkg/action" @@ -13,11 +14,11 @@ import ( "github.com/mitchellh/go-homedir" "github.com/rancherfederal/hauler/pkg/store" - "github.com/rancherfederal/hauler/pkg/apis/hauler.cattle.io/v1alpha1" tchart "github.com/rancherfederal/hauler/pkg/collection/chart" "github.com/rancherfederal/hauler/pkg/collection/imagetxt" "github.com/rancherfederal/hauler/pkg/collection/k3s" + "github.com/rancherfederal/hauler/pkg/consts" "github.com/rancherfederal/hauler/pkg/content" "github.com/rancherfederal/hauler/pkg/cosign" "github.com/rancherfederal/hauler/pkg/log" @@ -27,13 +28,15 @@ type SyncOpts struct { *RootOpts ContentFiles []string Key string + Products []string } func (o *SyncOpts) AddFlags(cmd *cobra.Command) { f := cmd.Flags() f.StringSliceVarP(&o.ContentFiles, "files", "f", []string{}, "Path to content files") - f.StringVarP(&o.Key, "key", "k", "", "(Optional) Path to the key for image signature verification") + f.StringVarP(&o.Key, "key", "k", "", "(Optional) Path to the key for signature verification") + f.StringSliceVar(&o.Products, "products", []string{}, "Used for RGS Carbide customers to supply a product and version and Hauler will retrieve the images. i.e. '--product rancher=v2.7.6'") } func SyncCmd(ctx context.Context, o *SyncOpts, s *store.Layout) error { @@ -45,157 +48,197 @@ func SyncCmd(ctx context.Context, o *SyncOpts, s *store.Layout) error { return err } + // if passed products, check for a remote manifest to retrieve and use. + for _, product := range o.Products { + l.Infof("processing content file for product: '%s'", product) + parts := strings.Split(product, "=") + tag := strings.ReplaceAll(parts[1], "+", "-") + manifestLoc := fmt.Sprintf("%s/hauler/%s-manifest.yaml:%s", consts.CarbideRegistry, parts[0], tag) + l.Infof("retrieving product manifest from: '%s'", manifestLoc) + img := v1alpha1.Image{ + Name: manifestLoc, + } + err := storeImage(ctx, s, img) + if err != nil { + return err + } + err = ExtractCmd(ctx, &ExtractOpts{RootOpts: o.RootOpts}, s, fmt.Sprintf("hauler/%s-manifest.yaml:%s", parts[0],tag)) + if err != nil { + return err + } + filename := fmt.Sprintf("%s-manifest.yaml", parts[0]) + + fi, err := os.Open(filename) + if err != nil { + return err + } + err = processContent(ctx, fi, o, s) + if err != nil { + return err + } + } + + // if passed a local manifest, process it for _, filename := range o.ContentFiles { l.Debugf("processing content file: '%s'", filename) fi, err := os.Open(filename) if err != nil { return err } + err = processContent(ctx, fi, o, s) + if err != nil { + return err + } + } + + return nil +} - reader := yaml.NewYAMLReader(bufio.NewReader(fi)) +func processContent(ctx context.Context, fi *os.File, o *SyncOpts, s *store.Layout) error { + l := log.FromContext(ctx) - var docs [][]byte - for { - raw, err := reader.Read() - if err == io.EOF { - break - } - if err != nil { - return err - } + reader := yaml.NewYAMLReader(bufio.NewReader(fi)) - docs = append(docs, raw) + var docs [][]byte + for { + raw, err := reader.Read() + if err == io.EOF { + break + } + if err != nil { + return err } - for _, doc := range docs { - obj, err := content.Load(doc) - if err != nil { - l.Debugf("skipping sync of unknown content") - continue - } + docs = append(docs, raw) + } - l.Infof("syncing [%s] to store", obj.GroupVersionKind().String()) + for _, doc := range docs { + obj, err := content.Load(doc) + if err != nil { + l.Debugf("skipping sync of unknown content") + continue + } - // TODO: Should type switch instead... - switch obj.GroupVersionKind().Kind { - case v1alpha1.FilesContentKind: - var cfg v1alpha1.Files - if err := yaml.Unmarshal(doc, &cfg); err != nil { - return err - } + l.Infof("syncing [%s] to store", obj.GroupVersionKind().String()) - for _, f := range cfg.Spec.Files { - err := storeFile(ctx, s, f) - if err != nil { - return err - } - } + // TODO: Should type switch instead... + switch obj.GroupVersionKind().Kind { + case v1alpha1.FilesContentKind: + var cfg v1alpha1.Files + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } - case v1alpha1.ImagesContentKind: - var cfg v1alpha1.Images - if err := yaml.Unmarshal(doc, &cfg); err != nil { + for _, f := range cfg.Spec.Files { + err := storeFile(ctx, s, f) + if err != nil { return err } + } + + case v1alpha1.ImagesContentKind: + var cfg v1alpha1.Images + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } + + for _, i := range cfg.Spec.Images { - for _, i := range cfg.Spec.Images { - - // Check if the user provided a key. - if o.Key != "" || i.Key != "" { - key := o.Key - if i.Key != "" { - key, err = homedir.Expand(i.Key) - } - l.Debugf("key for image [%s]", key) - - // verify signature using the provided key. - err := cosign.VerifySignature(ctx, s, key, i.Name) - if err != nil { - l.Errorf("signature verification failed for image [%s]. ** hauler will skip adding this image to the store **:\n%v", i.Name, err) - continue - } - l.Infof("signature verified for image [%s]", i.Name) + // Check if the user provided a key. + if o.Key != "" || i.Key != "" { + key := o.Key + if i.Key != "" { + key, err = homedir.Expand(i.Key) } + l.Debugf("key for image [%s]", key) - err = storeImage(ctx, s, i) + // verify signature using the provided key. + err := cosign.VerifySignature(ctx, s, key, i.Name) if err != nil { - return err + l.Errorf("signature verification failed for image [%s]. ** hauler will skip adding this image to the store **:\n%v", i.Name, err) + continue } + l.Infof("signature verified for image [%s]", i.Name) } - - case v1alpha1.ChartsContentKind: - var cfg v1alpha1.Charts - if err := yaml.Unmarshal(doc, &cfg); err != nil { + + err = storeImage(ctx, s, i) + if err != nil { return err } + } - for _, ch := range cfg.Spec.Charts { - // TODO: Provide a way to configure syncs - err := storeChart(ctx, s, ch, &action.ChartPathOptions{}) - if err != nil { - return err - } - } - - case v1alpha1.K3sCollectionKind: - var cfg v1alpha1.K3s - if err := yaml.Unmarshal(doc, &cfg); err != nil { - return err - } + case v1alpha1.ChartsContentKind: + var cfg v1alpha1.Charts + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } - k, err := k3s.NewK3s(cfg.Spec.Version) + for _, ch := range cfg.Spec.Charts { + // TODO: Provide a way to configure syncs + err := storeChart(ctx, s, ch, &action.ChartPathOptions{}) if err != nil { return err } + } - if _, err := s.AddOCICollection(ctx, k); err != nil { - return err - } + case v1alpha1.K3sCollectionKind: + var cfg v1alpha1.K3s + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } - case v1alpha1.ChartsCollectionKind: - var cfg v1alpha1.ThickCharts - if err := yaml.Unmarshal(doc, &cfg); err != nil { - return err - } + k, err := k3s.NewK3s(cfg.Spec.Version) + if err != nil { + return err + } - for _, cfg := range cfg.Spec.Charts { - tc, err := tchart.NewThickChart(cfg, &action.ChartPathOptions{ - RepoURL: cfg.RepoURL, - Version: cfg.Version, - }) - if err != nil { - return err - } + if _, err := s.AddOCICollection(ctx, k); err != nil { + return err + } - if _, err := s.AddOCICollection(ctx, tc); err != nil { - return err - } + case v1alpha1.ChartsCollectionKind: + var cfg v1alpha1.ThickCharts + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } + + for _, cfg := range cfg.Spec.Charts { + tc, err := tchart.NewThickChart(cfg, &action.ChartPathOptions{ + RepoURL: cfg.RepoURL, + Version: cfg.Version, + }) + if err != nil { + return err } - case v1alpha1.ImageTxtsContentKind: - var cfg v1alpha1.ImageTxts - if err := yaml.Unmarshal(doc, &cfg); err != nil { + if _, err := s.AddOCICollection(ctx, tc); err != nil { return err } + } - for _, cfgIt := range cfg.Spec.ImageTxts { - it, err := imagetxt.New(cfgIt.Ref, - imagetxt.WithIncludeSources(cfgIt.Sources.Include...), - imagetxt.WithExcludeSources(cfgIt.Sources.Exclude...), - ) - if err != nil { - return fmt.Errorf("convert ImageTxt %s: %v", cfg.Name, err) - } + case v1alpha1.ImageTxtsContentKind: + var cfg v1alpha1.ImageTxts + if err := yaml.Unmarshal(doc, &cfg); err != nil { + return err + } - if _, err := s.AddOCICollection(ctx, it); err != nil { - return fmt.Errorf("add ImageTxt %s to store: %v", cfg.Name, err) - } + for _, cfgIt := range cfg.Spec.ImageTxts { + it, err := imagetxt.New(cfgIt.Ref, + imagetxt.WithIncludeSources(cfgIt.Sources.Include...), + imagetxt.WithExcludeSources(cfgIt.Sources.Exclude...), + ) + if err != nil { + return fmt.Errorf("convert ImageTxt %s: %v", cfg.Name, err) } - default: - return fmt.Errorf("unrecognized content/collection type: %s", obj.GroupVersionKind().String()) + if _, err := s.AddOCICollection(ctx, it); err != nil { + return fmt.Errorf("add ImageTxt %s to store: %v", cfg.Name, err) + } } + + default: + return fmt.Errorf("unrecognized content/collection type: %s", obj.GroupVersionKind().String()) } } - return nil } diff --git a/go.mod b/go.mod index 775b9f07..01af7059 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,9 @@ module github.com/rancherfederal/hauler go 1.21 require ( + github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be github.com/containerd/containerd v1.7.6 - github.com/distribution/distribution/v3 v3.0.0-20231004133549-f7b3869062db + github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 github.com/docker/go-metrics v0.0.1 github.com/google/go-containerregistry v0.16.1 github.com/gorilla/handlers v1.5.1 @@ -35,18 +36,19 @@ require ( github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Masterminds/squirrel v1.5.4 // indirect github.com/Microsoft/hcsshim v0.11.0 // indirect + github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect github.com/andybalholm/brotli v1.0.1 // indirect github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bshuster-repo/logrus-logstash-hook v1.0.0 // indirect + github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd // indirect + github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b // indirect + github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/chai2010/gettext-go v1.0.2 // indirect github.com/containerd/stargz-snapshotter/estargz v0.14.3 // indirect - github.com/coreos/go-systemd/v22 v22.5.0 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/distribution/reference v0.5.0 // indirect github.com/docker/cli v24.0.6+incompatible // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/docker v24.0.6+incompatible // indirect @@ -54,6 +56,7 @@ require ( github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect github.com/docker/go-units v0.5.0 // indirect + github.com/docker/libtrust v0.0.0-20150114040149-fa567046d9b1 // indirect github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect github.com/emicklei/go-restful/v3 v3.10.1 // indirect github.com/evanphx/json-patch v5.6.0+incompatible // indirect @@ -71,6 +74,7 @@ require ( github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.2 // indirect + github.com/gomodule/redigo v1.8.2 // indirect github.com/google/btree v1.0.1 // indirect github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -81,8 +85,7 @@ require ( github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/golang-lru/arc/v2 v2.0.5 // indirect - github.com/hashicorp/golang-lru/v2 v2.0.5 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/huandu/xstrings v1.4.0 // indirect github.com/imdario/mergo v0.3.13 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -118,9 +121,6 @@ require ( github.com/prometheus/client_model v0.4.0 // indirect github.com/prometheus/common v0.44.0 // indirect github.com/prometheus/procfs v0.10.1 // indirect - github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 // indirect - github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 // indirect - github.com/redis/go-redis/v9 v9.1.0 // indirect github.com/rubenv/sql-migrate v1.5.2 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/shopspring/decimal v1.3.1 // indirect @@ -133,15 +133,18 @@ require ( github.com/xeipuuv/gojsonschema v1.2.0 // indirect github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xlab/treeprint v1.2.0 // indirect + github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 // indirect + github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 // indirect + github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f // indirect go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - golang.org/x/crypto v0.13.0 // indirect - golang.org/x/net v0.13.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect golang.org/x/oauth2 v0.8.0 // indirect - golang.org/x/sys v0.12.0 // indirect - golang.org/x/term v0.12.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index 28b3d189..2f51e161 100644 --- a/go.sum +++ b/go.sum @@ -62,6 +62,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Microsoft/hcsshim v0.11.0 h1:7EFNIY4igHEXUdj1zXgAyU3fLc7QfOKHbkldRVTBdiM= github.com/Microsoft/hcsshim v0.11.0/go.mod h1:OEthFdQv/AD2RAdzR6Mm1N1KPCztGKDurW1Z8b8VGMM= +github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d h1:UrqY+r/OJnIp5u0s1SbQ8dVfLCZJsnvazdBP5hS4iRs= +github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d/go.mod h1:HI8ITrYtUY+O+ZhtlqUnD8+KwNPOyugEhfP9fdUIaEQ= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/andybalholm/brotli v1.0.1 h1:KqhlKozYbRtJvsPrrEeXcO+N2l6NYT5A2QAFmSULpEc= @@ -74,13 +76,16 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bitly/go-simplejson v0.5.0 h1:6IH+V8/tVMab511d5bn4M7EwGXZf9Hj6i2xSwkNEM+Y= +github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA= github.com/bshuster-repo/logrus-logstash-hook v1.0.0 h1:e+C0SB5R1pu//O4MQ3f9cFuPGoOVeF2fE4Og9otCc70= github.com/bshuster-repo/logrus-logstash-hook v1.0.0/go.mod h1:zsTqEiSzDgAa/8GZR7E1qaXrhYNDKBYy5/dWPTIflbk= -github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= -github.com/bsm/ginkgo/v2 v2.9.5 h1:rtVBYPs3+TC5iLUVOis1B9tjLTup7Cj5IfzosKtvTJ0= -github.com/bsm/ginkgo/v2 v2.9.5/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= -github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= -github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= +github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd h1:rFt+Y/IK1aEZkEHchZRSq9OQbsSzIT/OrI8YFFmRIng= +github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8= +github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b h1:otBG+dV+YK+Soembjv71DPz3uX/V/6MMlSyD9JBQ6kQ= +github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50= +github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0 h1:nvj0OLI3YqYXer/kZD8Ri1aaunCxIEsOst1BVJswV0o= +github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -93,6 +98,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be h1:J5BL2kskAlV9ckgEsNQXscjIaLiOYiZ75d4e94E6dcQ= +github.com/common-nighthawk/go-figure v0.0.0-20210622060536-734e95fb86be/go.mod h1:mk5IQ+Y0ZeO87b858TlA645sVcEcbiX6YqP98kt+7+w= github.com/containerd/cgroups v1.1.0 h1:v8rEWFl6EoqHB+swVNjVoCJE8o3jX7e8nqBGPLaDFBM= github.com/containerd/cgroups v1.1.0/go.mod h1:6ppBcbh/NOOUU+dMKrykgaBnK9lCIBxHqJDGwsa1mIw= github.com/containerd/containerd v1.7.6 h1:oNAVsnhPoy4BTPQivLgTzI9Oleml9l/+eYIDYXRCYo8= @@ -101,7 +108,6 @@ github.com/containerd/continuity v0.4.2 h1:v3y/4Yz5jwnvqPKJJ+7Wf93fyWoCB3F5EclWG github.com/containerd/continuity v0.4.2/go.mod h1:F6PTNCKepoxEaXLQp3wDAjygEnImnZ/7o4JzpodfroQ= github.com/containerd/stargz-snapshotter/estargz v0.14.3 h1:OqlDCK3ZVUO6C3B/5FSkDwbkEETK84kQgEeFwDC+62k= github.com/containerd/stargz-snapshotter/estargz v0.14.3/go.mod h1:KY//uOCIkSuNAHhJogcZtrNHdKrA99/FCCRjE3HD36o= -github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -112,12 +118,8 @@ github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/distribution/distribution/v3 v3.0.0-20231004133549-f7b3869062db h1:bwffIMjFs5rBshD1HEKXy6sFyzMBcF8a5d30vGkh0DE= -github.com/distribution/distribution/v3 v3.0.0-20231004133549-f7b3869062db/go.mod h1:bSnTXMkKon2ocCpstaEtW+QbaGgTfgqApdhvdxeFzK8= -github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= -github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc= +github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2/go.mod h1:WHNsWjnIn2V1LYOrME7e8KxSeKunYHsxEm4am0BUtcI= github.com/docker/cli v24.0.6+incompatible h1:fF+XCQCgJjjQNIMjzaSmiKJSCcfcXb3TWTcc7GAneOY= github.com/docker/cli v24.0.6+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8= @@ -231,6 +233,8 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.2 h1:aeE13tS0IiQgFjYdoL8qN3K1N2bXXtI6Vi51/y7BpMw= github.com/golang/snappy v0.0.2/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/gomodule/redigo v1.8.2 h1:H5XSIre1MB5NbPYFp+i1NBbb5qN1W8Y8YAQoAYbkm8k= +github.com/gomodule/redigo v1.8.2/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= @@ -295,10 +299,8 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru/arc/v2 v2.0.5 h1:l2zaLDubNhW4XO3LnliVj0GXO3+/CGNJAg1dcN2Fpfw= -github.com/hashicorp/golang-lru/arc/v2 v2.0.5/go.mod h1:ny6zBSQZi2JxIeYcv7kt2sH2PXJtirBN7RDhRpxPkxU= -github.com/hashicorp/golang-lru/v2 v2.0.5 h1:wW7h1TG88eUIJ2i69gaE3uNVtEPIagzhGvHgwfx2Vm4= -github.com/hashicorp/golang-lru/v2 v2.0.5/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/huandu/xstrings v1.3.3/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU= github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= @@ -386,6 +388,8 @@ github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= +github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f h1:2+myh5ml7lgEU/51gbeLHfKGNfgEQQIWrlbdaOsidbQ= +github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= @@ -454,13 +458,6 @@ github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsT github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= -github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5 h1:EaDatTxkdHG+U3Bk4EUr+DZ7fOGwTfezUiUJMaIcaho= -github.com/redis/go-redis/extra/rediscmd/v9 v9.0.5/go.mod h1:fyalQWdtzDBECAQFBJuQe5bzQ02jGd5Qcbgb97Flm7U= -github.com/redis/go-redis/extra/redisotel/v9 v9.0.5 h1:EfpWLLCyXw8PSM2/XNJLjI3Pb27yVE+gIAfeqp8LUCc= -github.com/redis/go-redis/extra/redisotel/v9 v9.0.5/go.mod h1:WZjPDy7VNzn77AAfnAfVjZNvfJTYfPetfZk5yoSTLaQ= -github.com/redis/go-redis/v9 v9.0.5/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= -github.com/redis/go-redis/v9 v9.1.0 h1:137FnGdk+EQdCbye1FW+qOEcY5S+SpY9T0NiuqvtfMY= -github.com/redis/go-redis/v9 v9.1.0/go.mod h1:urWj3He21Dj5k4TK1y59xH8Uj6ATueP8AH1cY3lZl4c= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= @@ -526,6 +523,12 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43 h1:+lm10QQTNSBd8DVTNGHx7o/IKu9HYDvLMffDhbyLccI= +github.com/yvasiyarov/go-metrics v0.0.0-20140926110328-57bccd1ccd43/go.mod h1:aX5oPXxHm3bOH+xeAttToC8pqch2ScQN/JoXYupl6xs= +github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50 h1:hlE8//ciYMztlGpl/VA+Zm1AcTPHYkHJPbHqE6WJUXE= +github.com/yvasiyarov/gorelic v0.0.0-20141212073537-a9bba5b9ab50/go.mod h1:NUSPSUX/bi6SeDMUh6brw0nXpxHnc96TguQh0+r/ssA= +github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f h1:ERexzlUfuTvpE74urLSbIQW0Z/6hF9t8U4NsJLaioAY= +github.com/yvasiyarov/newrelic_platform_go v0.0.0-20140908184405-b21fdbd4370f/go.mod h1:GlGEuHIJweS1mbCqG+7vt2nvWLzLLnRHbXz5JKd/Qbg= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -538,8 +541,6 @@ go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s= go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4= go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo= go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4= -go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE= -go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4= go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs= go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0= go.starlark.net v0.0.0-20230525235612-a134d8f9ddca h1:VdD38733bfYv5tUZwEIskMM93VanwNIi5bIKnDrJdEY= @@ -554,8 +555,8 @@ golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.13.0 h1:mvySKfSWJ+UKUii46M40LOvyWfN0s2U+46/jDd0e6Ck= -golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -628,8 +629,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= -golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -702,14 +703,15 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20220526004731-065cf7ba2467/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.12.0 h1:/ZfYdc3zq+q02Rv9vGqTeSItdzZTSNDmfTi0mBAuidU= -golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= +golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/internal/version/version.go b/internal/version/version.go index 656aa367..96e07b27 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -1,61 +1,229 @@ +/* +Copyright 2022 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package version import ( "encoding/json" "fmt" - "path" + "os" "runtime" + "runtime/debug" "strings" + "sync" "text/tabwriter" + "time" + + "github.com/common-nighthawk/go-figure" ) +const unknown = "unknown" + +// Base version information. +// +// This is the fallback data used when version information from git is not +// provided via go ldflags. var ( - GitVersion = "devel" - commit = "unknown" - buildDate = "unknown" + // Output of "git describe". The prerequisite is that the + // branch should be tagged using the correct versioning strategy. + gitVersion = "devel" + // SHA1 from git, output of $(git rev-parse HEAD) + gitCommit = unknown + // State of git tree, either "clean" or "dirty" + gitTreeState = unknown + // Build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ') + buildDate = unknown + // flag to print the ascii name banner + asciiName = "true" + // goVersion is the used golang version. + goVersion = unknown + // compiler is the used golang compiler. + compiler = unknown + // platform is the used os/arch identifier. + platform = unknown + + once sync.Once + info = Info{} ) type Info struct { - GitVersion string - GitCommit string - BuildDate string + GitVersion string `json:"gitVersion"` + GitCommit string `json:"gitCommit"` + GitTreeState string `json:"gitTreeState"` + BuildDate string `json:"buildDate"` + GoVersion string `json:"goVersion"` + Compiler string `json:"compiler"` + Platform string `json:"platform"` - GoVersion string - Compiler string - Platform string + ASCIIName string `json:"-"` + FontName string `json:"-"` + Name string `json:"-"` + Description string `json:"-"` } -func GetVersionInfo() Info { - return Info{ - GitVersion: GitVersion, - GitCommit: commit, - BuildDate: buildDate, +func getBuildInfo() *debug.BuildInfo { + bi, ok := debug.ReadBuildInfo() + if !ok { + return nil + } + return bi +} + +func getGitVersion(bi *debug.BuildInfo) string { + if bi == nil { + return unknown + } + + // TODO: remove this when the issue https://github.com/golang/go/issues/29228 is fixed + if bi.Main.Version == "(devel)" || bi.Main.Version == "" { + return gitVersion + } + + return bi.Main.Version +} + +func getCommit(bi *debug.BuildInfo) string { + return getKey(bi, "vcs.revision") +} + +func getDirty(bi *debug.BuildInfo) string { + modified := getKey(bi, "vcs.modified") + if modified == "true" { + return "dirty" + } + if modified == "false" { + return "clean" + } + return unknown +} - GoVersion: runtime.Version(), - Compiler: runtime.Compiler, - Platform: path.Join(runtime.GOOS, runtime.GOARCH), +func getBuildDate(bi *debug.BuildInfo) string { + buildTime := getKey(bi, "vcs.time") + t, err := time.Parse("2006-01-02T15:04:05Z", buildTime) + if err != nil { + return unknown + } + return t.Format("2006-01-02T15:04:05") +} + +func getKey(bi *debug.BuildInfo, key string) string { + if bi == nil { + return unknown + } + for _, iter := range bi.Settings { + if iter.Key == key { + return iter.Value + } } + return unknown +} + +// GetVersionInfo represents known information on how this binary was built. +func GetVersionInfo() Info { + once.Do(func() { + buildInfo := getBuildInfo() + gitVersion = getGitVersion(buildInfo) + if gitCommit == unknown { + gitCommit = getCommit(buildInfo) + } + + if gitTreeState == unknown { + gitTreeState = getDirty(buildInfo) + } + + if buildDate == unknown { + buildDate = getBuildDate(buildInfo) + } + + if goVersion == unknown { + goVersion = runtime.Version() + } + + if compiler == unknown { + compiler = runtime.Compiler + } + + if platform == unknown { + platform = fmt.Sprintf("%s/%s", runtime.GOOS, runtime.GOARCH) + } + + info = Info{ + ASCIIName: asciiName, + GitVersion: gitVersion, + GitCommit: gitCommit, + GitTreeState: gitTreeState, + BuildDate: buildDate, + GoVersion: goVersion, + Compiler: compiler, + Platform: platform, + } + }) + + return info } -func (i Info) String() string { +// String returns the string representation of the version info +func (i *Info) String() string { b := strings.Builder{} w := tabwriter.NewWriter(&b, 0, 0, 2, ' ', 0) - fmt.Fprintf(w, "GitVersion:\t%s\n", i.GitVersion) - fmt.Fprintf(w, "GitCommit:\t%s\n", i.GitCommit) - fmt.Fprintf(w, "BuildDate:\t%s\n", i.BuildDate) - fmt.Fprintf(w, "GoVersion:\t%s\n", i.GoVersion) - fmt.Fprintf(w, "Compiler:\t%s\n", i.Compiler) - fmt.Fprintf(w, "Platform:\t%s\n", i.Platform) + // name and description are optional. + if i.Name != "" { + if i.ASCIIName == "true" { + f := figure.NewFigure(strings.ToUpper(i.Name), i.FontName, true) + _, _ = fmt.Fprint(w, f.String()) + } + _, _ = fmt.Fprint(w, i.Name) + if i.Description != "" { + _, _ = fmt.Fprintf(w, ": %s", i.Description) + } + _, _ = fmt.Fprint(w, "\n\n") + } + + _, _ = fmt.Fprintf(w, "GitVersion:\t%s\n", i.GitVersion) + _, _ = fmt.Fprintf(w, "GitCommit:\t%s\n", i.GitCommit) + _, _ = fmt.Fprintf(w, "GitTreeState:\t%s\n", i.GitTreeState) + _, _ = fmt.Fprintf(w, "BuildDate:\t%s\n", i.BuildDate) + _, _ = fmt.Fprintf(w, "GoVersion:\t%s\n", i.GoVersion) + _, _ = fmt.Fprintf(w, "Compiler:\t%s\n", i.Compiler) + _, _ = fmt.Fprintf(w, "Platform:\t%s\n", i.Platform) - w.Flush() + _ = w.Flush() return b.String() } -func (i Info) JSONString() (string, error) { +// JSONString returns the JSON representation of the version info +func (i *Info) JSONString() (string, error) { b, err := json.MarshalIndent(i, "", " ") if err != nil { return "", err } + return string(b), nil } + +func (i *Info) CheckFontName(fontName string) bool { + assetNames := figure.AssetNames() + + for _, font := range assetNames { + if strings.Contains(font, fontName) { + return true + } + } + + fmt.Fprintln(os.Stderr, "font not valid, using default") + return false +} \ No newline at end of file diff --git a/pkg/artifacts/file/getter/getter_test.go b/pkg/artifacts/file/getter/getter_test.go index e0da7585..e67e7482 100644 --- a/pkg/artifacts/file/getter/getter_test.go +++ b/pkg/artifacts/file/getter/getter_test.go @@ -38,14 +38,14 @@ func TestClient_Detect(t *testing.T) { want: "directory", }, { - name: "should identify a http", + name: "should identify an http fqdn", args: args{ source: "http://my.cool.website", }, want: "http", }, { - name: "should identify a http", + name: "should identify an http fqdn", args: args{ source: "https://my.cool.website", }, diff --git a/pkg/consts/consts.go b/pkg/consts/consts.go index 0263408b..7dd5bb52 100644 --- a/pkg/consts/consts.go +++ b/pkg/consts/consts.go @@ -10,6 +10,7 @@ const ( DockerForeignLayer = "application/vnd.docker.image.rootfs.foreign.diff.tar.gzip" DockerUncompressedLayer = "application/vnd.docker.image.rootfs.diff.tar" OCILayer = "application/vnd.oci.image.layer.v1.tar+gzip" + OCIArtifact = "application/vnd.oci.empty.v1+json" // ChartConfigMediaType is the reserved media type for the Helm chart manifest config ChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json" @@ -28,7 +29,7 @@ const ( FileDirectoryConfigMediaType = "application/vnd.content.hauler.file.directory.config.v1+json" FileHttpConfigMediaType = "application/vnd.content.hauler.file.http.config.v1+json" - // MemoryConfigMediaType + // MemoryConfigMediaType is the reserved media type for Memory config for a generic set of bytes stored in memory MemoryConfigMediaType = "application/vnd.content.hauler.memory.config.v1+json" // WasmArtifactLayerMediaType is the reserved media type for WASM artifact layers @@ -47,4 +48,6 @@ const ( KindAnnotationName = "kind" KindAnnotation = "dev.cosignproject.cosign/image" + + CarbideRegistry = "rgcrprod.azurecr.us" )