Skip to content

Commit a7899fa

Browse files
committed
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]>
1 parent a4a403a commit a7899fa

File tree

12 files changed

+1004
-4
lines changed

12 files changed

+1004
-4
lines changed

go.mod

Lines changed: 5 additions & 4 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,14 @@ 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
28+
k8s.io/cli-runtime v0.29.2
2529
k8s.io/client-go v0.29.3
2630
k8s.io/component-base v0.29.3
2731
k8s.io/utils v0.0.0-20240102154912-e7106e64919e
2832
sigs.k8s.io/controller-runtime v0.17.2
33+
sigs.k8s.io/yaml v1.4.0
2934
)
3035

3136
require (
@@ -140,7 +145,6 @@ require (
140145
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
141146
github.com/opencontainers/runc v1.1.12 // indirect
142147
github.com/opencontainers/runtime-spec v1.1.0 // indirect
143-
github.com/operator-framework/api v0.23.0 // indirect
144148
github.com/operator-framework/operator-lib v0.12.0 // indirect
145149
github.com/otiai10/copy v1.14.0 // indirect
146150
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
@@ -199,9 +203,7 @@ require (
199203
gopkg.in/warnings.v0 v0.1.2 // indirect
200204
gopkg.in/yaml.v3 v3.0.1 // indirect
201205
helm.sh/helm/v3 v3.14.3 // indirect
202-
k8s.io/apiextensions-apiserver v0.29.3 // indirect
203206
k8s.io/apiserver v0.29.3 // indirect
204-
k8s.io/cli-runtime v0.29.2 // indirect
205207
k8s.io/klog/v2 v2.120.1 // indirect
206208
k8s.io/kube-openapi v0.0.0-20240221221325-2ac9dc51f3f1 // indirect
207209
k8s.io/kubectl v0.29.2 // 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, rootCas)
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/rukpak/api/bundle_types.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
SourceTypeGit SourceType = "git"
24+
SourceTypeConfigMaps SourceType = "configMaps"
25+
SourceTypeHTTP SourceType = "http"
26+
27+
TypeUnpacked = "Unpacked"
28+
29+
ReasonUnpackPending = "UnpackPending"
30+
ReasonUnpacking = "Unpacking"
31+
ReasonUnpackSuccessful = "UnpackSuccessful"
32+
ReasonUnpackFailed = "UnpackFailed"
33+
ReasonProcessingFinalizerFailed = "ProcessingFinalizerFailed"
34+
35+
PhasePending = "Pending"
36+
PhaseUnpacking = "Unpacking"
37+
PhaseFailing = "Failing"
38+
PhaseUnpacked = "Unpacked"
39+
)
40+
41+
type BundleSource struct {
42+
// Type defines the kind of Bundle content being sourced.
43+
Type SourceType `json:"type"`
44+
// Image is the bundle image that backs the content of this bundle.
45+
Image ImageSource `json:"image,omitempty"`
46+
// Git is the git repository that backs the content of this Bundle.
47+
}
48+
49+
type ImageSource struct {
50+
// Ref contains the reference to a container image containing Bundle contents.
51+
Ref string `json:"ref"`
52+
// ImagePullSecretName contains the name of the image pull secret in the namespace that the provisioner is deployed.
53+
ImagePullSecretName string `json:"pullSecret,omitempty"`
54+
}

0 commit comments

Comments
 (0)