Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for yum/rpm #42

Merged
merged 8 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading