Repository: osbuild/osbuild-composer
Pull request #371 (2020-03-20 23:48:09)

osbuild-image-tests: add missing build constraints
Build constraints must be added to every file. We only want to build
this package when the `integration` tag is set.

Without this, every build prints this warning:

    # github.com/osbuild/osbuild-composer/cmd/osbuild-image-tests
    runtime.main_main·f: function main is undeclared in the main package


Patch:
diff --git a/.gitignore b/.gitignore
index 96527ebe8..83c4f76a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,4 @@ __pycache__
 /osbuild-weldr-tests
 /osbuild-rcm-tests
 
-/*.tar.gz
-/*.src.rpm
-
 /rpmbuild
diff --git a/internal/rcm/api.go b/internal/rcm/api.go
index d7ea01228..a02bc48a8 100644
--- a/internal/rcm/api.go
+++ b/internal/rcm/api.go
@@ -205,7 +205,7 @@ func (api *API) submit(writer http.ResponseWriter, request *http.Request, _ http
 	// Push the requested compose to the store
 	composeUUID := uuid.New()
 	// nil is used as an upload target, because LocalTarget is already used in the PushCompose function
-	err = api.store.PushCompose(distro, composeUUID, &blueprint.Blueprint{}, packages, buildPackages, arch, imageType, 0, nil)
+	err = api.store.PushCompose(distro, composeUUID, &blueprint.Blueprint{}, repoConfigs, packages, buildPackages, arch, imageType, 0, nil)
 	if err != nil {
 		if api.logger != nil {
 			api.logger.Println("RCM API failed to push compose:", err)
diff --git a/internal/store/store.go b/internal/store/store.go
index 47986391e..eee084677 100644
--- a/internal/store/store.go
+++ b/internal/store/store.go
@@ -578,7 +578,7 @@ func (s *Store) getImageBuildDirectory(composeID uuid.UUID, imageBuildID int) st
 	return fmt.Sprintf("%s/%d", s.getComposeDirectory(composeID), imageBuildID)
 }
 
-func (s *Store) PushCompose(distro distro.Distro, composeID uuid.UUID, bp *blueprint.Blueprint, packages, buildPackages []rpmmd.PackageSpec, arch, composeType string, size uint64, uploadTarget *target.Target) error {
+func (s *Store) PushCompose(distro distro.Distro, composeID uuid.UUID, bp *blueprint.Blueprint, repos []rpmmd.RepoConfig, packages, buildPackages []rpmmd.PackageSpec, arch, composeType string, size uint64, uploadTarget *target.Target) error {
 	targets := []*target.Target{}
 
 	// Compatibility layer for image types in Weldr API v0
@@ -606,12 +606,12 @@ func (s *Store) PushCompose(distro distro.Distro, composeID uuid.UUID, bp *bluep
 		targets = append(targets, uploadTarget)
 	}
 
-	repos := []rpmmd.RepoConfig{}
+	allRepos := append([]rpmmd.RepoConfig{}, repos...)
 	for _, source := range s.Sources {
-		repos = append(repos, source.RepoConfig())
+		allRepos = append(allRepos, source.RepoConfig())
 	}
 
-	manifestStruct, err := distro.Manifest(bp.Customizations, repos, packages, buildPackages, arch, composeType, size)
+	manifestStruct, err := distro.Manifest(bp.Customizations, allRepos, packages, buildPackages, arch, composeType, size)
 	if err != nil {
 		return err
 	}
diff --git a/internal/weldr/api.go b/internal/weldr/api.go
index 08a0576f5..2db121ea3 100644
--- a/internal/weldr/api.go
+++ b/internal/weldr/api.go
@@ -1421,7 +1421,7 @@ func (api *API) composeHandler(writer http.ResponseWriter, request *http.Request
 			return
 		}
 
-		err = api.store.PushCompose(api.distro, reply.BuildID, bp, packages, buildPackages, api.arch, cr.ComposeType, cr.Size, uploadTarget)
+		err = api.store.PushCompose(api.distro, reply.BuildID, bp, api.repos, packages, buildPackages, api.arch, cr.ComposeType, cr.Size, uploadTarget)
 
 		// TODO: we should probably do some kind of blueprint validation in future
 		// for now, let's just 500 and bail out


Test patch:
diff --git a/cmd/osbuild-image-tests/constants.go b/cmd/osbuild-image-tests/constants.go
index b6be5cae1..4236e148c 100644
--- a/cmd/osbuild-image-tests/constants.go
+++ b/cmd/osbuild-image-tests/constants.go
@@ -1,4 +1,4 @@
-// +build !travis
+// +build integration,!travis
 
 package main
 
diff --git a/cmd/osbuild-image-tests/context-managers.go b/cmd/osbuild-image-tests/context-managers.go
index 5c2db5145..7c66143e9 100644
--- a/cmd/osbuild-image-tests/context-managers.go
+++ b/cmd/osbuild-image-tests/context-managers.go
@@ -1,3 +1,5 @@
+// +build integration
+
 package main
 
 import (
diff --git a/cmd/osbuild-image-tests/helpers.go b/cmd/osbuild-image-tests/helpers.go
index 95edfb8bb..75f6da2b9 100644
--- a/cmd/osbuild-image-tests/helpers.go
+++ b/cmd/osbuild-image-tests/helpers.go
@@ -1,3 +1,5 @@
+// +build integration
+
 package main
 
 import (
diff --git a/cmd/osbuild-image-tests/netns.go b/cmd/osbuild-image-tests/netns.go
index de3896bc5..d7b9f0ad2 100644
--- a/cmd/osbuild-image-tests/netns.go
+++ b/cmd/osbuild-image-tests/netns.go
@@ -1,3 +1,5 @@
+// +build integration
+
 package main
 
 import (
diff --git a/internal/jobqueue/api_test.go b/internal/jobqueue/api_test.go
index d9b8a68f5..78ea7df38 100644
--- a/internal/jobqueue/api_test.go
+++ b/internal/jobqueue/api_test.go
@@ -54,7 +54,7 @@ func TestCreate(t *testing.T) {
 	store := store.New(nil, *registry)
 	api := jobqueue.New(nil, store)
 
-	err = store.PushCompose(distroStruct, id, &blueprint.Blueprint{}, nil, nil, "x86_64", "qcow2", 0, nil)
+	err = store.PushCompose(distroStruct, id, &blueprint.Blueprint{}, nil, nil, nil, "x86_64", "qcow2", 0, nil)
 	if err != nil {
 		t.Fatalf("error pushing compose: %v", err)
 	}
@@ -74,7 +74,7 @@ func testUpdateTransition(t *testing.T, from, to string, expectedStatus int, exp
 	api := jobqueue.New(nil, store)
 
 	if from != "VOID" {
-		err := store.PushCompose(distroStruct, id, &blueprint.Blueprint{}, nil, nil, "x86_64", "qcow2", 0, nil)
+		err := store.PushCompose(distroStruct, id, &blueprint.Blueprint{}, nil, nil, nil, "x86_64", "qcow2", 0, nil)
 		if err != nil {
 			t.Fatalf("error pushing compose: %v", err)
 		}