Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
add crd upgrade safety preflight check
Browse files Browse the repository at this point in the history
Signed-off-by: everettraven <[email protected]>
  • Loading branch information
everettraven committed May 23, 2024
1 parent 0f2b80e commit 96043d4
Show file tree
Hide file tree
Showing 6 changed files with 467 additions and 14 deletions.
14 changes: 14 additions & 0 deletions cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/gorilla/handlers"
"github.com/spf13/pflag"
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
apiextensionsv1client "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/typed/apiextensions/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/selection"
Expand All @@ -51,6 +52,7 @@ import (
"github.com/operator-framework/rukpak/internal/version"
"github.com/operator-framework/rukpak/pkg/features"
"github.com/operator-framework/rukpak/pkg/finalizer"
"github.com/operator-framework/rukpak/pkg/preflights/crdupgradesafety"
"github.com/operator-framework/rukpak/pkg/source"
"github.com/operator-framework/rukpak/pkg/storage"
"github.com/operator-framework/rukpak/pkg/util"
Expand Down Expand Up @@ -231,11 +233,23 @@ func main() {
setupLog.Error(err, "unable to create action client getter")
os.Exit(1)
}

aeClient, err := apiextensionsv1client.NewForConfig(cfg)
if err != nil {
setupLog.Error(err, "unable to create apiextensions client")
os.Exit(1)
}

preflights := []bundledeployment.Preflight{
crdupgradesafety.NewPreflight(aeClient.CustomResourceDefinitions()),
}

commonBDProvisionerOptions := []bundledeployment.Option{
bundledeployment.WithActionClientGetter(acg),
bundledeployment.WithFinalizers(bundleFinalizers),
bundledeployment.WithStorage(bundleStorage),
bundledeployment.WithUnpacker(unpacker),
bundledeployment.WithPreflights(preflights...),
}

if err := bundledeployment.SetupWithManager(mgr, systemNamespace, append(
Expand Down
13 changes: 12 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/operator-framework/rukpak
go 1.22.0

require (
carvel.dev/kapp v0.62.1-0.20240508153820-7d8a03ed7ccf
github.com/containerd/containerd v1.7.17
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.12.0
Expand Down Expand Up @@ -96,6 +97,9 @@ require (
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 // indirect
github.com/containers/ocicrypt v1.1.10 // indirect
github.com/containers/storage v1.53.0 // indirect
github.com/cppforlife/cobrautil v0.0.0-20221130162803-acdfead391ef // indirect
github.com/cppforlife/color v1.9.1-0.20200716202919-6706ac40b835 // indirect
github.com/cppforlife/go-cli-ui v0.0.0-20220425131040-94f26b16bc14 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dimchansky/utfbom v1.1.1 // indirect
Expand Down Expand Up @@ -146,6 +150,7 @@ require (
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -154,6 +159,8 @@ require (
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k14s/starlark-go v0.0.0-20200720175618-3a5c849cc368 // indirect
github.com/k14s/ytt v0.36.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.17.7 // indirect
github.com/klauspost/pgzip v1.2.6 // indirect
Expand All @@ -163,7 +170,7 @@ require (
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand All @@ -183,6 +190,7 @@ require (
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/openshift/crd-schema-checker v0.0.0-20240404194209-35a9033b1d11 // indirect
github.com/operator-framework/operator-lib v0.14.0 // indirect
github.com/otiai10/copy v1.14.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand All @@ -205,6 +213,9 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
github.com/vbatts/tar-split v0.11.5 // indirect
github.com/vito/go-interact v1.0.1 // indirect
github.com/vmware-tanzu/carvel-kapp-controller v0.50.2 // indirect
github.com/vmware-tanzu/carvel-vendir v0.36.0 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
Expand Down
Loading

0 comments on commit 96043d4

Please sign in to comment.