mirror of
https://github.com/hauler-dev/hauler.git
synced 2026-03-02 01:30:26 +00:00
Compare commits
2 Commits
v0.2.0-rc.
...
v0.2.0-rc.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49eb9e2527 | ||
|
|
83d989ab85 |
1
.github/workflows/ci.yaml
vendored
1
.github/workflows/ci.yaml
vendored
@@ -29,3 +29,4 @@ jobs:
|
||||
args: release --rm-dist
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
|
||||
|
||||
@@ -3,6 +3,10 @@ before:
|
||||
hooks:
|
||||
- go mod tidy
|
||||
- go mod download
|
||||
|
||||
env:
|
||||
- vpkg=github.com/rancherfederal/hauler/pkg/version
|
||||
|
||||
builds:
|
||||
- main: cmd/hauler/main.go
|
||||
goos:
|
||||
@@ -12,6 +16,8 @@ builds:
|
||||
goarch:
|
||||
- amd64
|
||||
- arm64
|
||||
ldflags:
|
||||
- -s -w -X {{ .Env.vpkg }}.GitVersion={{ .Version }} -X {{ .Env.vpkg }}.commit={{ .ShortCommit }} -X {{ .Env.vpkg }}.buildDate={{ .Date }}
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ func New() *cobra.Command {
|
||||
// Add subcommands
|
||||
addDownload(cmd)
|
||||
addStore(cmd)
|
||||
addVersion(cmd)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ func Cmd(ctx context.Context, o *Opts, reference string) error {
|
||||
|
||||
lgr.Infof("downloaded [%s] to [%s]", ref.Name(), outputFile)
|
||||
|
||||
case types.FileMediaType:
|
||||
case types.FileConfigMediaType:
|
||||
lgr.Infof("identified [file] (%s) content", manifest.Config.MediaType)
|
||||
|
||||
fs := content.NewFileStore(o.DestinationDir)
|
||||
|
||||
37
cmd/hauler/cli/version.go
Normal file
37
cmd/hauler/cli/version.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/rancherfederal/hauler/pkg/version"
|
||||
)
|
||||
|
||||
func addVersion(parent *cobra.Command) {
|
||||
var json bool
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print current hauler version",
|
||||
Long: "Print current hauler version",
|
||||
Aliases: []string{"v"},
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
v := version.GetVersionInfo()
|
||||
response := v.String()
|
||||
if json {
|
||||
data, err := v.JSONString()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
response = data
|
||||
}
|
||||
fmt.Print(response)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().BoolVar(&json, "json", false, "toggle output in JSON")
|
||||
|
||||
parent.AddCommand(cmd)
|
||||
}
|
||||
@@ -3,14 +3,10 @@ package types
|
||||
const (
|
||||
OCIManifestSchema1 = "application/vnd.oci.image.manifest.v1+json"
|
||||
DockerManifestSchema2 = "application/vnd.docker.distribution.manifest.v2+json"
|
||||
DockerConfigJSON = "application/vnd.docker.container.image.v1+json"
|
||||
UnknownManifest = "application/vnd.hauler.cattle.io.unknown.v1+json"
|
||||
|
||||
UnknownLayer = "application/vnd.content.hauler.unknown.layer"
|
||||
FileLayerMediaType = "application/vnd.content.hauler.file.layer.v1"
|
||||
FileMediaType = "application/vnd.content.hauler.file.config.v1+json"
|
||||
DockerConfigJSON = "application/vnd.docker.container.image.v1+json"
|
||||
|
||||
// ConfigMediaType is the reserved media type for the Helm chart manifest config
|
||||
// ChartConfigMediaType is the reserved media type for the Helm chart manifest config
|
||||
ChartConfigMediaType = "application/vnd.cncf.helm.config.v1+json"
|
||||
|
||||
// ChartLayerMediaType is the reserved media type for Helm chart package content
|
||||
@@ -19,6 +15,21 @@ const (
|
||||
// ProvLayerMediaType is the reserved media type for Helm chart provenance files
|
||||
ProvLayerMediaType = "application/vnd.cncf.helm.chart.provenance.v1.prov"
|
||||
|
||||
// FileLayerMediaType is the reserved media type for File content layers
|
||||
FileLayerMediaType = "application/vnd.content.hauler.file.layer.v1"
|
||||
|
||||
// FileConfigMediaType is the reserved media type for File config
|
||||
FileConfigMediaType = "application/vnd.content.hauler.file.config.v1+json"
|
||||
|
||||
// WasmArtifactLayerMediaType is the reserved media type for WASM artifact layers
|
||||
WasmArtifactLayerMediaType = "application/vnd.wasm.content.layer.v1+wasm"
|
||||
|
||||
// WasmConfigMediaType is the reserved media type for WASM configs
|
||||
WasmConfigMediaType = "application/vnd.wasm.config.v1+json"
|
||||
|
||||
UnknownManifest = "application/vnd.hauler.cattle.io.unknown.v1+json"
|
||||
UnknownLayer = "application/vnd.content.hauler.unknown.layer"
|
||||
|
||||
OCIVendorPrefix = "vnd.oci"
|
||||
DockerVendorPrefix = "vnd.docker"
|
||||
HaulerVendorPrefix = "vnd.hauler"
|
||||
|
||||
@@ -30,7 +30,7 @@ func (c config) Descriptor() (gv1.Descriptor, error) {
|
||||
}
|
||||
|
||||
return gv1.Descriptor{
|
||||
MediaType: types.FileMediaType,
|
||||
MediaType: types.FileConfigMediaType,
|
||||
Size: c.size,
|
||||
Digest: c.hash,
|
||||
URLs: c.URLs,
|
||||
@@ -47,7 +47,7 @@ func (c config) Digest() (gv1.Hash, error) {
|
||||
}
|
||||
|
||||
func (c config) MediaType() (gtypes.MediaType, error) {
|
||||
return types.FileMediaType, nil
|
||||
return types.FileConfigMediaType, nil
|
||||
}
|
||||
|
||||
func (c config) Size() (int64, error) {
|
||||
|
||||
61
pkg/version/version.go
Normal file
61
pkg/version/version.go
Normal file
@@ -0,0 +1,61 @@
|
||||
package version
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
)
|
||||
|
||||
var (
|
||||
GitVersion = "devel"
|
||||
commit = "unknown"
|
||||
buildDate = "unknown"
|
||||
)
|
||||
|
||||
type Info struct {
|
||||
GitVersion string
|
||||
GitCommit string
|
||||
BuildDate string
|
||||
|
||||
GoVersion string
|
||||
Compiler string
|
||||
Platform string
|
||||
}
|
||||
|
||||
func GetVersionInfo() Info {
|
||||
return Info{
|
||||
GitVersion: GitVersion,
|
||||
GitCommit: commit,
|
||||
BuildDate: buildDate,
|
||||
|
||||
GoVersion: runtime.Version(),
|
||||
Compiler: runtime.Compiler,
|
||||
Platform: path.Join(runtime.GOOS, runtime.GOARCH),
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
w.Flush()
|
||||
return b.String()
|
||||
}
|
||||
|
||||
func (i Info) JSONString() (string, error) {
|
||||
b, err := json.MarshalIndent(i, "", " ")
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return string(b), nil
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
IMAGE_NAME="$1"
|
||||
SAVE_DIR="$2"
|
||||
|
||||
if [ -z "${IMAGE_NAME}" ]; then
|
||||
echo "[Usage] ./save-docker-image.sh <image_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
SAVE_DIR="."
|
||||
|
||||
fi
|
||||
|
||||
echo "Creating ${IMAGE_NAME} backup..."
|
||||
#docker save ${IMAGE_NAME} | gzip --stdout > ${SAVE_DIR}/${IMAGE_NAME}.tgz
|
||||
docker save ${IMAGE_NAME} > ${IMAGE_NAME}.tar
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
IMAGE_NAME="$1"
|
||||
SAVE_DIR="$2"
|
||||
|
||||
if [ -z "${IMAGE_NAME}" ]; then
|
||||
echo "[Usage] ./save-docker-image.sh <image_name>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
SAVE_DIR="."
|
||||
|
||||
fi
|
||||
|
||||
echo "Creating ${IMAGE_NAME} backup..."
|
||||
docker save ${IMAGE_NAME} | gzip --stdout > ${SAVE_DIR}/${IMAGE_NAME}.tgz
|
||||
@@ -1,25 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
K3S_RELEASE="v1.18.8-rc1%2Bk3s1"
|
||||
|
||||
SAVE_DIR="$1"
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
SAVE_DIR="."
|
||||
fi
|
||||
|
||||
# k3s - arm64
|
||||
wget -P ${SAVE_DIR} https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s-arm64
|
||||
|
||||
# k3s - amd64
|
||||
wget -P ${SAVE_DIR} https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s
|
||||
|
||||
# images - amd64
|
||||
wget -P ${SAVE_DIR} https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s-airgap-images-amd64.tar
|
||||
|
||||
# images - arm64
|
||||
wget -P ${SAVE_DIR} https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s-airgap-images-arm64.tar
|
||||
|
||||
# images.txt
|
||||
wget -P ${SAVE_DIR} https://github.com/rancher/k3s/releases/download/${K3S_VERSION}/k3s-images.txt
|
||||
|
||||
Reference in New Issue
Block a user