Skip to content

Commit d3c2306

Browse files
committed
image-builder: add experimental "skip-priv-checks" option
This commit adds support to skip the priviledges checks when preparing for running osbuild. This is needed so that we can still run our (fake) integration tests.
1 parent 9eb8aea commit d3c2306

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

cmd/image-builder/main_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func TestManifestIntegrationSmoke(t *testing.T) {
159159
if !hasDepsolveDnf() {
160160
t.Skip("no osbuild-depsolve-dnf binary found")
161161
}
162+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
162163

163164
restore := main.MockNewRepoRegistry(testrepos.New)
164165
defer restore()
@@ -359,6 +360,7 @@ func TestBuildIntegrationHappy(t *testing.T) {
359360
if !hasDepsolveDnf() {
360361
t.Skip("no osbuild-depsolve-dnf binary found")
361362
}
363+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
362364

363365
restore := main.MockNewRepoRegistry(testrepos.New)
364366
defer restore()
@@ -420,6 +422,7 @@ func TestBuildIntegrationArgs(t *testing.T) {
420422
if !hasDepsolveDnf() {
421423
t.Skip("no osbuild-depsolve-dnf binary found")
422424
}
425+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
423426

424427
restore := main.MockNewRepoRegistry(testrepos.New)
425428
defer restore()
@@ -509,6 +512,7 @@ func TestBuildIntegrationErrorsProgressVerbose(t *testing.T) {
509512
if !hasDepsolveDnf() {
510513
t.Skip("no osbuild-depsolve-dnf binary found")
511514
}
515+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
512516

513517
restore := main.MockNewRepoRegistry(testrepos.New)
514518
defer restore()
@@ -543,6 +547,7 @@ func TestBuildIntegrationErrorsProgressVerboseWithBuildlog(t *testing.T) {
543547
if !hasDepsolveDnf() {
544548
t.Skip("no osbuild-depsolve-dnf binary found")
545549
}
550+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
546551

547552
restore := main.MockNewRepoRegistry(testrepos.New)
548553
defer restore()
@@ -592,6 +597,7 @@ func TestBuildIntegrationErrorsProgressTerm(t *testing.T) {
592597
if !hasDepsolveDnf() {
593598
t.Skip("no osbuild-depsolve-dnf binary found")
594599
}
600+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
595601

596602
restore := main.MockNewRepoRegistry(testrepos.New)
597603
defer restore()
@@ -821,6 +827,7 @@ func TestBuildCrossArchSmoke(t *testing.T) {
821827
if !hasDepsolveDnf() {
822828
t.Skip("no osbuild-depsolve-dnf binary found")
823829
}
830+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
824831

825832
restore := main.MockNewRepoRegistry(testrepos.New)
826833
defer restore()
@@ -873,6 +880,7 @@ func TestBuildIntegrationOutputFilename(t *testing.T) {
873880
if !hasDepsolveDnf() {
874881
t.Skip("no osbuild-depsolve-dnf binary found")
875882
}
883+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
876884

877885
restore := main.MockNewRepoRegistry(testrepos.New)
878886
defer restore()

cmd/image-builder/upload_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ func TestBuildAndUploadWithAWSMock(t *testing.T) {
128128
if !hasDepsolveDnf() {
129129
t.Skip("no osbuild-depsolve-dnf binary found")
130130
}
131+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
131132

132133
var regionName, bucketName, amiName string
133134
var fa fakeAwsUploader
@@ -177,6 +178,7 @@ func TestBuildAmiButNotUpload(t *testing.T) {
177178
if !hasDepsolveDnf() {
178179
t.Skip("no osbuild-depsolve-dnf binary found")
179180
}
181+
t.Setenv("IMAGE_BUILDER_EXPERIMENTAL", "skip-priv-checks")
180182

181183
fa := fakeAwsUploader{
182184
uploadAndRegisterErr: fmt.Errorf("upload should not be called"),

pkg/progress/run.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ type OSBuildOptions struct {
3333
// enoughPrivsForOsbuild() returns true if the current process does
3434
// has enough priviledges to run osbuild
3535
var enoughPrivsForOsbuild = func() (bool, error) {
36+
if experimentalflags.Bool("skip-priv-checks") {
37+
return true, nil
38+
}
39+
3640
if os.Getuid() != 0 {
3741
return false, nil
3842
}

0 commit comments

Comments
 (0)