Skip to content

Commit 1d7040b

Browse files
Oci export (#2)
* oci-export: Release pipeline handlers added * Rootfs syncer added * Dir creation added * oci-export: tmp files added * oci-export: Target fix * fiX * oci-export: fix dir * oci-export: fix command usage * oci-export: cmd args adjs * oci-export: fix dir * oci-export: fix empty dir issue * oci-export: fix logs * oci-export: done * oci-export: remove redundant code blocks * oci-export: Parse file paramter moved to dynamic
1 parent 6f7873e commit 1d7040b

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

.github/workflows/release.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Firecracker RootFS
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
build:
10+
name: GoReleaser build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Check out code into the Go module directory
14+
uses: actions/checkout@v2
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Set up Go 1.24.1
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.24.1
22+
id: go
23+
24+
- name: Run GoReleaser
25+
uses: goreleaser/goreleaser-action@master
26+
with:
27+
version: latest
28+
args: release --config=build/.goreleaser.yaml
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.FIRECRACKER_ROOTFS_RELEASE_TOKEN }}

build/.gorelease.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
builds:
2+
- main: ./
3+
binary: ./bin/ofs
4+
flags:
5+
- -trimpath
6+
env:
7+
- CGO_ENABLED=0
8+
- GO111MODULE=auto
9+
targets:
10+
- darwin_amd64
11+
- darwin_arm64
12+
- linux_amd64
13+
- linux_arm64
14+
- windows_amd64

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010

1111
var (
1212
configFile string
13+
rootFsName string
14+
rootFsSize int64
1315
)
1416

1517
func newBuildClient() src.Builder {
@@ -34,12 +36,12 @@ func HandleRootFS() {
3436
log.Err(err).Msg("Error while running parserCli.ParseYamlFile()")
3537
}
3638

37-
err = rootFsClient.CreateFileDD(10, "ops")
39+
err = rootFsClient.CreateFileDD(rootFsSize, rootFsName)
3840
if err != nil {
3941
log.Err(err).Msg("Error while running rootFsClient.CreateFileDD()")
4042
}
4143

42-
fsErr := rootFsClient.FormatandMountFileSystem("ops", result.TargetDirectory)
44+
fsErr := rootFsClient.FormatandMountFileSystem(rootFsName, result.TargetDirectory)
4345
if fsErr != nil {
4446
log.Err(fsErr).Msg("Error while running rootFsClient.FormatFileSystem()")
4547
}
@@ -60,6 +62,8 @@ func main() {
6062
},
6163
}
6264
rootCmd.Flags().StringVarP(&configFile, "config", "C", "config.yaml", "Config file of RootFS creation")
65+
rootCmd.Flags().StringVarP(&rootFsName, "filesystem-name", "F", "rootfs", "Name of rootfs")
66+
rootCmd.Flags().Int64VarP(&rootFsSize, "filesystem-size", "S", 10, "Size of rootfs")
6367

6468
rootCmd.MarkFlagRequired("config")
6569

src/parser.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type ParseHandler struct{}
2323

2424
func (parser *ParseHandler) ParseYamlFile(configFile string) (RootFSManifest, error) {
2525
var config RootFSManifest
26-
data, err := os.ReadFile("config.yaml")
26+
data, err := os.ReadFile(configFile)
2727

2828
if err != nil {
2929
log.Err(err).Msg("Error reading YAML file:")

src/rootfs.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@ type RootFS interface {
1515
type RootFSHandler struct{}
1616

1717
func (rootfs *RootFSHandler) FormatandMountFileSystem(path, targetDirectory string) error {
18-
cmd := exec.Command("mkfs.ext4", path)
18+
19+
cmd := exec.Command("mkdir", "-p", targetDirectory)
1920
output, err := cmd.CombinedOutput()
21+
if err != nil {
22+
log.Err(err).Msg("Error while running mkdir")
23+
log.Info().Msgf("Mkdir exec output: %s", string(output))
24+
return err
25+
}
26+
27+
cmd = exec.Command("mkfs.ext4", path)
28+
output, err = cmd.CombinedOutput()
2029
if err != nil {
2130
log.Err(err).Msg("Error running mkfs.ext4:")
2231
log.Info().Msgf("Output: %s", string(output))

0 commit comments

Comments
 (0)