Skip to content

Commit

Permalink
feat!: Bump Kraftkit to version 0.7.0 (#21)
Browse files Browse the repository at this point in the history
Approved-by: Alexander Jung <[email protected]>
  • Loading branch information
nderjung committed Nov 22, 2023
2 parents ecd3c62 + 19860f3 commit 5af4010
Show file tree
Hide file tree
Showing 29 changed files with 1,137 additions and 948 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "monthly"
4 changes: 1 addition & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ jobs:

- name: Update packages
run: |
apt-get install -y --no-install-recommends \
jq \
libgit2-dev
apt-get install -y --no-install-recommends jq
- name: Fetch all tags
run: |
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

2 changes: 1 addition & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ HASHICORP_PACKER_PLUGIN_SDK_VERSION?=$(shell go list -m github.com/hashicorp/pac
CMAKE ?= cmake
WORKDIR ?= $(CURDIR)
VENDORDIR ?= $(WORKDIR)/third_party
GO_VERSION ?= 1.20
GO_VERSION ?= 1.21

.PHONY: dev

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ Starting from version 1.7, Packer supports a new `packer init` command allowing
automatic installation of Packer plugins. Read the
[Packer documentation](https://www.packer.io/docs/commands/init) for more information.

To install this plugin, copy and paste this code into your Packer configuration .
To install this plugin, copy and paste this code into your Packer configuration.
Then, run [`packer init`](https://www.packer.io/docs/commands/init).

```hcl
packer {
required_plugins {
unikraft = {
version = ">= 0.1.1"
version = ">= 0.2.0"
source = "github.com/unikraft/unikraft"
}
}
Expand Down
2 changes: 1 addition & 1 deletion builder/unikraft/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
driver := &KraftDriver{
Ctx: &b.config.ctx,
Ui: ui,
CommandContext: KraftCommandContext(),
CommandContext: KraftCommandContext(ui, b.config.LogLevel),
}

steps := []multistep.Step{
Expand Down
8 changes: 2 additions & 6 deletions builder/unikraft/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 2 additions & 11 deletions builder/unikraft/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ type Config struct {
Force bool `mapstructure:"force"`
// The name of the image to build.
Target string `mapstructure:"target"`
// Max number of jobs to run in parallel.
Jobs int `mapstructure:"jobs"`
// Build jobs in parallel.
Fast bool `mapstructure:"fast"`

// The path to the build directory. This is required.
Path string `mapstructure:"build_path" required:"true"`
// The path to the pull source.
Expand All @@ -40,8 +35,8 @@ type Config struct {
SourcesNoDefault bool `mapstructure:"sources_no_default"`
// Set of options to set.
Options string `mapstructure:"options"`
// Keep the specification of the build.
KeepConfig bool `mapstructure:"keep_config"`
// Log level to use.
LogLevel string `mapstructure:"log_level"`

ctx interpolate.Context
}
Expand Down Expand Up @@ -73,10 +68,6 @@ func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("platform must be specified"))
}

if c.Jobs < 1 {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("jobs must be greater than 0"))
}

if c.Path == "" {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("build_path must be specified"))
}
Expand Down
6 changes: 3 additions & 3 deletions builder/unikraft/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ package unikraft
// Kraft. The Driver interface also allows the steps to be tested since
// a mock driver can be shimmed in.
type Driver interface {
Build(path, architecture, platform string, fast bool) error
Build(path, architecture, platform, target string) error

Pkg(architecture, platform, pkgType, pkgName, workdir string) error
Pkg(architecture, platform, target, pkgName, rootfs, workdir string, push bool) error

ProperClean(path string) error
Clean(path string) error

Pull(source, workdir string) error

Expand Down
28 changes: 18 additions & 10 deletions builder/unikraft/driver_kraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,36 @@ type KraftDriver struct {
CommandContext context.Context
}

func (d *KraftDriver) Build(path, architecture, platform string, fast bool) error {
func (d *KraftDriver) Build(path, architecture, platform, target string) error {
c := Build{
Architecture: architecture,
Platform: platform,
Fast: fast,
Target: target,
NoCache: true,
NoUpdate: true,
}
return c.BuildCmd(d.CommandContext, []string{path})
return c.BuildCmd(d.CommandContext, path)
}

func (d *KraftDriver) Pkg(architecture, platform, pkgType, pkgName, workdir string) error {
func (d *KraftDriver) Pkg(architecture, platform, target, pkgName, workdir, rootfs string, push bool) error {
c := Pkg{
Architecture: architecture,
Platform: platform,
Format: pkgType,
Target: target,
Format: "oci",
Name: pkgName,
Push: push,
Rootfs: rootfs,
}

return c.PkgCmd(d.CommandContext, []string{workdir})
_, err := c.PackCmd(d.CommandContext, workdir)
return err
}

func (d *KraftDriver) ProperClean(path string) error {
c := ProperClean{}
func (d *KraftDriver) Clean(path string) error {
c := Clean{}

return c.ProperCleanCmd(d.CommandContext, []string{path})
return c.CleanCmd(d.CommandContext, []string{path})
}

func (d *KraftDriver) Pull(source, workdir string) error {
Expand All @@ -61,7 +67,9 @@ func (d *KraftDriver) Set(options map[string]string) error {
}

func (d *KraftDriver) Source(source string) error {
c := Source{}
c := Source{
Force: false,
}

return c.SourceCmd(d.CommandContext, []string{source})
}
Expand Down
Loading

0 comments on commit 5af4010

Please sign in to comment.