Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit c7a9268

Browse files
✨ Add oci as assets client (#198)
* Upgrade CSO dependency to v0.1.0-alpha.6 Signed-off-by: Roman Hros <[email protected]> * Fix quickstart link Signed-off-by: Roman Hros <[email protected]> * Add oci as assets client Signed-off-by: Roman Hros <[email protected]> * Try registry.dnation.cloud to fix tests Signed-off-by: Roman Hros <[email protected]> * fix(config): use cspo-cluster-stack-variables Signed-off-by: Jan Schoone <[email protected]> * feat(envrc): add Resource Sets to sample environment Signed-off-by: Jan Schoone <[email protected]> * Add oci username/password to the cspo config Signed-off-by: Roman Hros <[email protected]> * feat(tilt): update CAPO version Signed-off-by: Jan Schoone <[email protected]> * OCI_USERNAME and OCI_PASSWORD are not required Signed-off-by: Roman Hros <[email protected]> * Upgrade CSO dependency to v0.1.0-alpha.7 Signed-off-by: Roman Hros <[email protected]> * Disable oci integration tests for the GitHub CI Signed-off-by: Roman Hros <[email protected]> --------- Signed-off-by: Roman Hros <[email protected]> Signed-off-by: Jan Schoone <[email protected]> Co-authored-by: Jan Schoone <[email protected]>
1 parent 3278995 commit c7a9268

File tree

1,058 files changed

+85491
-41571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,058 files changed

+85491
-41571
lines changed

.envrc.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export PATH="$(pwd)/hack/tools/bin/:$PATH"
22
export KUBECONFIG=$PWD/.mgt-cluster-kubeconfig.yaml
33
export CLUSTER_TOPOLOGY=true
4+
export EXP_RUNTIME_SDK=true
5+
export EXP_CLUSTER_RESOURCE_SET=true
46
export CLUSTER_NAME=test-dfkhje
57
export SECRET_NAME=supersecret
68
export CLOUD_NAME=test

.github/workflows/test.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ jobs:
6262
GIT_REPOSITORY_NAME: cluster-stacks
6363
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
6464
ENCODED_CLOUDS_YAML: ${{ secrets.ENCODED_CLOUDS_YAML }}
65+
# OCI_REGISTRY: registry.scs.community
66+
# OCI_REPOSITORY: registry.scs.community/csctl-oci/openstack
6567
run: make test-integration
6668

6769
# - name: Create Report

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ all-tools: get-dependencies $(GOTESTSUM) $(go-cover-treemap) $(go-binsize-treema
144144

145145
env-vars-for-wl-cluster:
146146
ifeq ($(wildcard tilt-settings.yaml),)
147-
@./hack/ensure-env-variables.sh GIT_PROVIDER_B64 GIT_ACCESS_TOKEN_B64 GIT_ORG_NAME_B64 GIT_REPOSITORY_NAME_B64 CLUSTER_TOPOLOGY CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
147+
@./hack/ensure-env-variables.sh GIT_PROVIDER_B64 GIT_ACCESS_TOKEN_B64 GIT_ORG_NAME_B64 GIT_REPOSITORY_NAME_B64 CLUSTER_TOPOLOGY EXP_RUNTIME_SDK CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
148148
else ifeq ($(shell awk '/local_mode:/ {print tolower($$2)}' tilt-settings.yaml),true)
149-
@./hack/ensure-env-variables.sh CLUSTER_TOPOLOGY CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
149+
@./hack/ensure-env-variables.sh CLUSTER_TOPOLOGY EXP_RUNTIME_SDK CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
150150
else
151-
@./hack/ensure-env-variables.sh GIT_PROVIDER_B64 GIT_ACCESS_TOKEN_B64 GIT_ORG_NAME_B64 GIT_REPOSITORY_NAME_B64 CLUSTER_TOPOLOGY CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
151+
@./hack/ensure-env-variables.sh GIT_PROVIDER_B64 GIT_ACCESS_TOKEN_B64 GIT_ORG_NAME_B64 GIT_REPOSITORY_NAME_B64 CLUSTER_TOPOLOGY EXP_RUNTIME_SDK CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
152152
endif
153153

154154
.PHONY: cluster
@@ -494,7 +494,7 @@ generate-modules-ci: generate-modules
494494
KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env --bin-dir $(abspath $(TOOLS_BIN_DIR)) -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))
495495

496496
.PHONY: test-integration ## Run integration tests
497-
test-integration: test-integration-github test-integration-openstack
497+
test-integration: test-integration-openstack test-integration-github #test-integration-oci
498498
echo done
499499

