Skip to content

Commit 631c758

Browse files
authored
✨ Starting Helm POC - pull in some rukpak (#756)
* Fix suite_test.go Signed-off-by: Todd Short <[email protected]> * Copy over some rukpak code and replace BundleDeployment Replace BundleDeployment in the Unpack APIs with a combination of BundleSource and ClusterExtension. It builds... Signed-off-by: Todd Short <[email protected]> * fixup! Copy over some rukpak code and replace BundleDeployment --------- Signed-off-by: Todd Short <[email protected]>
1 parent 1b1b671 commit 631c758

File tree

13 files changed

+991
-5
lines changed

13 files changed

+991
-5
lines changed

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ require (
99
github.com/blang/semver/v4 v4.0.0
1010
github.com/go-logr/logr v1.4.1
1111
github.com/google/go-cmp v0.6.0
12+
github.com/nlepage/go-tarfs v1.2.1
13+
github.com/operator-framework/api v0.23.0
1214
github.com/operator-framework/catalogd v0.12.0
1315
github.com/operator-framework/deppy v0.3.0
1416
github.com/operator-framework/helm-operator-plugins v0.1.3
@@ -21,11 +23,13 @@ require (
2123
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a
2224
gopkg.in/yaml.v2 v2.4.0
2325
k8s.io/api v0.29.3
26+
k8s.io/apiextensions-apiserver v0.29.3
2427
k8s.io/apimachinery v0.29.3
2528
k8s.io/client-go v0.29.3
2629
k8s.io/component-base v0.29.3
2730
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
2831
sigs.k8s.io/controller-runtime v0.17.2
32+
sigs.k8s.io/yaml v1.4.0
2933
)
3034

3135
require (
@@ -140,7 +144,6 @@ require (
140144
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
141145
github.com/opencontainers/runc v1.1.12 // indirect
142146
github.com/opencontainers/runtime-spec v1.1.0 // indirect
143-
github.com/operator-framework/api v0.23.0 // indirect
144147
github.com/operator-framework/operator-lib v0.12.0 // indirect
145148
github.com/otiai10/copy v1.14.0 // indirect
146149
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
@@ -199,7 +202,6 @@ require (
199202
gopkg.in/warnings.v0 v0.1.2 // indirect
200203
gopkg.in/yaml.v3 v3.0.1 // indirect
201204
helm.sh/helm/v3 v3.14.3 // indirect
202-
k8s.io/apiextensions-apiserver v0.29.3 // indirect
203205
k8s.io/apiserver v0.29.3 // indirect
204206
k8s.io/cli-runtime v0.29.2 // indirect
205207
k8s.io/klog/v2 v2.120.1 // indirect
@@ -211,5 +213,4 @@ require (
211213
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
212214
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
213215
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
214-
sigs.k8s.io/yaml v1.4.0 // indirect
215216
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
376376
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
377377
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
378378
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
379+
github.com/nlepage/go-tarfs v1.2.1 h1:o37+JPA+ajllGKSPfy5+YpsNHDjZnAoyfvf5GsUa+Ks=
380+
github.com/nlepage/go-tarfs v1.2.1/go.mod h1:rno18mpMy9aEH1IiJVftFsqPyIpwqSUiAOpJYjlV2NA=
379381
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
380382
github.com/onsi/ginkgo/v2 v2.17.1 h1:V++EzdbhI4ZV4ev0UTIj0PzhzOcReJFyJaLjtSF55M8=
381383
github.com/onsi/ginkgo/v2 v2.17.1/go.mod h1:llBI3WDLL9Z6taip6f33H76YcWtJv+7R3HigUjbIBOs=

internal/controllers/clusterextension_controller.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050
"github.com/operator-framework/operator-controller/internal/catalogmetadata"
5151
catalogfilter "github.com/operator-framework/operator-controller/internal/catalogmetadata/filter"
5252
catalogsort "github.com/operator-framework/operator-controller/internal/catalogmetadata/sort"
53+
rukpakapi "github.com/operator-framework/operator-controller/internal/rukpak/api"
5354
)
5455

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

139+
// Generate a BundleSource, and then pass this and the ClusterExtension to Unpack
140+
// TODO:
141+
// bs := r.GenerateExpectedBundleSource(*ext, bundle.Image)
142+
// unpacker := NewDefaultUnpacker(msg, namespace, unpackImage)
143+
// unpacker..Unpack(bs, ext)
144+
138145
// set the status of the cluster extension based on the respective bundle deployment status conditions.
139146
return ctrl.Result{}, nil
140147
}
@@ -221,6 +228,15 @@ func SetDeprecationStatus(ext *ocv1alpha1.ClusterExtension, bundle *catalogmetad
221228
}
222229
}
223230

231+
func (r *ClusterExtensionReconciler) GenerateExpectedBundleSource(o ocv1alpha1.ClusterExtension, bundlePath string) *rukpakapi.BundleSource {
232+
return &rukpakapi.BundleSource{
233+
Type: rukpakapi.SourceTypeImage,
234+
Image: rukpakapi.ImageSource{
235+
Ref: bundlePath,
236+
},
237+
}
238+
}
239+
224240
func (r *ClusterExtensionReconciler) GenerateExpectedBundleDeployment(o ocv1alpha1.ClusterExtension, bundlePath string, bundleProvisioner string) *unstructured.Unstructured {
225241
// We use unstructured here to avoid problems of serializing default values when sending patches to the apiserver.
226242
// If you use a typed object, any default values from that struct get serialized into the JSON patch, which could

internal/controllers/suite_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func newClient(t *testing.T) client.Client {
4747
}
4848

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

5353
cl := newClient(t)
@@ -56,7 +56,6 @@ func newClientAndReconciler(t *testing.T) (client.Client, *controllers.ClusterEx
5656
Client: cl,
5757
BundleProvider: &fakeCatalogClient,
5858
Scheme: sch,
59-
Resolver: resolver,
6059
}
6160
return cl, reconciler
6261
}

internal/rukpak/api/bundle_types.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
Copyright 2021.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package rukpakapi
18+
19+
type SourceType string
20+
21+
const (
22+
SourceTypeImage SourceType = "image"
23+
24+
TypeUnpacked = "Unpacked"
25+
26+
ReasonUnpackPending = "UnpackPending"
27+
ReasonUnpacking = "Unpacking"
28+
ReasonUnpackSuccessful = "UnpackSuccessful"
29+
ReasonUnpackFailed = "UnpackFailed"
30+
ReasonProcessingFinalizerFailed = "ProcessingFinalizerFailed"
31+
32+
PhasePending = "Pending"
33+
PhaseUnpacking = "Unpacking"
34+
PhaseFailing = "Failing"
35+
PhaseUnpacked = "Unpacked"
36+
)
37+
38+
type BundleSource struct {
39+
// Type defines the kind of Bundle content being sourced.
40+
Type SourceType `json:"type"`
41+
// Image is the bundle image that backs the content of this bundle.
42+
Image ImageSource `json:"image,omitempty"`
43+
// Git is the git repository that backs the content of this Bundle.
44+
}
45+
46+
type ImageSource struct {
47+
// Ref contains the reference to a container image containing Bundle contents.
48+
Ref string `json:"ref"`
49+
// ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed.
50+
ImagePullSecretName string `json:"pullSecret,omitempty"`
51+
}

0 commit comments

Comments
 (0)