Skip to content

Commit

Permalink
Merge branch 'main' into renovate/cspo-builder-image
Browse files Browse the repository at this point in the history
Signed-off-by: Roman Hros <roman.hros@dnation.cloud>
  • Loading branch information
chess-knight committed Sep 10, 2024
2 parents 587f4ab + c7a9268 commit af90338
Show file tree
Hide file tree
Showing 1,071 changed files with 85,528 additions and 41,600 deletions.
2 changes: 1 addition & 1 deletion .builder-image-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.3
0.1.4
2 changes: 2 additions & 0 deletions .envrc.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export PATH="$(pwd)/hack/tools/bin/:$PATH"
export KUBECONFIG=$PWD/.mgt-cluster-kubeconfig.yaml
export CLUSTER_TOPOLOGY=true
export EXP_RUNTIME_SDK=true
export EXP_CLUSTER_RESOURCE_SET=true
export CLUSTER_NAME=test-dfkhje
export SECRET_NAME=supersecret
export CLOUD_NAME=test
Expand Down
1 change: 1 addition & 0 deletions .github/actions/setup-go/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ runs:
- name: Install go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: "1.22"
go-version-file: "go.mod"
cache: true
cache-dependency-path: go.sum
Expand Down
2 changes: 1 addition & 1 deletion .github/renovate/golang.json5
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
},
// https://docs.renovatebot.com/configuration-options/#constraints
"constraints": {
"go": "1.21"
"go": "1.22"
},
packageRules: [
{
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pr-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
if: github.event_name != 'pull_request' || !github.event.pull_request.draft
runs-on: ubuntu-latest
container:
image: ghcr.io/sovereigncloudstack/cspo-builder:0.1.3
image: ghcr.io/sovereigncloudstack/cspo-builder:0.1.4
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
Expand All @@ -32,6 +32,8 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: ./.github/actions/setup-go

- name: Fixup git permissions
# https://github.com/actions/checkout/issues/766
shell: bash
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ jobs:
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, mode=max, scope=${{ github.workflow }}


- name: Sign Container Images
run: |
cosign sign --yes ghcr.io/sovereigncloudstack/cspo@${{ steps.docker_build_release_cspo.outputs.digest }}
Expand Down Expand Up @@ -140,11 +139,7 @@ jobs:
fetch-depth: 0

- name: Install go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version-file: "go.mod"
cache: true
cache-dependency-path: go.sum
uses: ./.github/actions/setup-go

- name: install kustomize
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule-scan-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Trivy
runs-on: ubuntu-latest
container:
image: ghcr.io/sovereigncloudstack/cspo-builder:0.1.3
image: ghcr.io/sovereigncloudstack/cspo-builder:0.1.4
credentials:
username: ${{ github.actor }}
password: ${{ secrets.github_token }}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ jobs:
GIT_REPOSITORY_NAME: cluster-stacks
GIT_ACCESS_TOKEN: ${{ secrets.GIT_ACCESS_TOKEN }}
ENCODED_CLOUDS_YAML: ${{ secrets.ENCODED_CLOUDS_YAML }}
# OCI_REGISTRY: registry.scs.community
# OCI_REPOSITORY: registry.scs.community/csctl-oci/openstack
run: make test-integration

# - name: Create Report
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ tmp_*
.cspotemplate.yaml
.secret.yaml
.release

.config
27 changes: 17 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ linters:
- bodyclose
- containedctx
- contextcheck
- copyloopvar
- durationcheck
- errchkjson
- errname
- errorlint
- exhaustive
- exportloopref
- forcetypeassert
- gci
# - goconst
Expand Down Expand Up @@ -86,10 +86,6 @@ linters-settings:
allow-unused: false
allow-leading-space: false
require-specific: true
staticcheck:
go: "1.21"
stylecheck:
go: "1.21"
checks: ["all", "-ST1006"]
dot-import-whitelist:
- "github.com/onsi/gomega"
Expand All @@ -101,6 +97,9 @@ linters-settings:
- performance
- experimental
- opinionated
settings:
hugeParam:
sizeThreshold: 120
revive:
enable-all-rules: true
rules:
Expand Down Expand Up @@ -141,7 +140,14 @@ linters-settings:
severity: warning
disabled: false
arguments:
- [ "call-chain", "loop", "method-call", "recover", "immediate-recover", "return"] # yamllint disable-line rule:line-length
- [
"call-chain",
"loop",
"method-call",
"recover",
"immediate-recover",
"return",
] # yamllint disable-line rule:line-length
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#exported
- name: exported
severity: warning
Expand Down Expand Up @@ -224,7 +230,7 @@ linters-settings:
- name: struct-tag
disabled: true
unused:
go: "1.21"
go: "1.22"
usestdlibvars:
# Suggest the use of http.MethodXX.
# Default: true
Expand Down Expand Up @@ -285,10 +291,11 @@ issues:
- linters:
- wrapcheck
path: _test\.go
exclude-dirs:
- vendor$

run:
timeout: 10m
go: "1.21"
go: "1.22"
allow-parallel-runners: true
modules-download-mode: vendor
skip-dirs:
- vendor$
18 changes: 12 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.28.0
CONTROLLER_GEN := $(abspath $(TOOLS_BIN_DIR)/controller-gen)
controller-gen: $(CONTROLLER_GEN) ## Build a local copy of controller-gen
$(CONTROLLER_GEN): # Build controller-gen from tools folder.
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.14.0
go install sigs.k8s.io/controller-tools/cmd/controller-gen@v0.16.2

KUSTOMIZE := $(abspath $(TOOLS_BIN_DIR)/kustomize)
kustomize: $(KUSTOMIZE) ## Build a local copy of kustomize
Expand Down Expand Up @@ -144,11 +144,11 @@ all-tools: get-dependencies $(GOTESTSUM) $(go-cover-treemap) $(go-binsize-treema

env-vars-for-wl-cluster:
ifeq ($(wildcard tilt-settings.yaml),)
@./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
@./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
else ifeq ($(shell awk '/local_mode:/ {print tolower($$2)}' tilt-settings.yaml),true)
@./hack/ensure-env-variables.sh CLUSTER_TOPOLOGY CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
@./hack/ensure-env-variables.sh CLUSTER_TOPOLOGY EXP_RUNTIME_SDK CLUSTER_NAME SECRET_NAME CLOUD_NAME ENCODED_CLOUDS_YAML
else
@./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
@./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
endif

.PHONY: cluster
Expand Down Expand Up @@ -338,7 +338,7 @@ ifeq ($(BUILD_IN_CONTAINER),true)
else
go version
golangci-lint version
golangci-lint run -v --out-format=github-actions
golangci-lint run -v --out-format=colored-line-number
endif

.PHONY: lint-yaml
Expand Down Expand Up @@ -494,7 +494,7 @@ generate-modules-ci: generate-modules
KUBEBUILDER_ASSETS ?= $(shell $(SETUP_ENVTEST) use --use-env --bin-dir $(abspath $(TOOLS_BIN_DIR)) -p path $(KUBEBUILDER_ENVTEST_KUBERNETES_VERSION))

.PHONY: test-integration ## Run integration tests
test-integration: test-integration-github test-integration-openstack
test-integration: test-integration-openstack test-integration-github #test-integration-oci
echo done

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

.PHONY: test-integration-oci
test-integration-oci: $(SETUP_ENVTEST) $(GOTESTSUM)
@mkdir -p $(shell pwd)/.coverage
KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" $(GOTESTSUM) --junitfile=.coverage/junit.xml --format testname -- -mod=vendor \
-covermode=atomic -coverprofile=.coverage/cover.out -p=1 ./internal/test/integration/oci/...

.PHONY: test-integration-openstack
test-integration-openstack: $(SETUP_ENVTEST) $(GOTESTSUM)
@mkdir -p $(shell pwd)/.coverage
Expand Down
4 changes: 2 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ settings = {
"preload_images_for_kind": True,
"kind_cluster_name": "cspo",
"capi_version": "v1.6.0",
"cso_version": "v0.1.0-alpha.5",
"capo_version": "v0.9.0",
"cso_version": "v0.1.0-alpha.7",
"capo_version": "v0.10.4",
"cert_manager_version": "v1.13.2",
"kustomize_substitutions": {
},
Expand Down
8 changes: 4 additions & 4 deletions api/v1alpha1/conditions_const.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ const (
)

const (
// GitAPIAvailableCondition is used when Git API is available.
GitAPIAvailableCondition = "GitAPIAvailable"
// AssetsClientAPIAvailableCondition is used when AssetsClient API is available.
AssetsClientAPIAvailableCondition = "AssetsClientAPIAvailable"

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

const (
Expand Down
27 changes: 20 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ package main

// Import packages including all Kubernetes client auth plugins: k8s.io/client-go/plugin/pkg/client/auth.
import (
"errors"
"flag"
"os"
"time"

githubclient "github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client"
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/github/client/fake"
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient"
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient/fake"
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient/github"
"github.com/SovereignCloudStack/cluster-stack-operator/pkg/assetsclient/oci"
apiv1alpha1 "github.com/SovereignCloudStack/cluster-stack-provider-openstack/api/v1alpha1"
"github.com/SovereignCloudStack/cluster-stack-provider-openstack/internal/controller"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -53,6 +56,7 @@ var (
releaseDir string
imageImportTimeout int
localMode bool
source string
metricsAddr string
enableLeaderElection bool
probeAddr string
Expand All @@ -69,7 +73,8 @@ func main() {
)
flag.StringVar(&releaseDir, "release-dir", "/tmp/downloads/", "Specify release directory for cluster-stack releases")
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.")
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.")
flag.BoolVar(&localMode, "local", false, "Enable local mode where no release assets will be downloaded from a remote repository. Useful for implementing cluster stacks.")
flag.StringVar(&source, "source", "github", "Specifies the source from which release assets would be downloaded. Allowed sources are 'github' and 'oci'")

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

var gitFactory githubclient.Factory
var assetsClientFactory assetsclient.Factory
if localMode {
gitFactory = fake.NewFactory()
assetsClientFactory = fake.NewFactory()
} else {
gitFactory = githubclient.NewFactory()
switch source {
case "oci":
assetsClientFactory = oci.NewFactory()
case "github":
assetsClientFactory = github.NewFactory()
default:
setupLog.Error(errors.New("invalid asset source"), "no valid source specified, allowed sources are 'github' and 'oci'")
os.Exit(1)
}
}

if err = (&controller.OpenStackClusterStackReleaseReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
ReleaseDirectory: releaseDir,
GitHubClientFactory: gitFactory,
AssetsClientFactory: assetsClientFactory,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "OpenStackClusterStackRelease")
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.2
name: openstackclusterstackreleases.infrastructure.clusterstack.x-k8s.io
spec:
group: infrastructure.clusterstack.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.2
name: openstackclusterstackreleasetemplates.infrastructure.clusterstack.x-k8s.io
spec:
group: infrastructure.clusterstack.x-k8s.io
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.16.2
name: openstacknodeimagereleases.infrastructure.clusterstack.x-k8s.io
spec:
group: infrastructure.clusterstack.x-k8s.io
Expand Down
5 changes: 5 additions & 0 deletions config/manager/credentials.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ data:
git-org-name: ${GIT_ORG_NAME_B64:=""}
git-repo-name: ${GIT_REPOSITORY_NAME_B64:=""}
git-access-token: ${GIT_ACCESS_TOKEN_B64:=""}
oci-registry: ${OCI_REGISTRY_B64:=""}
oci-repository: ${OCI_REPOSITORY_B64:=""}
oci-access-token: ${OCI_ACCESS_TOKEN_B64:=""}
oci-username: ${OCI_USERNAME_B64:=""}
oci-password: ${OCI_PASSWORD_B64:=""}
25 changes: 25 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,31 @@ spec:
secretKeyRef:
name: cspo-cluster-stack-variables
key: git-access-token
- name: OCI_REGISTRY
valueFrom:
secretKeyRef:
name: cspo-cluster-stack-variables
key: oci-registry
- name: OCI_REPOSITORY
valueFrom:
secretKeyRef:
name: cspo-cluster-stack-variables
key: oci-repository
- name: OCI_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: cspo-cluster-stack-variables
key: oci-access-token
- name: OCI_USERNAME
valueFrom:
secretKeyRef:
name: cspo-cluster-stack-variables
key: oci-username
- name: OCI_PASSWORD
valueFrom:
secretKeyRef:
name: cspo-cluster-stack-variables
key: oci-password
image: controller:latest
name: manager
securityContext:
Expand Down
Loading

0 comments on commit af90338

Please sign in to comment.