Skip to content

✨ Starting Helm POC - pull in some rukpak #756

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

Merged
merged 3 commits into from
Apr 16, 2024
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
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/blang/semver/v4 v4.0.0
github.com/go-logr/logr v1.4.1
github.com/google/go-cmp v0.6.0
github.com/nlepage/go-tarfs v1.2.1
github.com/operator-framework/api v0.23.0
github.com/operator-framework/catalogd v0.12.0
github.com/operator-framework/deppy v0.3.0
github.com/operator-framework/helm-operator-plugins v0.1.3
Expand All @@ -21,11 +23,13 @@ require (
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
gopkg.in/yaml.v2 v2.4.0
k8s.io/api v0.29.3
k8s.io/apiextensions-apiserver v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/component-base v0.29.3
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
sigs.k8s.io/controller-runtime v0.17.2
sigs.k8s.io/yaml v1.4.0
)

require (
Expand Down Expand Up @@ -140,7 +144,6 @@ require (
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/opencontainers/runtime-spec v1.1.0 // indirect
github.com/operator-framework/api v0.23.0 // indirect
github.com/operator-framework/operator-lib v0.12.0 // indirect
github.com/otiai10/copy v1.14.0 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
Expand Down Expand Up @@ -199,7 +202,6 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
helm.sh/helm/v3 v3.14.3 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/apiserver v0.29.3 // indirect
k8s.io/cli-runtime v0.29.2 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
Expand All @@ -211,5 +213,4 @@ require (
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nlepage/go-tarfs v1.2.1 h1:o37+JPA+ajllGKSPfy5+YpsNHDjZnAoyfvf5GsUa+Ks=
github.com/nlepage/go-tarfs v1.2.1/go.mod h1:rno18mpMy9aEH1IiJVftFsqPyIpwqSUiAOpJYjlV2NA=
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=
Expand Down
16 changes: 16 additions & 0 deletions internal/controllers/clusterextension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import (
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter"
catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort"
rukpakapi "github.com/operator-framework/operator-controller/internal/rukpak/api"
)

// ClusterExtensionReconciler reconciles a ClusterExtension object
Expand Down Expand Up @@ -135,6 +136,12 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
// Unpack contents into a fs based on the bundle.
// Considering only image source.

// Generate a BundleSource, and then pass this and the ClusterExtension to Unpack
// TODO:
// bs := r.GenerateExpectedBundleSource(*ext, bundle.Image)
// unpacker := NewDefaultUnpacker(msg, namespace, unpackImage)
// unpacker..Unpack(bs, ext)

// set the status of the cluster extension based on the respective bundle deployment status conditions.
return ctrl.Result{}, nil
}
Expand Down Expand Up @@ -221,6 +228,15 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundle *catalogmetad
}
}

func (r *ClusterExtensionReconciler) GenerateExpectedBundleSource(o ocv1alpha1.ClusterExtension, bundlePath string) *rukpakapi.BundleSource {
return &rukpakapi.BundleSource{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BundleSource here is stateless, and does not store any information with respect to the status.
Which means we need not create a separate API, instead just create a struct and pass it to the unpacker. This way, we can remove all the deep copy methods and not consider the bundle source as a deep copy object.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this API is not a k8s API, it's just a struct as you point out. It was convenient to use. However, it's named rukpakapi since it's part of the interface to the pulled-in rukpak code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It had deepycopy methods, so thought this was intended to be a separate API. The naming is all good 👍

Type: rukpakapi.SourceTypeImage,
Image: rukpakapi.ImageSource{
Ref: bundlePath,
},
}
}

func (r *ClusterExtensionReconciler) GenerateExpectedBundleDeployment(o ocv1alpha1.ClusterExtension, bundlePath string, bundleProvisioner string) *unstructured.Unstructured {
// We use unstructured here to avoid problems of serializing default values when sending patches to the apiserver.
// If you use a typed object, any default values from that struct get serialized into the JSON patch, which could
Expand Down
3 changes: 1 addition & 2 deletions internal/controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newClient(t *testing.T) client.Client {
}

func newClientAndReconciler(t *testing.T) (client.Client, *controllers.ClusterExtensionReconciler) {
resolver, err := solver.New()
_, err := solver.New()
require.NoError(t, err)

cl := newClient(t)
Expand All @@ -56,7 +56,6 @@ func newClientAndReconciler(t *testing.T) (client.Client, *controllers.ClusterEx
Client: cl,
BundleProvider: &fakeCatalogClient,
Scheme: sch,
Resolver: resolver,
}
return cl, reconciler
}
Expand Down
51 changes: 51 additions & 0 deletions internal/rukpak/api/bundle_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
Copyright 2021.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package rukpakapi

type SourceType string

const (
SourceTypeImage SourceType = "image"

TypeUnpacked = "Unpacked"

ReasonUnpackPending = "UnpackPending"
ReasonUnpacking = "Unpacking"
ReasonUnpackSuccessful = "UnpackSuccessful"
ReasonUnpackFailed = "UnpackFailed"
ReasonProcessingFinalizerFailed = "ProcessingFinalizerFailed"

PhasePending = "Pending"
PhaseUnpacking = "Unpacking"
PhaseFailing = "Failing"
PhaseUnpacked = "Unpacked"
)

type BundleSource struct {
// Type defines the kind of Bundle content being sourced.
Type SourceType `json:"type"`
// Image is the bundle image that backs the content of this bundle.
Image ImageSource `json:"image,omitempty"`
// Git is the git repository that backs the content of this Bundle.
}

type ImageSource struct {
// Ref contains the reference to a container image containing Bundle contents.
Ref string `json:"ref"`
// ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed.
ImagePullSecretName string `json:"pullSecret,omitempty"`
}
Loading