Compare commits

..

4 Commits

Author SHA1 Message Date
mudler
c7331207ab ⬆️ Tag 0.34.0 2023-02-02 14:26:26 +01:00
dependabot[bot]
fd698e8554 ⬆️ Bump github.com/opencontainers/runc from 1.1.1 to 1.1.2 (#322)
Bumps [github.com/opencontainers/runc](https://github.com/opencontainers/runc) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/opencontainers/runc/releases)
- [Changelog](https://github.com/opencontainers/runc/blob/main/CHANGELOG.md)
- [Commits](https://github.com/opencontainers/runc/compare/v1.1.1...v1.1.2)

---
updated-dependencies:
- dependency-name: github.com/opencontainers/runc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-02-02 13:37:09 +01:00
Santhosh
d48006af8a unpack local image file with prefix file:// (#318)
Co-authored-by: Ettore Di Giacinto <mudler@users.noreply.github.com>
2023-02-02 11:48:09 +00:00
Ettore Di Giacinto
5ee1ff6d5a ⬆️ Bump to go 1.19 as requirement for building (#319)
* ⬆️ Bump to go 1.19 as requirement for building

Signed-off-by: mudler <mudler@c3os.io>

* ⬆️ Update vendor

* 🤖 Use go 1.19 in CI

* 🤖 Do not pull cover from makefile

Signed-off-by: mudler <mudler@c3os.io>

* 🤖 Fix permission issues

Signed-off-by: mudler <mudler@c3os.io>

* 🤖 Adapt test to getcap output changes

Signed-off-by: mudler <mudler@c3os.io>

---------

Signed-off-by: mudler <mudler@c3os.io>
2023-02-02 11:59:57 +01:00
11 changed files with 47 additions and 25 deletions

View File

@@ -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:

View File

@@ -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

View File

@@ -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
View File

@@ -1,4 +1,5 @@
*.swp *.swp
.idea/
luet luet
tests/integration/shunit2 tests/integration/shunit2
tests/integration/bin tests/integration/bin

View File

@@ -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"
) )

View File

@@ -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
View File

@@ -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
View File

@@ -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=

View File

@@ -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
} }

View File

@@ -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
View File

@@ -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