500500
.PHONY: test-unit
@@ -513,6 +513,12 @@ test-integration-github: $(SETUP_ENVTEST) $(GOTESTSUM)
513513
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GOTESTSUM) --junitfile=.coverage/junit.xml --format testname -- -mod=vendor \
514514
-covermode=atomic -coverprofile=.coverage/cover.out -p=1 ./internal/test/integration/github/...
515515

516+
.PHONY: test-integration-oci
517+
test-integration-oci: $(SETUP_ENVTEST) $(GOTESTSUM)
518+
@mkdir -p $(shell pwd)/.coverage
519+
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GOTESTSUM) --junitfile=.coverage/junit.xml --format testname -- -mod=vendor \
520+
-covermode=atomic -coverprofile=.coverage/cover.out -p=1 ./internal/test/integration/oci/...
521+
516522
.PHONY: test-integration-openstack
517523
test-integration-openstack: $(SETUP_ENVTEST) $(GOTESTSUM)
518524
@mkdir -p $(shell pwd)/.coverage

Tiltfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ settings = {
2222
"preload_images_for_kind": True,
2323
"kind_cluster_name": "cspo",
2424
"capi_version": "v1.6.0",
25-
"cso_version": "v0.1.0-alpha.5",
26-
"capo_version": "v0.9.0",
25+
"cso_version": "v0.1.0-alpha.7",
26+
"capo_version": "v0.10.4",
2727
"cert_manager_version": "v1.13.2",
2828
"kustomize_substitutions": {
2929
},

api/v1alpha1/conditions_const.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ const (
4040
)
4141

4242
const (
43-
// GitAPIAvailableCondition is used when Git API is available.
44-
GitAPIAvailableCondition = "GitAPIAvailable"
43+
// AssetsClientAPIAvailableCondition is used when AssetsClient API is available.
44+
AssetsClientAPIAvailableCondition = "AssetsClientAPIAvailable"
4545

46-
// GitTokenOrEnvVariableNotSetReason is used when user don't specify the token or environment variable.
47-
GitTokenOrEnvVariableNotSetReason = "GitTokenOrEnvVariableNotSet" //#nosec
46+
// FailedCreateAssetsClientReason is used when user don't specify the token or environment variable required for initializing the assets client.
47+
FailedCreateAssetsClientReason = "FailedCreateAssetsClient" //#nosec
4848
)
4949

5050
const (

cmd/main.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@ package main
1919

2020
// Import packages including all Kubernetes client auth plugins: k8s.io/client-go/plugin/pkg/client/auth.
2121
import (
22+
"errors"
2223
"flag"
2324
"os"
2425
"time"
2526

26-
githubclient "github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client"
27-
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client/fake"
27+
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient"
28+
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient/fake"
29+
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient/github"
30+
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient/oci"
2831
apiv1alpha1 "github.com/SovereignCloudStack/cluster-stack-provider-openstack/api/v1alpha1"
2932
"github.com/SovereignCloudStack/cluster-stack-provider-openstack/internal/controller"
3033
"k8s.io/apimachinery/pkg/runtime"
@@ -53,6 +56,7 @@ var (
5356
releaseDir string
5457
imageImportTimeout int
5558
localMode bool
59+
source string
5660
metricsAddr string
5761
enableLeaderElection bool
5862
probeAddr string
@@ -69,7 +73,8 @@ func main() {
6973
)
7074
flag.StringVar(&releaseDir, "release-dir", "/tmp/downloads/", "Specify release directory for cluster-stack releases")
7175
flag.IntVar(&imageImportTimeout, "image-import-timeout", 0, "Maximum time in minutes that you allow cspo to import image. If image-import-timeout <= 0, cspo waits forever.")
72-
flag.BoolVar(&localMode, "local", false, "Enable local mode where no release assets will be downloaded from a remote Git repository. Useful for implementing cluster stacks.")
76+
flag.BoolVar(&localMode, "local", false, "Enable local mode where no release assets will be downloaded from a remote repository. Useful for implementing cluster stacks.")
77+
flag.StringVar(&source, "source", "github", "Specifies the source from which release assets would be downloaded. Allowed sources are 'github' and 'oci'")
7378

7479
opts := zap.Options{
7580
Development: true,
@@ -100,18 +105,26 @@ func main() {
100105
// Initialize event recorder.
101106
record.InitFromRecorder(mgr.GetEventRecorderFor("cspo-controller"))
102107

103-
var gitFactory githubclient.Factory
108+
var assetsClientFactory assetsclient.Factory
104109
if localMode {
105-
gitFactory = fake.NewFactory()
110+
assetsClientFactory = fake.NewFactory()
106111
} else {
107-
gitFactory = githubclient.NewFactory()
112+
switch source {
113+
case "oci":
114+
assetsClientFactory = oci.NewFactory()
115+
case "github":
116+
assetsClientFactory = github.NewFactory()
117+
default:
118+
setupLog.Error(errors.New("invalid asset source"), "no valid source specified, allowed sources are 'github' and 'oci'")
119+
os.Exit(1)
120+
}
108121
}
109122

110123
if err = (&controller.OpenStackClusterStackReleaseReconciler{
111124
Client: mgr.GetClient(),
112125
Scheme: mgr.GetScheme(),
113126
ReleaseDirectory: releaseDir,
114-
GitHubClientFactory: gitFactory,
127+
AssetsClientFactory: assetsClientFactory,
115128
}).SetupWithManager(mgr); err != nil {
116129
setupLog.Error(err, "unable to create controller", "controller", "OpenStackClusterStackRelease")
117130
os.Exit(1)

config/manager/credentials.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,8 @@ data:
99
git-org-name: ${GIT_ORG_NAME_B64:=""}
1010
git-repo-name: ${GIT_REPOSITORY_NAME_B64:=""}
1111
git-access-token: ${GIT_ACCESS_TOKEN_B64:=""}
12+
oci-registry: ${OCI_REGISTRY_B64:=""}
13+
oci-repository: ${OCI_REPOSITORY_B64:=""}
14+
oci-access-token: ${OCI_ACCESS_TOKEN_B64:=""}
15+
oci-username: ${OCI_USERNAME_B64:=""}
16+
oci-password: ${OCI_PASSWORD_B64:=""}

config/manager/manager.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,31 @@ spec:
6262
secretKeyRef:
6363
name: cspo-cluster-stack-variables
6464
key: git-access-token
65+
- name: OCI_REGISTRY
66+
valueFrom:
67+
secretKeyRef:
68+
name: cspo-cluster-stack-variables
69+
key: oci-registry
70+
- name: OCI_REPOSITORY
71+
valueFrom:
72+
secretKeyRef:
73+
name: cspo-cluster-stack-variables
74+
key: oci-repository
75+
- name: OCI_ACCESS_TOKEN
76+
valueFrom:
77+
secretKeyRef:
78+
name: cspo-cluster-stack-variables
79+
key: oci-access-token
80+
- name: OCI_USERNAME
81+
valueFrom:
82+
secretKeyRef:
83+
name: cspo-cluster-stack-variables
84+
key: oci-username
85+
- name: OCI_PASSWORD
86+
valueFrom:
87+
secretKeyRef:
88+
name: cspo-cluster-stack-variables
89+
key: oci-password
6590
image: controller:latest
6691
name: manager
6792
securityContext:

config/rbac/role.yaml

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,31 +24,6 @@ rules:
2424
- infrastructure.clusterstack.x-k8s.io
2525
resources:
2626
- openstackclusterstackreleases
27-
verbs:
28-
- create
29-
- delete
30-
- get
31-
- list
32-
- patch
33-
- update
34-
- watch
35-
- apiGroups:
36-
- infrastructure.clusterstack.x-k8s.io
37-
resources:
38-
- openstackclusterstackreleases/finalizers
39-
verbs:
40-
- update
41-
- apiGroups:
42-
- infrastructure.clusterstack.x-k8s.io
43-
resources:
44-
- openstackclusterstackreleases/status
45-
verbs:
46-
- get
47-
- patch
48-
- update
49-
- apiGroups:
50-
- infrastructure.clusterstack.x-k8s.io
51-
resources:
5227
- openstacknodeimagereleases
5328
verbs:
5429
- create
@@ -61,12 +36,14 @@ rules:
6136
- apiGroups:
6237
- infrastructure.clusterstack.x-k8s.io
6338
resources:
39+
- openstackclusterstackreleases/finalizers
6440
- openstacknodeimagereleases/finalizers
6541
verbs:
6642
- update
6743
- apiGroups:
6844
- infrastructure.clusterstack.x-k8s.io
6945
resources:
46+
- openstackclusterstackreleases/status
7047
- openstacknodeimagereleases/status
7148
verbs:
7249
- get

docs/develop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ If you have any trouble finding the right command, then you can use `make help`
6060

6161
## Toggle between local_mode and remote mode
6262

63-
We can retrieve cluster-stacks in two modes. One way is to let the controller fetch it from GitHub which is remote mode and other is we mount the cluster-stacks inside the container at `/tmp/downloads/cluster-stacks` directory.
63+
We can retrieve cluster-stacks in two modes. One way is to let the controller fetch it from repository which is remote mode and other is we mount the cluster-stacks inside the container at `/tmp/downloads/cluster-stacks` directory.
6464

6565
> [!NOTE]
6666
> Using remote mode is the default behavior.

0 commit comments

Comments
 (0)