Skip to content

Commit

Permalink
integrate buildah
Browse files Browse the repository at this point in the history
Signed-off-by: david.bao <[email protected]>
  • Loading branch information
justadogistaken committed Aug 11, 2022
1 parent cef62a5 commit 8983c23
Show file tree
Hide file tree
Showing 2,621 changed files with 342,458 additions and 18,730 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/e2e-test-apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
repository: ${{fromJson(steps.request.outputs.data).head.repo.full_name}}
ref: ${{fromJson(steps.request.outputs.data).head.ref}}
path: src/github.com/sealerio/sealer

- name: Install deps
run: |
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Set up Go 1.16
uses: actions/setup-go@v2
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
repository: ${{fromJson(steps.request.outputs.data).head.repo.full_name}}
ref: ${{fromJson(steps.request.outputs.data).head.ref}}
path: src/github.com/sealerio/sealer

- name: Install deps
run: |
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Set up Go 1.16
uses: actions/setup-go@v1
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-test-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
repository: ${{fromJson(steps.request.outputs.data).head.repo.full_name}}
ref: ${{fromJson(steps.request.outputs.data).head.ref}}
path: src/github.com/sealerio/sealer

- name: Install deps
run: |
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Set up Go 1.16
uses: actions/setup-go@v1
with:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/e2e-test-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ jobs:
repository: ${{fromJson(steps.request.outputs.data).head.repo.full_name}}
ref: ${{fromJson(steps.request.outputs.data).head.ref}}
path: src/github.com/sealerio/sealer

- name: Install deps
run: |
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Set up Go 1.16
uses: actions/setup-go@v1
with:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
branches: "*"
paths-ignore:
- 'docs/**'
- 'vendor/**'
- '*.md'
- '*.yml'
jobs:
Expand All @@ -17,7 +16,9 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: Install deps
run: |
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- name: Set up Go
uses: actions/setup-go@v2
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Install deps
run: |
sudo apt-get install -y libgpgme-dev libbtrfs-dev libdevmapper-dev
- uses: actions/setup-go@v2
with:
go-version: '1.16'
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ Here are some dependents with specific version:

* golang : v1.14
* golangci-lint: 1.39.0
* gpname(brew install gpgme)

When you develop the Sealer project at the local environment, you should use subcommands of Makefile to help yourself to check and build the latest version of Sealer. For the convenience of developers, we use the docker to build Sealer. It can reduce problems of the developing environment.

Expand Down
31 changes: 12 additions & 19 deletions apply/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ package apply

import (
"fmt"

"os"
"path/filepath"

"github.com/sealerio/sealer/pkg/imageengine"
common2 "github.com/sealerio/sealer/pkg/imageengine/common"

"github.com/sealerio/sealer/apply/driver"
"github.com/sealerio/sealer/common"
"github.com/sealerio/sealer/pkg/clusterfile"
"github.com/sealerio/sealer/pkg/filesystem"
"github.com/sealerio/sealer/pkg/image"
"github.com/sealerio/sealer/pkg/image/store"
v2 "github.com/sealerio/sealer/types/api/v2"
)

Expand Down Expand Up @@ -57,24 +59,22 @@ func NewApplierFromFile(path string) (driver.Interface, error) {
}
path = filepath.Join(pa, path)
}

Clusterfile, err := clusterfile.NewClusterFile(path)
if err != nil {
return nil, err
}
imgSvc, err := image.NewImageService()
if err != nil {
return nil, err
}

mounter, err := filesystem.NewClusterImageMounter()
imageEngine, err := imageengine.NewImageEngine(common2.EngineGlobalConfigurations{})
if err != nil {
return nil, err
}

is, err := store.NewDefaultImageStore()
mounter, err := filesystem.NewClusterImageMounter(imageEngine)
if err != nil {
return nil, err
}

