mirror of
https://github.com/kairos-io/kcrypt.git
synced 2025-11-05 12:39:33 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d077c9353 | ||
|
|
0e278a89f0 | ||
|
|
7310c313ee | ||
|
|
b9572125e1 |
@@ -6,9 +6,11 @@ ARG BASE_IMAGE=quay.io/kairos/core-opensuse
|
|||||||
|
|
||||||
build-kcrypt:
|
build-kcrypt:
|
||||||
FROM golang:alpine
|
FROM golang:alpine
|
||||||
|
RUN apk add git
|
||||||
COPY . /work
|
COPY . /work
|
||||||
WORKDIR /work
|
WORKDIR /work
|
||||||
RUN CGO_ENABLED=0 go build -o kcrypt
|
ARG VERSION="$(git describe --tags)"
|
||||||
|
RUN CGO_ENABLED=0 go build -o kcrypt -ldflags "-X main.Version=$VERSION"
|
||||||
SAVE ARTIFACT /work/kcrypt AS LOCAL kcrypt
|
SAVE ARTIFACT /work/kcrypt AS LOCAL kcrypt
|
||||||
|
|
||||||
build-dracut:
|
build-dracut:
|
||||||
|
|||||||
10
main.go
10
main.go
@@ -21,6 +21,8 @@ import (
|
|||||||
pi "github.com/kairos-io/kcrypt/pkg/partition_info"
|
pi "github.com/kairos-io/kcrypt/pkg/partition_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Version = "v0.0.0-dev"
|
||||||
|
|
||||||
func waitdevice(device string, attempts int) error {
|
func waitdevice(device string, attempts int) error {
|
||||||
for tries := 0; tries < attempts; tries++ {
|
for tries := 0; tries < attempts; tries++ {
|
||||||
sh("udevadm settle")
|
sh("udevadm settle")
|
||||||
@@ -279,7 +281,7 @@ func injectInitrd(initrd string, file, dst string) error {
|
|||||||
func unlockAll() error {
|
func unlockAll() error {
|
||||||
bus.Manager.Initialize()
|
bus.Manager.Initialize()
|
||||||
|
|
||||||
partitionInfo, err := pi.NewPartitionInfoFromFile(pi.DefaultPartitionInfoFile)
|
partitionInfo, _, err := pi.NewPartitionInfoFromFile(pi.DefaultPartitionInfoFile)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -305,10 +307,10 @@ func unlockAll() error {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := &cli.App{
|
app := &cli.App{
|
||||||
Name: "keiros-kcrypt",
|
Name: "kairos-kcrypt",
|
||||||
Version: "0.1",
|
Version: Version,
|
||||||
Author: "Ettore Di Giacinto",
|
Author: "Ettore Di Giacinto",
|
||||||
Usage: "keiros escrow key agent component",
|
Usage: "kairos escrow key agent component",
|
||||||
Description: ``,
|
Description: ``,
|
||||||
UsageText: ``,
|
UsageText: ``,
|
||||||
Copyright: "Ettore Di Giacinto",
|
Copyright: "Ettore Di Giacinto",
|
||||||
|
|||||||
@@ -71,6 +71,10 @@ func (pi PartitionInfo) UpdateMapping(partitionData string) error {
|
|||||||
return pi.save()
|
return pi.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pi PartitionInfo) IsMappingNil() bool {
|
||||||
|
return pi.mapping == nil
|
||||||
|
}
|
||||||
|
|
||||||
func (pi PartitionInfo) save() error {
|
func (pi PartitionInfo) save() error {
|
||||||
data, err := yaml.Marshal(&pi.mapping)
|
data, err := yaml.Marshal(&pi.mapping)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -107,6 +111,9 @@ func ParsePartitionInfoFile(file string) (map[string]string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return result, errors.Wrap(err, "unmarshalling partition info file")
|
return result, errors.Wrap(err, "unmarshalling partition info file")
|
||||||
}
|
}
|
||||||
|
if result == nil {
|
||||||
|
result = map[string]string{}
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,13 +38,15 @@ var _ = Describe("Partition Info file parsing", func() {
|
|||||||
fmt.Sprintf("partition-info-%d.yaml", time.Now().UnixNano()))
|
fmt.Sprintf("partition-info-%d.yaml", time.Now().UnixNano()))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("creates the file and returns 'false' and an (empty) mapping", func() {
|
It("creates the file and returns 'false' and a non nil mapping", func() {
|
||||||
result, existed, err := pi.NewPartitionInfoFromFile(fileName)
|
result, existed, err := pi.NewPartitionInfoFromFile(fileName)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(result).ToNot(BeNil())
|
Expect(result).ToNot(BeNil())
|
||||||
Expect(existed).To(BeFalse())
|
Expect(existed).To(BeFalse())
|
||||||
_, err = os.Stat(fileName)
|
_, err = os.Stat(fileName)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
Expect(result).ToNot(BeNil())
|
||||||
|
Expect(result.IsMappingNil()).To(BeFalse())
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user