Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 0 additions & 14 deletions staging/operator-registry/.github/workflows/retest.yaml

This file was deleted.

37 changes: 33 additions & 4 deletions staging/operator-registry/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ clean:
@rm -rf ./bin

.PHONY: e2e
e2e:
$(GO) run github.com/onsi/ginkgo/v2/ginkgo --v --randomize-all --progress --trace --randomize-suites --race $(if $(TEST),-focus '$(TEST)') $(TAGS) ./test/e2e -- $(if $(SKIPTLS),-skip-tls-verify true) $(if $(USEHTTP),-use-http true)
e2e: ginkgo
$(GINKGO) --v --randomize-all --progress --trace --randomize-suites --race $(if $(TEST),-focus '$(TEST)') $(TAGS) ./test/e2e -- $(if $(SKIPTLS),-skip-tls-verify true) $(if $(USEHTTP),-use-http true)

.PHONY: release
export OPM_IMAGE_REPO ?= quay.io/operator-framework/opm
Expand All @@ -137,8 +137,8 @@ export LATEST_IMAGE_OR_EMPTY ?= $(shell \
&& [ "$(shell echo -e "$(OPM_VERSION)\n$(LATEST_TAG)" | sort -rV | head -n1)" == "$(OPM_VERSION)" ] \
&& echo "$(OPM_IMAGE_REPO):latest" || echo "")
release: RELEASE_ARGS ?= release --rm-dist --snapshot -f release/goreleaser.$(shell go env GOOS).yaml
release:
./scripts/fetch goreleaser 1.4.1 && ./bin/goreleaser $(RELEASE_ARGS)
release: goreleaser
$(GORELEASER) $(RELEASE_ARGS)

# tagged-or-empty returns $(OPM_IMAGE_REPO):$(1) when HEAD is assigned a non-prerelease semver tag,
# otherwise the empty string. An empty string causes goreleaser to skip building
Expand All @@ -150,3 +150,32 @@ $(shell \
&& git describe --tags --exact-match HEAD >/dev/null 2>&1 \
&& echo "$(OPM_IMAGE_REPO):$(1)" || echo "" )
endef

################
# Hack / Tools #
################

GO_INSTALL_OPTS ?= "-mod=mod"

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
GORELEASER ?= $(LOCALBIN)/goreleaser
GINKGO ?= $(LOCALBIN)/ginkgo

## Tool Versions
GORELEASER_VERSION ?= v1.8.3
GINKGO_VERSION ?= v2.1.3

.PHONY: goreleaser
goreleaser: $(GORELEASER) ## Download goreleaser locally if necessary.
$(GORELEASER): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) github.com/goreleaser/goreleaser@$(GORELEASER_VERSION)

