mirror of
https://github.com/mudler/luet.git
synced 2025-09-17 15:52:15 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
c7331207ab | ||
|
fd698e8554 | ||
|
d48006af8a | ||
|
5ee1ff6d5a |
6
.github/workflows/pr.yml
vendored
6
.github/workflows/pr.yml
vendored
@@ -5,7 +5,7 @@ jobs:
|
|||||||
tests-integration-img:
|
tests-integration-img:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.18.x]
|
go-version: [1.19.x]
|
||||||
platform: [ubuntu-latest]
|
platform: [ubuntu-latest]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
tests-integration:
|
tests-integration:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.18.x]
|
go-version: [1.19.x]
|
||||||
platform: [ubuntu-latest]
|
platform: [ubuntu-latest]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
@@ -48,7 +48,7 @@ jobs:
|
|||||||
tests-unit:
|
tests-unit:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.18.x]
|
go-version: [1.19.x]
|
||||||
platform: [ubuntu-latest]
|
platform: [ubuntu-latest]
|
||||||
runs-on: ${{ matrix.platform }}
|
runs-on: ${{ matrix.platform }}
|
||||||
steps:
|
steps:
|
||||||
|
6
.github/workflows/push.yml
vendored
6
.github/workflows/push.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Login to quay
|
- name: Login to quay
|
||||||
@@ -35,7 +35,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Login to quay
|
- name: Login to quay
|
||||||
@@ -59,7 +59,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: Login to quay
|
- name: Login to quay
|
||||||
|
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -14,7 +14,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: setup-docker
|
- name: setup-docker
|
||||||
@@ -40,7 +40,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: setup-docker
|
- name: setup-docker
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
- name: setup-docker
|
- name: setup-docker
|
||||||
@@ -101,7 +101,7 @@ jobs:
|
|||||||
- name: Install Go
|
- name: Install Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.18.x
|
go-version: 1.19.x
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
*.swp
|
*.swp
|
||||||
|
.idea/
|
||||||
luet
|
luet
|
||||||
tests/integration/shunit2
|
tests/integration/shunit2
|
||||||
tests/integration/bin
|
tests/integration/bin
|
||||||
|
@@ -30,7 +30,7 @@ var cfgFile string
|
|||||||
var Verbose bool
|
var Verbose bool
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LuetCLIVersion = "0.33.0"
|
LuetCLIVersion = "0.34.0"
|
||||||
LuetEnvPrefix = "LUET"
|
LuetEnvPrefix = "LUET"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
@@ -34,6 +35,10 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
filePrefix = "file://"
|
||||||
|
)
|
||||||
|
|
||||||
func pack(ctx *context.Context, p, dst, imageName, arch, OS string) error {
|
func pack(ctx *context.Context, p, dst, imageName, arch, OS string) error {
|
||||||
|
|
||||||
tempimage, err := ctx.TempFile("tempimage")
|
tempimage, err := ctx.TempFile("tempimage")
|
||||||
@@ -126,7 +131,7 @@ func NewUnpackCommand() *cobra.Command {
|
|||||||
RegistryToken: registryToken,
|
RegistryToken: registryToken,
|
||||||
}
|
}
|
||||||
|
|
||||||
if !local {
|
if !local && !strings.HasPrefix(image, filePrefix) {
|
||||||
info, err := docker.DownloadAndExtractDockerImage(util.DefaultContext, image, destination, auth, verify)
|
info, err := docker.DownloadAndExtractDockerImage(util.DefaultContext, image, destination, auth, verify)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
util.DefaultContext.Error(err.Error())
|
util.DefaultContext.Error(err.Error())
|
||||||
|
4
go.mod
4
go.mod
@@ -1,6 +1,6 @@
|
|||||||
module github.com/mudler/luet
|
module github.com/mudler/luet
|
||||||
|
|
||||||
go 1.18
|
go 1.19
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Masterminds/sprig/v3 v3.2.1
|
github.com/Masterminds/sprig/v3 v3.2.1
|
||||||
@@ -102,7 +102,7 @@ require (
|
|||||||
github.com/moby/sys/mountinfo v0.6.0 // indirect
|
github.com/moby/sys/mountinfo v0.6.0 // indirect
|
||||||
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
|
||||||
github.com/morikuni/aec v1.0.0 // indirect
|
github.com/morikuni/aec v1.0.0 // indirect
|
||||||
github.com/opencontainers/runc v1.1.1 // indirect
|
github.com/opencontainers/runc v1.1.2 // indirect
|
||||||
github.com/prometheus/client_golang v1.12.1 // indirect
|
github.com/prometheus/client_golang v1.12.1 // indirect
|
||||||
github.com/prometheus/client_model v0.2.0 // indirect
|
github.com/prometheus/client_model v0.2.0 // indirect
|
||||||
github.com/prometheus/common v0.32.1 // indirect
|
github.com/prometheus/common v0.32.1 // indirect
|
||||||
|
4
go.sum
4
go.sum
@@ -788,8 +788,8 @@ github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h
|
|||||||
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
github.com/opencontainers/runc v1.0.0-rc9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
|
||||||
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
|
github.com/opencontainers/runc v1.0.0-rc93/go.mod h1:3NOsor4w32B2tC0Zbl8Knk4Wg84SM2ImC1fxBuqJ/H0=
|
||||||
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
|
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
|
||||||
github.com/opencontainers/runc v1.1.1 h1:PJ9DSs2sVwE0iVr++pAHE6QkS9tzcVWozlPifdwMgrU=
|
github.com/opencontainers/runc v1.1.2 h1:2VSZwLx5k/BfsBxMMipG/LYUnmqOD/BPkIVgQUcTlLw=
|
||||||
github.com/opencontainers/runc v1.1.1/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc=
|
github.com/opencontainers/runc v1.1.2/go.mod h1:Tj1hFw6eFWp/o33uxGf5yF2BX5yz2Z6iptFpuvbbKqc=
|
||||||
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
github.com/opencontainers/runtime-spec v0.1.2-0.20190507144316-5b71a03e2700/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||||
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||||
github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
github.com/opencontainers/runtime-spec v1.0.2-0.20190207185410-29686dbc5559/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
|
||||||
|
@@ -20,6 +20,10 @@ import (
|
|||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
v1 "github.com/google/go-containerregistry/pkg/v1"
|
||||||
|
"github.com/google/go-containerregistry/pkg/v1/tarball"
|
||||||
|
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
luetimages "github.com/mudler/luet/pkg/api/core/image"
|
luetimages "github.com/mudler/luet/pkg/api/core/image"
|
||||||
@@ -42,6 +46,11 @@ import (
|
|||||||
"github.com/theupdateframework/notary/tuf/data"
|
"github.com/theupdateframework/notary/tuf/data"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
filePrefix = "file://"
|
||||||
|
fileImageSeparator = ":/"
|
||||||
|
)
|
||||||
|
|
||||||
// See also https://github.com/docker/cli/blob/88c6089300a82d3373892adf6845a4fed1a4ba8d/cli/command/image/trust.go#L171
|
// See also https://github.com/docker/cli/blob/88c6089300a82d3373892adf6845a4fed1a4ba8d/cli/command/image/trust.go#L171
|
||||||
|
|
||||||
func verifyImage(image string, authConfig *types.AuthConfig) (string, error) {
|
func verifyImage(image string, authConfig *types.AuthConfig) (string, error) {
|
||||||
@@ -196,18 +205,26 @@ func DownloadAndExtractDockerImage(ctx luettypes.Context, image, dest string, au
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ExtractDockerImage(ctx luettypes.Context, local, dest string) (*images.Image, error) {
|
func ExtractDockerImage(ctx luettypes.Context, local, dest string) (*images.Image, error) {
|
||||||
|
var img v1.Image
|
||||||
if !fileHelper.Exists(dest) {
|
if !fileHelper.Exists(dest) {
|
||||||
if err := os.MkdirAll(dest, os.ModePerm); err != nil {
|
if err := os.MkdirAll(dest, os.ModePerm); err != nil {
|
||||||
return nil, errors.Wrapf(err, "cannot create destination directory")
|
return nil, errors.Wrapf(err, "cannot create destination directory")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ref, err := name.ParseReference(local)
|
var err error
|
||||||
if err != nil {
|
if strings.HasPrefix(local, filePrefix) {
|
||||||
return nil, err
|
parts := strings.Split(local, fileImageSeparator)
|
||||||
|
if len(parts) == 2 && parts[1] != "" {
|
||||||
|
img, err = tarball.ImageFromPath(parts[1], nil)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ref, err := name.ParseReference(local)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
img, err = daemon.Image(ref)
|
||||||
}
|
}
|
||||||
|
|
||||||
img, err := daemon.Image(ref)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@@ -62,9 +62,8 @@ testInstall() {
|
|||||||
|
|
||||||
assertTrue 'package installed file1' "[ -e '$tmpdir/testrootfs/file1' ]"
|
assertTrue 'package installed file1' "[ -e '$tmpdir/testrootfs/file1' ]"
|
||||||
assertTrue 'package installed file2' "[ -e '$tmpdir/testrootfs/file2' ]"
|
assertTrue 'package installed file2' "[ -e '$tmpdir/testrootfs/file2' ]"
|
||||||
|
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file1)" "cap_net_raw=ep"
|
||||||
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file1)" "cap_net_raw+ep"
|
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file2)" "cap_net_raw=ep"
|
||||||
assertContains 'caps' "$(getcap $tmpdir/testrootfs/file2)" "cap_net_raw+ep"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@@ -403,7 +403,7 @@ github.com/opencontainers/go-digest
|
|||||||
## explicit
|
## explicit
|
||||||
github.com/opencontainers/image-spec/specs-go
|
github.com/opencontainers/image-spec/specs-go
|
||||||
github.com/opencontainers/image-spec/specs-go/v1
|
github.com/opencontainers/image-spec/specs-go/v1
|
||||||
# github.com/opencontainers/runc v1.1.1
|
# github.com/opencontainers/runc v1.1.2
|
||||||
## explicit; go 1.16
|
## explicit; go 1.16
|
||||||
github.com/opencontainers/runc/libcontainer/user
|
github.com/opencontainers/runc/libcontainer/user
|
||||||
# github.com/otiai10/copy v1.2.1-0.20200916181228-26f84a0b1578
|
# github.com/otiai10/copy v1.2.1-0.20200916181228-26f84a0b1578
|
||||||
|
Reference in New Issue
Block a user