Skip to content

Commit

Permalink
Add support for yum/rpm (#42)
Browse files Browse the repository at this point in the history
* Add support for yum/rpm

* Fix test

* Harmonize file and package names

* Tests for rpm/yum

* Add utility commands

* Harmonize package names

* Add fixes after review

---------

Co-authored-by: Jon Henrik Bjørnstad <[email protected]>
  • Loading branch information
jonhenrik13 and jonhenrik13 authored Apr 2, 2024
1 parent b61a2dc commit 850d09c
Show file tree
Hide file tree
Showing 29 changed files with 918 additions and 167 deletions.
37 changes: 37 additions & 0 deletions Dockerfile.rhel9
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM golang:1.21 as builder

ARG version
ENV VERSION_VAR=go.qbee.io/agent/app.Version

ENV CGO_ENABLED=0

WORKDIR /src

COPY . /src

# build the agent
RUN --mount=type=cache,target=/go \
--mount=type=cache,target=/root/.cache/go-build \
go build \
-ldflags "-s -w -X ${VERSION_VAR}=$version" \
-o /usr/bin/qbee-agent \
main.go

FROM registry.access.redhat.com/ubi9/ubi:latest

COPY app/software/test_repository/rhel /yum-repo

COPY <<EOF /etc/yum.repos.d/qbee.repo
[qbee-dev]
name=qbee-dev
baseurl=file:///yum-repo/
enabled=1
gpgcheck=0
EOF

RUN mkdir /etc/qbee && echo '{}' > /etc/qbee/qbee-agent.json
COPY --from=builder /usr/bin/qbee-agent /usr/bin/qbee-agent

WORKDIR /app
CMD [ "/bin/sh" ]

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ docker-image:
docker build -t debian:qbee \
--build-arg version=2023.01 \
.
docker build -t rhel:qbee \
--build-arg version=2023.01 \
-f Dockerfile.rhel9 .

test:
go test ./app/...

lint:
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run
docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run
18 changes: 9 additions & 9 deletions app/configuration/bundle_file_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
func Test_FileDistributionBundle(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"

agentConfig := configuration.CommittedConfig{
Bundles: []string{configuration.BundleFileDistribution},
Expand Down Expand Up @@ -142,7 +142,7 @@ func Test_FileDistributionBundle_TemplateUsingParameters(t *testing.T) {
func Test_FileDistributionBundle_AfterCommand(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"

agentConfig := configuration.CommittedConfig{
Bundles: []string{configuration.BundleFileDistribution},
Expand Down Expand Up @@ -181,7 +181,7 @@ func Test_FileDistributionBundle_AfterCommand(t *testing.T) {
func Test_FileDistributionBundle_PreCondition_True(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"

// commit config for the device
agentConfig := configuration.CommittedConfig{
Expand Down Expand Up @@ -218,7 +218,7 @@ func Test_FileDistributionBundle_PreCondition_True(t *testing.T) {
func Test_FileDistributionBundle_PreCondition_False(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"

// commit config for the device
agentConfig := configuration.CommittedConfig{
Expand Down Expand Up @@ -251,7 +251,7 @@ func Test_FileDistributionBundle_Destination_Dirname_Exists(t *testing.T) {
r := runner.New(t)

destDir := "/tmp/"
filename := "test_2.1.1.deb"
filename := "qbee-test_2.1.1_all.deb"
localFileRef := "file:///apt-repo/" + filename

agentConfig := configuration.CommittedConfig{
Expand Down Expand Up @@ -288,8 +288,8 @@ func Test_FileDistributionBundle_Destination_Dirname_Exists(t *testing.T) {
func Test_FileDistributionBundle_Destination_Regular_Path(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
destFile := "/tmp/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"
destFile := "/tmp/qbee-test_2.1.1_all.deb"

agentConfig := configuration.CommittedConfig{
Bundles: []string{configuration.BundleFileDistribution},
Expand Down Expand Up @@ -327,7 +327,7 @@ func Test_FileDistributionBundle_Destination_Regular_Path(t *testing.T) {
func Test_FileDistributionBundle_Destination_Dirname_NotExists(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"
destDir := "/tmp/doesnotexist/"

agentConfig := configuration.CommittedConfig{
Expand Down Expand Up @@ -357,7 +357,7 @@ func Test_FileDistributionBundle_Destination_Dirname_NotExists(t *testing.T) {
func Test_FileDistributionBundle_Destination_Is_Empty(t *testing.T) {
r := runner.New(t)

localFileRef := "file:///apt-repo/test_2.1.1.deb"
localFileRef := "file:///apt-repo/qbee-test_2.1.1_all.deb"
destDir := ""

agentConfig := configuration.CommittedConfig{
Expand Down
Loading

0 comments on commit 850d09c

Please sign in to comment.