cluster := Clusterfile.GetCluster()
if cluster.Name == "" {
return nil, fmt.Errorf("cluster name cannot be empty, make sure %s file is correct", path)
Expand All @@ -85,9 +85,8 @@ func NewApplierFromFile(path string) (driver.Interface, error) {
return &driver.Applier{
ClusterDesired: &cluster,
ClusterFile: Clusterfile,
ImageManager: imgSvc,
ImageEngine: imageEngine,
ClusterImageMounter: mounter,
ImageStore: is,
}, nil
}

Expand All @@ -102,25 +101,19 @@ func NewDefaultApplier(cluster *v2.Cluster) (driver.Interface, error) {
if cluster.Name == "" {
return nil, fmt.Errorf("cluster name cannot be empty")
}
imgSvc, err := image.NewImageService()
if err != nil {
return nil, err
}

mounter, err := filesystem.NewClusterImageMounter()
imageEngine, err := imageengine.NewImageEngine(common2.EngineGlobalConfigurations{})
if err != nil {
return nil, err
}

is, err := store.NewDefaultImageStore()
mounter, err := filesystem.NewClusterImageMounter(imageEngine)
if err != nil {
return nil, err
}

return &driver.Applier{
ClusterDesired: cluster,
ImageManager: imgSvc,
ImageEngine: imageEngine,
ClusterImageMounter: mounter,
ImageStore: is,
}, nil
}
51 changes: 35 additions & 16 deletions apply/driver/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import (
"fmt"
"net"

"github.com/sealerio/sealer/pkg/auth"
"github.com/sealerio/sealer/pkg/imageengine"

"github.com/sealerio/sealer/apply/processor"
"github.com/sealerio/sealer/common"
"github.com/sealerio/sealer/pkg/client/k8s"
"github.com/sealerio/sealer/pkg/clusterfile"
"github.com/sealerio/sealer/pkg/filesystem/clusterimage"
"github.com/sealerio/sealer/pkg/image"
"github.com/sealerio/sealer/pkg/image/store"
"github.com/sealerio/sealer/pkg/runtime"
"github.com/sealerio/sealer/pkg/runtime/kubernetes"
v1 "github.com/sealerio/sealer/types/api/v1"
v2 "github.com/sealerio/sealer/types/api/v2"
"github.com/sealerio/sealer/utils"
osi "github.com/sealerio/sealer/utils/os"
Expand All @@ -36,6 +36,7 @@ import (
"github.com/sealerio/sealer/utils/strings"

"github.com/pkg/errors"
imagecommon "github.com/sealerio/sealer/pkg/imageengine/common"
"github.com/sirupsen/logrus"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/version"
Expand All @@ -46,10 +47,9 @@ type Applier struct {
ClusterDesired *v2.Cluster
ClusterCurrent *v2.Cluster
ClusterFile clusterfile.Interface
ImageManager image.Service
ImageEngine imageengine.Interface
ClusterImageMounter clusterimage.Interface
Client *k8s.Client
ImageStore store.ImageStore
CurrentClusterInfo *version.Info
}

Expand Down Expand Up @@ -99,15 +99,33 @@ func (c *Applier) mountClusterImage() error {
if err != nil {
return err
}
plats := []*v1.Platform{platform.GetDefaultPlatform()}

platVisit := map[string]struct{}{}
platVisit[platform.GetDefaultPlatform().ToString()] = struct{}{}
for _, v := range platsMap {
plat := v
plats = append(plats, &plat)
platVisit[v.ToString()] = struct{}{}
}
err = c.ImageManager.PullIfNotExist(imageName, plats)
if err != nil {
return err

plats := []string{}
for k := range platVisit {
plats = append(plats, k)
}
// TODO optimize image engine caller.
for _, plat := range plats {
err = c.ImageEngine.Pull(&imagecommon.PullOptions{
Authfile: auth.GetDefaultAuthFilePath(),
Quiet: false,
TLSVerify: true,
PullPolicy: "missing",
Image: imageName,
Platform: plat,
})

if err != nil {
return err
}
}

err = c.ClusterImageMounter.MountImage(c.ClusterDesired)
if err != nil {
return err
Expand Down Expand Up @@ -143,13 +161,14 @@ func (c *Applier) reconcileCluster() error {
logrus.Warnf("failed to umount image(%s): %v", c.ClusterDesired.ClusterName, err)
}
}()

baseImage, err := c.ImageStore.GetByName(c.ClusterDesired.Spec.Image, platform.GetDefaultPlatform())
image := c.ClusterDesired.Spec.Image
// TODO
imageExtension, err := c.ImageEngine.GetSealerImageExtension(&imagecommon.GetImageAnnoOptions{ImageNameOrID: image})
if err != nil {
return fmt.Errorf("failed to get base image(%s): %v", baseImage.Name, err)
return err
}
// if no rootfs ,try to install applications.
if baseImage.Spec.ImageConfig.ImageType == common.AppImage {

if imageExtension.ImageType == common.AppImage {
return c.installApp()
}

Expand Down
39 changes: 28 additions & 11 deletions apply/processor/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,19 @@ package processor
import (
"fmt"

"github.com/sealerio/sealer/pkg/auth"
"github.com/sealerio/sealer/pkg/imageengine"
imagecommon "github.com/sealerio/sealer/pkg/imageengine/common"
"github.com/sealerio/sealer/pkg/registry"

"github.com/sealerio/sealer/pkg/clusterfile"
"github.com/sealerio/sealer/pkg/config"
"github.com/sealerio/sealer/pkg/filesystem"
"github.com/sealerio/sealer/pkg/filesystem/clusterimage"
"github.com/sealerio/sealer/pkg/guest"
"github.com/sealerio/sealer/pkg/image"
"github.com/sealerio/sealer/pkg/plugin"
"github.com/sealerio/sealer/pkg/runtime"
"github.com/sealerio/sealer/pkg/runtime/kubernetes"
v1 "github.com/sealerio/sealer/types/api/v1"
v2 "github.com/sealerio/sealer/types/api/v2"
"github.com/sealerio/sealer/utils/net"
"github.com/sealerio/sealer/utils/platform"
Expand All @@ -37,12 +38,12 @@ import (

type CreateProcessor struct {
ClusterFile clusterfile.Interface
ImageManager image.Service
cloudImageMounter clusterimage.Interface
Runtime runtime.Interface
Guest guest.Interface
Config config.Interface
Plugins plugin.Plugins
ImageEngine imageengine.Interface
}

func (c *CreateProcessor) GetPipeLine() ([]func(cluster *v2.Cluster) error, error) {
Expand Down Expand Up @@ -82,14 +83,30 @@ func (c *CreateProcessor) MountImage(cluster *v2.Cluster) error {
if err != nil {
return err
}
plats := []*v1.Platform{platform.GetDefaultPlatform()}

platVisit := map[string]struct{}{}
platVisit[platform.GetDefaultPlatform().ToString()] = struct{}{}
for _, v := range platsMap {
plat := v
plats = append(plats, &plat)
platVisit[v.ToString()] = struct{}{}
}
if err = c.ImageManager.PullIfNotExist(cluster.Spec.Image, plats); err != nil {
return err

plats := []string{}
for k := range platVisit {
plats = append(plats, k)
}
for _, plat := range plats {
if err = c.ImageEngine.Pull(&imagecommon.PullOptions{
Authfile: auth.GetDefaultAuthFilePath(),
Quiet: false,
TLSVerify: true,
PullPolicy: "missing",
Image: cluster.Spec.Image,
Platform: plat,
}); err != nil {
return err
}
}

if err = c.cloudImageMounter.MountImage(cluster); err != nil {
return err
}
Expand Down Expand Up @@ -153,12 +170,12 @@ func (c *CreateProcessor) GetPhasePluginFunc(phase plugin.Phase) func(cluster *v
}

func NewCreateProcessor(clusterFile clusterfile.Interface) (Processor, error) {
imgSvc, err := image.NewImageService()
imageEngine, err := imageengine.NewImageEngine(imagecommon.EngineGlobalConfigurations{})
if err != nil {
return nil, err
}

mounter, err := filesystem.NewClusterImageMounter()
mounter, err := filesystem.NewClusterImageMounter(imageEngine)
if err != nil {
return nil, err
}
Expand All @@ -170,7 +187,7 @@ func NewCreateProcessor(clusterFile clusterfile.Interface) (Processor, error) {

return &CreateProcessor{
ClusterFile: clusterFile,
ImageManager: imgSvc,
ImageEngine: imageEngine,
cloudImageMounter: mounter,
Guest: gs,
}, nil
Expand Down
9 changes: 8 additions & 1 deletion apply/processor/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package processor

import (
"fmt"
"github.com/sealerio/sealer/pkg/imageengine"
common2 "github.com/sealerio/sealer/pkg/imageengine/common"

"github.com/sealerio/sealer/pkg/registry"

Expand Down Expand Up @@ -93,7 +95,12 @@ func (d *DeleteProcessor) CleanFS(cluster *v2.Cluster) error {
}

func NewDeleteProcessor(clusterFile clusterfile.Interface) (Processor, error) {
mounter, err := filesystem.NewClusterImageMounter()
imageEngine, err := imageengine.NewImageEngine(common2.EngineGlobalConfigurations{})
if err != nil {
return nil, err
}

mounter, err := filesystem.NewClusterImageMounter(imageEngine)
if err != nil {
return nil, err
}
Expand Down
Loading

0 comments on commit 8983c23

Please sign in to comment.