.PHONY: ginkgo
ginkgo: $(GINKGO) ## Download ginkgo locally if necessary.
$(GINKGO): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install $(GO_INSTALL_OPTS) github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
6 changes: 3 additions & 3 deletions staging/operator-registry/alpha/action/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestMigrate(t *testing.T) {
err := generateSqliteFile(dbFile, sqliteBundles)
require.NoError(t, err)

reg, err := newMigrateRegistry(sqliteBundles)
reg, err := newMigrateRegistry(t, sqliteBundles)
require.NoError(t, err)

specs := []spec{
Expand Down Expand Up @@ -118,8 +118,8 @@ func TestMigrate(t *testing.T) {
}
}

func newMigrateRegistry(imageMap map[image.Reference]string) (image.Registry, error) {
subSqliteImage, err := generateSqliteFS(imageMap)
func newMigrateRegistry(t *testing.T, imageMap map[image.Reference]string) (image.Registry, error) {
subSqliteImage, err := generateSqliteFS(t, imageMap)
if err != nil {
return nil, err
}
Expand Down
16 changes: 6 additions & 10 deletions staging/operator-registry/alpha/action/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestRender(t *testing.T) {
assertion require.ErrorAssertionFunc
}

reg, err := newRegistry()
reg, err := newRegistry(t)
require.NoError(t, err)
foov1csv, err := bundleImageV1.ReadFile("testdata/foo-bundle-v0.1.0/manifests/foo.v0.1.0.csv.yaml")
require.NoError(t, err)
Expand Down Expand Up @@ -563,7 +563,7 @@ func TestAllowRefMask(t *testing.T) {
expectErr error
}

reg, err := newRegistry()
reg, err := newRegistry(t)
require.NoError(t, err)

dir := t.TempDir()
Expand Down Expand Up @@ -766,13 +766,13 @@ var bundleImageV2NoCSVRelatedImages embed.FS
//go:embed testdata/foo-index-v0.2.0-declcfg/foo/*
var declcfgImage embed.FS

func newRegistry() (image.Registry, error) {
func newRegistry(t *testing.T) (image.Registry, error) {
imageMap := map[image.Reference]string{
image.SimpleReference("test.registry/foo-operator/foo-bundle:v0.1.0"): "testdata/foo-bundle-v0.1.0",
image.SimpleReference("test.registry/foo-operator/foo-bundle:v0.2.0"): "testdata/foo-bundle-v0.2.0",
}

subSqliteImage, err := generateSqliteFS(imageMap)
subSqliteImage, err := generateSqliteFS(t, imageMap)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -828,12 +828,8 @@ func newRegistry() (image.Registry, error) {
}, nil
}

func generateSqliteFS(imageMap map[image.Reference]string) (fs.FS, error) {
dir, err := os.MkdirTemp("", "opm-render-test-")
if err != nil {
return nil, err
}
defer os.RemoveAll(dir)
func generateSqliteFS(t *testing.T, imageMap map[image.Reference]string) (fs.FS, error) {
dir := t.TempDir()

dbFile := filepath.Join(dir, "index.db")
if err := generateSqliteFile(dbFile, imageMap); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions staging/operator-registry/alpha/property/property_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,7 @@ func TestFile_GetData(t *testing.T) {

for _, s := range specs {
t.Run(s.name, func(t *testing.T) {
dir, err := ioutil.TempDir("", "operator-registry-test-file-")
require.NoError(t, err)
defer os.RemoveAll(dir)
dir := t.TempDir()

if s.createFile != nil {
require.NoError(t, s.createFile(dir))
Expand Down
7 changes: 2 additions & 5 deletions staging/operator-registry/pkg/image/mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package image

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand All @@ -16,9 +15,7 @@ func TestMockRegistry(t *testing.T) {
dne := SimpleReference("dne")
ctx := context.Background()

tmpDir, err := ioutil.TempDir("", "reg-test-mock-")
require.NoError(t, err)
defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()

r := MockRegistry{
RemoteImages: map[Reference]*MockImage{
Expand All @@ -44,7 +41,7 @@ func TestMockRegistry(t *testing.T) {

// Test unpack and labels of unpulled ref
require.Error(t, r.Unpack(ctx, exists, tmpDir))
_, err = r.Labels(ctx, exists)
_, err := r.Labels(ctx, exists)
require.Error(t, err)

// Test pull of existing ref
Expand Down
6 changes: 2 additions & 4 deletions staging/operator-registry/pkg/lib/bundle/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,7 @@ COPY x/y/z /metadata/
}

func TestCopyYamlOutput(t *testing.T) {
testOutputDir, _ := ioutil.TempDir("./", "test-generate")
defer os.RemoveAll(testOutputDir)
testOutputDir := t.TempDir()

testContent := []byte{0, 1, 0, 0}
testManifestDir := "./testdata/generate/manifests"
Expand Down Expand Up @@ -224,8 +223,7 @@ func TestCopyYamlOutput_NoOutputDir(t *testing.T) {
}

func TestCopyYamlOutput_NestedCopy(t *testing.T) {
testOutputDir, _ := ioutil.TempDir("./", "test-generate")
defer os.RemoveAll(testOutputDir)
testOutputDir := t.TempDir()

testContent := []byte{0, 1, 0, 0}
testManifestDir := "./testdata/generate/nested_manifests"
Expand Down
3 changes: 1 addition & 2 deletions staging/operator-registry/pkg/lib/registry/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,8 +630,7 @@ func TestCheckForBundles(t *testing.T) {

for _, tt := range tests {
t.Run(tt.description, func(t *testing.T) {
tmpdir, err := os.MkdirTemp(".", "tmpdir-*")
defer os.RemoveAll(tmpdir)
tmpdir := t.TempDir()
db, cleanup := CreateTestDb(t)
defer cleanup()
load, err := sqlite.NewSQLLiteLoader(db)
Expand Down
4 changes: 1 addition & 3 deletions staging/operator-registry/pkg/registry/populator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,9 +1184,7 @@ func TestDeprecatePackage(t *testing.T) {
}

func TestAddAfterDeprecate(t *testing.T) {
tmpdir, err := os.MkdirTemp(".", "add-after-deprecate-*")
require.NoError(t, err)
defer os.RemoveAll(tmpdir)
tmpdir := t.TempDir()

/*
(0.1) 0.1.2 <- 0.1.1 <- 0.1.0
Expand Down
8 changes: 1 addition & 7 deletions staging/operator-registry/pkg/sqlite/conversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package sqlite

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -12,11 +10,7 @@ import (
)

func TestToModel(t *testing.T) {
tmpDir, err := ioutil.TempDir("", "server_test-")
if err != nil {
logrus.Fatal(err)
}
defer os.RemoveAll(tmpDir)
tmpDir := t.TempDir()
dbPath := filepath.Join(tmpDir, "test.db")

db, err := Open(dbPath)
Expand Down
9 changes: 1 addition & 8 deletions staging/operator-registry/pkg/sqlite/directory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package sqlite

import (
"context"
"io/ioutil"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -38,13 +37,7 @@ func TestDirectoryLoaderWithBadPackageData(t *testing.T) {
require.NoError(t, store.Migrate(context.TODO()))

// Copy golden manifests to a temp dir
dir, err := ioutil.TempDir("testdata", "manifests-")
require.NoError(t, err)
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}()
dir := t.TempDir()
require.NoError(t, copy.Copy("./testdata/loader_data", dir))

// Point the first channel at a CSV that doesn't exist
Expand Down
31 changes: 0 additions & 31 deletions staging/operator-registry/scripts/fetch

This file was deleted.