mirror of
https://github.com/clastix/kamaji.git
synced 2026-02-14 18:10:03 +00:00
refactor(golangci-lint): aligning to new linters
Signed-off-by: Dario Tranchitella <dario@tranchitella.eu>
This commit is contained in:
2
.github/workflows/ci.yaml
vendored
2
.github/workflows/ci.yaml
vendored
@@ -19,7 +19,7 @@ jobs:
|
|||||||
- name: Run golangci-lint
|
- name: Run golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3.2.0
|
uses: golangci/golangci-lint-action@v3.2.0
|
||||||
with:
|
with:
|
||||||
version: v1.49.0
|
version: v1.54.2
|
||||||
only-new-issues: false
|
only-new-issues: false
|
||||||
args: --timeout 5m --config .golangci.yml
|
args: --timeout 5m --config .golangci.yml
|
||||||
diff:
|
diff:
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ linters-settings:
|
|||||||
|
|
||||||
linters:
|
linters:
|
||||||
disable:
|
disable:
|
||||||
|
- depguard
|
||||||
- wrapcheck
|
- wrapcheck
|
||||||
- gomnd
|
- gomnd
|
||||||
- scopelint
|
- scopelint
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -89,7 +89,7 @@ controller-gen: ## Download controller-gen locally if necessary.
|
|||||||
|
|
||||||
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
|
GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
|
||||||
golangci-lint: ## Download golangci-lint locally if necessary.
|
golangci-lint: ## Download golangci-lint locally if necessary.
|
||||||
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.49.0)
|
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54.2)
|
||||||
|
|
||||||
KUSTOMIZE = $(shell pwd)/bin/kustomize
|
KUSTOMIZE = $(shell pwd)/bin/kustomize
|
||||||
kustomize: ## Download kustomize locally if necessary.
|
kustomize: ## Download kustomize locally if necessary.
|
||||||
|
|||||||
@@ -4,9 +4,6 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
_ "go.uber.org/automaxprocs" // Automatically set `GOMAXPROCS` to match Linux container CPU quota.
|
_ "go.uber.org/automaxprocs" // Automatically set `GOMAXPROCS` to match Linux container CPU quota.
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
@@ -22,9 +19,6 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command {
|
|||||||
Use: "kamaji",
|
Use: "kamaji",
|
||||||
Short: "Build and operate Kubernetes at scale with a fraction of operational burden.",
|
Short: "Build and operate Kubernetes at scale with a fraction of operational burden.",
|
||||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
// Seed is required to ensure non reproducibility for the certificates generate by Kamaji.
|
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
|
|
||||||
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
|
utilruntime.Must(clientgoscheme.AddToScheme(scheme))
|
||||||
utilruntime.Must(kamajiv1alpha1.AddToScheme(scheme))
|
utilruntime.Must(kamajiv1alpha1.AddToScheme(scheme))
|
||||||
utilruntime.Must(appsv1.RegisterDefaults(scheme))
|
utilruntime.Must(appsv1.RegisterDefaults(scheme))
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ type CoreDNS struct {
|
|||||||
TriggerChannel chan event.GenericEvent
|
TriggerChannel chan event.GenericEvent
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CoreDNS) Reconcile(ctx context.Context, request reconcile.Request) (reconcile.Result, error) {
|
func (c *CoreDNS) Reconcile(ctx context.Context, _ reconcile.Request) (reconcile.Result, error) {
|
||||||
tcp, err := c.GetTenantControlPlaneFunc()
|
tcp, err := c.GetTenantControlPlaneFunc()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.logger.Error(err, "cannot retrieve TenantControlPlane")
|
c.logger.Error(err, "cannot retrieve TenantControlPlane")
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
|
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
|
||||||
"k8s.io/apimachinery/pkg/api/errors"
|
"k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
controllerruntime "sigs.k8s.io/controller-runtime"
|
controllerruntime "sigs.k8s.io/controller-runtime"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/builder"
|
"sigs.k8s.io/controller-runtime/pkg/builder"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
@@ -84,7 +84,7 @@ func (m *Migrate) createOrUpdate(ctx context.Context) error {
|
|||||||
{
|
{
|
||||||
Name: "leases.migrate.kamaji.clastix.io",
|
Name: "leases.migrate.kamaji.clastix.io",
|
||||||
ClientConfig: admissionregistrationv1.WebhookClientConfig{
|
ClientConfig: admissionregistrationv1.WebhookClientConfig{
|
||||||
URL: pointer.String(fmt.Sprintf("https://%s.%s.svc:443/migrate", m.WebhookServiceName, m.WebhookNamespace)),
|
URL: pointer.To(fmt.Sprintf("https://%s.%s.svc:443/migrate", m.WebhookServiceName, m.WebhookNamespace)),
|
||||||
CABundle: m.WebhookCABundle,
|
CABundle: m.WebhookCABundle,
|
||||||
},
|
},
|
||||||
Rules: []admissionregistrationv1.RuleWithOperations{
|
Rules: []admissionregistrationv1.RuleWithOperations{
|
||||||
@@ -128,7 +128,7 @@ func (m *Migrate) createOrUpdate(ctx context.Context) error {
|
|||||||
{
|
{
|
||||||
Name: "catchall.migrate.kamaji.clastix.io",
|
Name: "catchall.migrate.kamaji.clastix.io",
|
||||||
ClientConfig: admissionregistrationv1.WebhookClientConfig{
|
ClientConfig: admissionregistrationv1.WebhookClientConfig{
|
||||||
URL: pointer.String(fmt.Sprintf("https://%s.%s.svc:443/migrate", m.WebhookServiceName, m.WebhookNamespace)),
|
URL: pointer.To(fmt.Sprintf("https://%s.%s.svc:443/migrate", m.WebhookServiceName, m.WebhookNamespace)),
|
||||||
CABundle: m.WebhookCABundle,
|
CABundle: m.WebhookCABundle,
|
||||||
},
|
},
|
||||||
Rules: []admissionregistrationv1.RuleWithOperations{
|
Rules: []admissionregistrationv1.RuleWithOperations{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
"k8s.io/client-go/kubernetes/scheme"
|
"k8s.io/client-go/kubernetes/scheme"
|
||||||
"k8s.io/client-go/rest"
|
"k8s.io/client-go/rest"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
||||||
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
@@ -44,7 +44,7 @@ var _ = BeforeSuite(func() {
|
|||||||
|
|
||||||
By("bootstrapping test environment")
|
By("bootstrapping test environment")
|
||||||
testEnv = &envtest.Environment{
|
testEnv = &envtest.Environment{
|
||||||
UseExistingCluster: pointer.Bool(true),
|
UseExistingCluster: pointer.To(true),
|
||||||
}
|
}
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -27,7 +27,7 @@ var _ = Describe("Deploy a TenantControlPlane resource with additional resources
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
AdditionalInitContainers: []corev1.Container{{
|
AdditionalInitContainers: []corev1.Container{{
|
||||||
Name: initContainerName,
|
Name: initContainerName,
|
||||||
Image: initContainerImage,
|
Image: initContainerImage,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
"github.com/clastix/kamaji/internal/utilities"
|
"github.com/clastix/kamaji/internal/utilities"
|
||||||
@@ -43,7 +43,7 @@ var _ = Describe("Deploy a TenantControlPlane resource with additional options",
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
AdditionalInitContainers: []corev1.Container{{
|
AdditionalInitContainers: []corev1.Container{{
|
||||||
Name: initContainerName,
|
Name: initContainerName,
|
||||||
Image: initContainerImage,
|
Image: initContainerImage,
|
||||||
@@ -256,7 +256,7 @@ var _ = Describe("Deploy a TenantControlPlane resource with additional options",
|
|||||||
}, &deploy)).NotTo(HaveOccurred())
|
}, &deploy)).NotTo(HaveOccurred())
|
||||||
|
|
||||||
return deploy.Spec.Template.Spec.InitContainers
|
return deploy.Spec.Template.Spec.InitContainers
|
||||||
}, 10*time.Second, time.Second).Should(HaveLen(0), "Deployment should not contain anymore the init container")
|
}, 10*time.Second, time.Second).Should(BeEmpty(), "Deployment should not contain anymore the init container")
|
||||||
|
|
||||||
Eventually(func() bool {
|
Eventually(func() bool {
|
||||||
deploy := appsv1.Deployment{}
|
deploy := appsv1.Deployment{}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/rand"
|
"k8s.io/apimachinery/pkg/util/rand"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
|
ctrlclient "sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
@@ -36,7 +36,7 @@ var _ = Describe("When migrating a Tenant Control Plane to another datastore", f
|
|||||||
DataStore: "etcd-bronze",
|
DataStore: "etcd-bronze",
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "NodePort",
|
ServiceType: "NodePort",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -25,7 +25,7 @@ var _ = Describe("Deploy a TenantControlPlane resource with the MySQL driver", f
|
|||||||
DataStore: "mysql-bronze",
|
DataStore: "mysql-bronze",
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -25,7 +25,7 @@ var _ = Describe("Deploy a TenantControlPlane resource with the PostgreSQL drive
|
|||||||
DataStore: "postgresql-bronze",
|
DataStore: "postgresql-bronze",
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -24,7 +24,7 @@ var _ = Describe("Deploy a TenantControlPlane resource", func() {
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
. "github.com/onsi/ginkgo/v2"
|
. "github.com/onsi/ginkgo/v2"
|
||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -27,7 +27,7 @@ var _ = Describe("Deploy a TenantControlPlane with wrong preferred kubelet addre
|
|||||||
DataStore: "default",
|
DataStore: "default",
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
@@ -63,7 +63,7 @@ var _ = Describe("Deploy a TenantControlPlane with wrong preferred kubelet addre
|
|||||||
DataStore: "default",
|
DataStore: "default",
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -26,7 +26,7 @@ var _ = Describe("downgrade of a TenantControlPlane Kubernetes version", func()
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -26,7 +26,7 @@ var _ = Describe("non-linear minor upgrade of a TenantControlPlane Kubernetes ve
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
. "github.com/onsi/gomega"
|
. "github.com/onsi/gomega"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
"github.com/clastix/kamaji/internal/upgrade"
|
"github.com/clastix/kamaji/internal/upgrade"
|
||||||
@@ -36,7 +36,7 @@ var _ = Describe("using an unsupported TenantControlPlane Kubernetes version", f
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
@@ -64,7 +64,7 @@ var _ = Describe("using an unsupported TenantControlPlane Kubernetes version", f
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "ClusterIP",
|
ServiceType: "ClusterIP",
|
||||||
|
|||||||
@@ -19,9 +19,9 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
kubeadmv1beta3 "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd"
|
"k8s.io/kubernetes/cmd/kubeadm/app/cmd"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/cmd/util"
|
pointer "k8s.io/utils/ptr"
|
||||||
"k8s.io/utils/pointer"
|
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -44,7 +44,7 @@ var _ = Describe("starting a kind worker with kubeadm", func() {
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "NodePort",
|
ServiceType: "NodePort",
|
||||||
@@ -121,7 +121,7 @@ var _ = Describe("starting a kind worker with kubeadm", func() {
|
|||||||
var joinCommandBuffer *bytes.Buffer
|
var joinCommandBuffer *bytes.Buffer
|
||||||
|
|
||||||
By("generating kubeadm join command", func() {
|
By("generating kubeadm join command", func() {
|
||||||
joinCommandBuffer = bytes.NewBuffer([]byte(""))
|
joinCommandBuffer = bytes.NewBufferString("")
|
||||||
|
|
||||||
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigFile.Name())
|
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigFile.Name())
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
@@ -129,7 +129,7 @@ var _ = Describe("starting a kind worker with kubeadm", func() {
|
|||||||
clientset, err := kubernetes.NewForConfig(config)
|
clientset, err := kubernetes.NewForConfig(config)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
Expect(cmd.RunCreateToken(joinCommandBuffer, clientset, "", util.DefaultInitConfiguration(), true, "", kubeconfigFile.Name())).ToNot(HaveOccurred())
|
Expect(cmd.RunCreateToken(joinCommandBuffer, clientset, "", &kubeadmv1beta3.InitConfiguration{}, true, "", kubeconfigFile.Name())).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
By("executing the command in the worker node", func() {
|
By("executing the command in the worker node", func() {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/version"
|
"k8s.io/apimachinery/pkg/version"
|
||||||
"k8s.io/client-go/kubernetes"
|
"k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/clientcmd"
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
)
|
)
|
||||||
@@ -39,7 +39,7 @@ var _ = Describe("validating kubeconfig", func() {
|
|||||||
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
Spec: kamajiv1alpha1.TenantControlPlaneSpec{
|
||||||
ControlPlane: kamajiv1alpha1.ControlPlane{
|
ControlPlane: kamajiv1alpha1.ControlPlane{
|
||||||
Deployment: kamajiv1alpha1.DeploymentSpec{
|
Deployment: kamajiv1alpha1.DeploymentSpec{
|
||||||
Replicas: pointer.Int32(1),
|
Replicas: pointer.To(int32(1)),
|
||||||
},
|
},
|
||||||
Service: kamajiv1alpha1.ServiceSpec{
|
Service: kamajiv1alpha1.ServiceSpec{
|
||||||
ServiceType: "NodePort",
|
ServiceType: "NodePort",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm/v1beta3"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
"k8s.io/kubernetes/cmd/kubeadm/app/constants"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
@@ -224,7 +224,7 @@ func (d Deployment) buildPKIVolume(podSpec *corev1.PodSpec, tcp kamajiv1alpha1.T
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Projected: &corev1.ProjectedVolumeSource{
|
Projected: &corev1.ProjectedVolumeSource{
|
||||||
Sources: sources,
|
Sources: sources,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -240,7 +240,7 @@ func (d Deployment) buildCAVolume(podSpec *corev1.PodSpec, tcp kamajiv1alpha1.Te
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.Certificates.CA.SecretName,
|
SecretName: tcp.Status.Certificates.CA.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ func (d Deployment) buildSSLCertsVolume(podSpec *corev1.PodSpec, tcp kamajiv1alp
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.Certificates.CA.SecretName,
|
SecretName: tcp.Status.Certificates.CA.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ func (d Deployment) buildShareCAVolume(podSpec *corev1.PodSpec, tcp kamajiv1alph
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.Certificates.CA.SecretName,
|
SecretName: tcp.Status.Certificates.CA.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ func (d Deployment) buildLocalShareCAVolume(podSpec *corev1.PodSpec, tcp kamajiv
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.Certificates.CA.SecretName,
|
SecretName: tcp.Status.Certificates.CA.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ func (d Deployment) buildSchedulerVolume(podSpec *corev1.PodSpec, tcp kamajiv1al
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.KubeConfig.Scheduler.SecretName,
|
SecretName: tcp.Status.KubeConfig.Scheduler.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -320,7 +320,7 @@ func (d Deployment) buildControllerManagerVolume(podSpec *corev1.PodSpec, tcp ka
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.KubeConfig.ControllerManager.SecretName,
|
SecretName: tcp.Status.KubeConfig.ControllerManager.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -776,7 +776,7 @@ func (d Deployment) buildKineVolume(podSpec *corev1.PodSpec, tcp kamajiv1alpha1.
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: tcp.Status.Storage.Certificate.SecretName,
|
SecretName: tcp.Status.Storage.Certificate.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// Adding the volume to read Kine certificates:
|
// Adding the volume to read Kine certificates:
|
||||||
@@ -933,7 +933,7 @@ func (d Deployment) setReplicas(deploymentSpec *appsv1.DeploymentSpec, tcp kamaj
|
|||||||
|
|
||||||
func (d Deployment) setRuntimeClass(spec *corev1.PodSpec, tcp kamajiv1alpha1.TenantControlPlane) {
|
func (d Deployment) setRuntimeClass(spec *corev1.PodSpec, tcp kamajiv1alpha1.TenantControlPlane) {
|
||||||
if len(tcp.Spec.ControlPlane.Deployment.RuntimeClassName) > 0 {
|
if len(tcp.Spec.ControlPlane.Deployment.RuntimeClassName) > 0 {
|
||||||
spec.RuntimeClassName = pointer.String(tcp.Spec.ControlPlane.Deployment.RuntimeClassName)
|
spec.RuntimeClassName = pointer.To(tcp.Spec.ControlPlane.Deployment.RuntimeClassName)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
"github.com/clastix/kamaji/internal/utilities"
|
"github.com/clastix/kamaji/internal/utilities"
|
||||||
@@ -186,7 +186,7 @@ func (k Konnectivity) buildVolumeMounts(podSpec *corev1.PodSpec) {
|
|||||||
|
|
||||||
podSpec.Containers[index].Args = utilities.ArgsFromMapToSlice(args)
|
podSpec.Containers[index].Args = utilities.ArgsFromMapToSlice(args)
|
||||||
|
|
||||||
vFound, vIndex := false, 0
|
vFound, vIndex := false, 0 //nolint:wastedassign
|
||||||
// Patching the volume mounts
|
// Patching the volume mounts
|
||||||
if vFound, vIndex = utilities.HasNamedVolumeMount(podSpec.Containers[index].VolumeMounts, konnectivityUDSVolume); !vFound {
|
if vFound, vIndex = utilities.HasNamedVolumeMount(podSpec.Containers[index].VolumeMounts, konnectivityUDSVolume); !vFound {
|
||||||
vIndex = len(podSpec.Containers[index].VolumeMounts)
|
vIndex = len(podSpec.Containers[index].VolumeMounts)
|
||||||
@@ -208,9 +208,8 @@ func (k Konnectivity) buildVolumeMounts(podSpec *corev1.PodSpec) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (k Konnectivity) buildVolumes(status kamajiv1alpha1.KonnectivityStatus, podSpec *corev1.PodSpec) {
|
func (k Konnectivity) buildVolumes(status kamajiv1alpha1.KonnectivityStatus, podSpec *corev1.PodSpec) {
|
||||||
found, index := false, 0
|
|
||||||
// Defining volumes for the UDS socket
|
// Defining volumes for the UDS socket
|
||||||
found, index = utilities.HasNamedVolume(podSpec.Volumes, konnectivityUDSVolume)
|
found, index := utilities.HasNamedVolume(podSpec.Volumes, konnectivityUDSVolume)
|
||||||
if !found {
|
if !found {
|
||||||
index = len(podSpec.Volumes)
|
index = len(podSpec.Volumes)
|
||||||
podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{})
|
podSpec.Volumes = append(podSpec.Volumes, corev1.Volume{})
|
||||||
@@ -235,7 +234,7 @@ func (k Konnectivity) buildVolumes(status kamajiv1alpha1.KonnectivityStatus, pod
|
|||||||
LocalObjectReference: corev1.LocalObjectReference{
|
LocalObjectReference: corev1.LocalObjectReference{
|
||||||
Name: status.ConfigMap.Name,
|
Name: status.ConfigMap.Name,
|
||||||
},
|
},
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// Defining volume for the Konnectivity kubeconfig
|
// Defining volume for the Konnectivity kubeconfig
|
||||||
@@ -249,7 +248,7 @@ func (k Konnectivity) buildVolumes(status kamajiv1alpha1.KonnectivityStatus, pod
|
|||||||
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
podSpec.Volumes[index].VolumeSource = corev1.VolumeSource{
|
||||||
Secret: &corev1.SecretVolumeSource{
|
Secret: &corev1.SecretVolumeSource{
|
||||||
SecretName: status.Kubeconfig.SecretName,
|
SecretName: status.Kubeconfig.SecretName,
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ func NewStorageConnection(ctx context.Context, client client.Client, ds kamajiv1
|
|||||||
return NewMySQLConnection(*cc)
|
return NewMySQLConnection(*cc)
|
||||||
case kamajiv1alpha1.KinePostgreSQLDriver:
|
case kamajiv1alpha1.KinePostgreSQLDriver:
|
||||||
cc.TLSConfig.ServerName = cc.Endpoints[0].Host
|
cc.TLSConfig.ServerName = cc.Endpoints[0].Host
|
||||||
//nolint:contextcheck
|
|
||||||
return NewPostgreSQLConnection(*cc)
|
return NewPostgreSQLConnection(*cc)
|
||||||
case kamajiv1alpha1.EtcdDriver:
|
case kamajiv1alpha1.EtcdDriver:
|
||||||
return NewETCDConnection(*cc)
|
return NewETCDConnection(*cc)
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ func (e *EtcdClient) DeleteDB(ctx context.Context, dbName string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *EtcdClient) RevokePrivileges(ctx context.Context, user, dbName string) error {
|
func (e *EtcdClient) RevokePrivileges(ctx context.Context, _, dbName string) error {
|
||||||
if _, err := e.Client.Auth.RoleDelete(ctx, dbName); err != nil {
|
if _, err := e.Client.Auth.RoleDelete(ctx, dbName); err != nil {
|
||||||
return errors.NewRevokePrivilegesError(err)
|
return errors.NewRevokePrivilegesError(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,13 +216,17 @@ func (c *MySQLConnection) DBExists(ctx context.Context, dbName string) (bool, er
|
|||||||
return ok, nil
|
return ok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *MySQLConnection) GrantPrivilegesExists(ctx context.Context, user, dbName string) (bool, error) {
|
func (c *MySQLConnection) GrantPrivilegesExists(_ context.Context, user, dbName string) (bool, error) {
|
||||||
statementShowGrantsStatement := fmt.Sprintf(mysqlShowGrantsStatement, user)
|
statementShowGrantsStatement := fmt.Sprintf(mysqlShowGrantsStatement, user)
|
||||||
rows, err := c.db.Query(statementShowGrantsStatement)
|
rows, err := c.db.Query(statementShowGrantsStatement) //nolint:sqlclosecheck
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.NewGrantPrivilegesError(err)
|
return false, errors.NewGrantPrivilegesError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err = rows.Err(); err != nil {
|
||||||
|
return false, errors.NewGrantPrivilegesError(err)
|
||||||
|
}
|
||||||
|
|
||||||
expected := fmt.Sprintf(mysqlGrantPrivilegesStatement, user, dbName)
|
expected := fmt.Sprintf(mysqlGrantPrivilegesStatement, user, dbName)
|
||||||
var grant string
|
var grant string
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func (r *PostgreSQLConnection) Migrate(ctx context.Context, tcp kamajiv1alpha1.T
|
|||||||
// Dumping the old datastore in a local buffer
|
// Dumping the old datastore in a local buffer
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
if _, err := r.switchDatabaseFn(tcp.Status.Storage.Setup.Schema).WithContext(ctx).CopyTo(&buf, "COPY kine TO STDOUT"); err != nil { //nolint:contextcheck
|
if _, err := r.switchDatabaseFn(tcp.Status.Storage.Setup.Schema).WithContext(ctx).CopyTo(&buf, "COPY kine TO STDOUT"); err != nil {
|
||||||
return fmt.Errorf("unable to copy from the origin datastore: %w", err)
|
return fmt.Errorf("unable to copy from the origin datastore: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,11 +26,8 @@ func buildCertificateDirectoryWithCA(ca CertificatePrivateKeyPair, directory str
|
|||||||
}
|
}
|
||||||
|
|
||||||
keyPath := path.Join(directory, kubeadmconstants.CAKeyName)
|
keyPath := path.Join(directory, kubeadmconstants.CAKeyName)
|
||||||
if err := os.WriteFile(keyPath, ca.PrivateKey, os.FileMode(0o600)); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return os.WriteFile(keyPath, ca.PrivateKey, os.FileMode(0o600))
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateKubeconfig(kubeconfigName string, ca CertificatePrivateKeyPair, config *Configuration) ([]byte, error) {
|
func CreateKubeconfig(kubeconfigName string, ca CertificatePrivateKeyPair, config *Configuration) ([]byte, error) {
|
||||||
|
|||||||
@@ -11,28 +11,28 @@ import (
|
|||||||
|
|
||||||
type Discard struct{}
|
type Discard struct{}
|
||||||
|
|
||||||
func (d Discard) PrintObj(obj runtime.Object, writer io.Writer) error {
|
func (d Discard) PrintObj(runtime.Object, io.Writer) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Discard) Fprintf(writer io.Writer, format string, args ...interface{}) (n int, err error) {
|
func (d Discard) Fprintf(io.Writer, string, ...interface{}) (n int, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Discard) Fprintln(writer io.Writer, args ...interface{}) (n int, err error) {
|
func (d Discard) Fprintln(io.Writer, ...interface{}) (n int, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Discard) Printf(format string, args ...interface{}) (n int, err error) {
|
func (d Discard) Printf(string, ...interface{}) (n int, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Discard) Println(args ...interface{}) (n int, err error) {
|
func (d Discard) Println(...interface{}) (n int, err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Discard) Flush(writer io.Writer, last bool) {
|
func (d Discard) Flush(io.Writer, bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d Discard) Close(writer io.Writer) {
|
func (d Discard) Close(io.Writer) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import (
|
|||||||
"k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig"
|
"k8s.io/kubernetes/cmd/kubeadm/app/phases/uploadconfig"
|
||||||
"k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
|
"k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
|
||||||
"k8s.io/kubernetes/pkg/apis/rbac"
|
"k8s.io/kubernetes/pkg/apis/rbac"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
|
|
||||||
"github.com/clastix/kamaji/internal/utilities"
|
"github.com/clastix/kamaji/internal/utilities"
|
||||||
)
|
)
|
||||||
@@ -81,10 +81,10 @@ func getKubeletConfigmapContent(kubeletConfiguration KubeletConfiguration) ([]by
|
|||||||
},
|
},
|
||||||
Authentication: kubelettypes.KubeletAuthentication{
|
Authentication: kubelettypes.KubeletAuthentication{
|
||||||
Anonymous: kubelettypes.KubeletAnonymousAuthentication{
|
Anonymous: kubelettypes.KubeletAnonymousAuthentication{
|
||||||
Enabled: pointer.Bool(false),
|
Enabled: pointer.To(false),
|
||||||
},
|
},
|
||||||
Webhook: kubelettypes.KubeletWebhookAuthentication{
|
Webhook: kubelettypes.KubeletWebhookAuthentication{
|
||||||
Enabled: pointer.Bool(true),
|
Enabled: pointer.To(true),
|
||||||
CacheTTL: zeroDuration,
|
CacheTTL: zeroDuration,
|
||||||
},
|
},
|
||||||
X509: kubelettypes.KubeletX509Authentication{
|
X509: kubelettypes.KubeletX509Authentication{
|
||||||
@@ -110,9 +110,9 @@ func getKubeletConfigmapContent(kubeletConfiguration KubeletConfiguration) ([]by
|
|||||||
EvictionPressureTransitionPeriod: zeroDuration,
|
EvictionPressureTransitionPeriod: zeroDuration,
|
||||||
FileCheckFrequency: zeroDuration,
|
FileCheckFrequency: zeroDuration,
|
||||||
HealthzBindAddress: "127.0.0.1",
|
HealthzBindAddress: "127.0.0.1",
|
||||||
HealthzPort: pointer.Int32(10248),
|
HealthzPort: pointer.To(int32(10248)),
|
||||||
HTTPCheckFrequency: zeroDuration,
|
HTTPCheckFrequency: zeroDuration,
|
||||||
ImageGCHighThresholdPercent: pointer.Int32(100),
|
ImageGCHighThresholdPercent: pointer.To(int32(100)),
|
||||||
NodeStatusUpdateFrequency: zeroDuration,
|
NodeStatusUpdateFrequency: zeroDuration,
|
||||||
NodeStatusReportFrequency: zeroDuration,
|
NodeStatusReportFrequency: zeroDuration,
|
||||||
RotateCertificates: true,
|
RotateCertificates: true,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
rbacv1 "k8s.io/api/rbac/v1"
|
rbacv1 "k8s.io/api/rbac/v1"
|
||||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
@@ -287,7 +287,7 @@ func (k *KubeProxy) mutateDaemonSet(ctx context.Context, tenantClient client.Cli
|
|||||||
ds.Spec.Template.Spec.Volumes[0].Name = k.daemonSet.Spec.Template.Spec.Volumes[0].Name
|
ds.Spec.Template.Spec.Volumes[0].Name = k.daemonSet.Spec.Template.Spec.Volumes[0].Name
|
||||||
ds.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap = &corev1.ConfigMapVolumeSource{
|
ds.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap = &corev1.ConfigMapVolumeSource{
|
||||||
LocalObjectReference: corev1.LocalObjectReference{Name: k.daemonSet.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap.Name},
|
LocalObjectReference: corev1.LocalObjectReference{Name: k.daemonSet.Spec.Template.Spec.Volumes[0].VolumeSource.ConfigMap.Name},
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
}
|
}
|
||||||
|
|
||||||
ds.Spec.Template.Spec.Volumes[1].Name = k.daemonSet.Spec.Template.Spec.Volumes[1].Name
|
ds.Spec.Template.Spec.Volumes[1].Name = k.daemonSet.Spec.Template.Spec.Volumes[1].Name
|
||||||
|
|||||||
@@ -64,11 +64,8 @@ func (d *Migrate) Define(ctx context.Context, tenantControlPlane *kamajiv1alpha1
|
|||||||
}
|
}
|
||||||
|
|
||||||
d.desiredDatastore = &kamajiv1alpha1.DataStore{}
|
d.desiredDatastore = &kamajiv1alpha1.DataStore{}
|
||||||
if err := d.Client.Get(ctx, types.NamespacedName{Name: tenantControlPlane.Spec.DataStore}, d.desiredDatastore); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return d.Client.Get(ctx, types.NamespacedName{Name: tenantControlPlane.Spec.DataStore}, d.desiredDatastore)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Migrate) ShouldCleanup(tcp *kamajiv1alpha1.TenantControlPlane) bool {
|
func (d *Migrate) ShouldCleanup(tcp *kamajiv1alpha1.TenantControlPlane) bool {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ func (r *Config) CreateOrUpdate(ctx context.Context, tenantControlPlane *kamajiv
|
|||||||
return utilities.CreateOrUpdateWithConflict(ctx, r.Client, r.resource, r.mutate(ctx, tenantControlPlane))
|
return utilities.CreateOrUpdateWithConflict(ctx, r.Client, r.resource, r.mutate(ctx, tenantControlPlane))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Config) Delete(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
func (r *Config) Delete(ctx context.Context, _ *kamajiv1alpha1.TenantControlPlane) error {
|
||||||
secret := r.resource.DeepCopy()
|
secret := r.resource.DeepCopy()
|
||||||
|
|
||||||
if err := r.Client.Get(ctx, types.NamespacedName{Name: r.resource.Name, Namespace: r.resource.Namespace}, secret); err != nil {
|
if err := r.Client.Get(ctx, types.NamespacedName{Name: r.resource.Name, Namespace: r.resource.Namespace}, secret); err != nil {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
networkingv1 "k8s.io/api/networking/v1"
|
networkingv1 "k8s.io/api/networking/v1"
|
||||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
@@ -119,7 +119,7 @@ func (r *KubernetesIngressResource) mutate(tenantControlPlane *kamajiv1alpha1.Te
|
|||||||
}
|
}
|
||||||
|
|
||||||
path.Path = "/"
|
path.Path = "/"
|
||||||
path.PathType = (*networkingv1.PathType)(pointer.String(string(networkingv1.PathTypePrefix)))
|
path.PathType = (*networkingv1.PathType)(pointer.To(string(networkingv1.PathTypePrefix)))
|
||||||
|
|
||||||
if path.Backend.Service == nil {
|
if path.Backend.Service == nil {
|
||||||
path.Backend.Service = &networkingv1.IngressServiceBackend{}
|
path.Backend.Service = &networkingv1.IngressServiceBackend{}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/log"
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
||||||
@@ -146,11 +146,11 @@ func (r *Agent) mutate(ctx context.Context, tenantControlPlane *kamajiv1alpha1.T
|
|||||||
ServiceAccountToken: &corev1.ServiceAccountTokenProjection{
|
ServiceAccountToken: &corev1.ServiceAccountTokenProjection{
|
||||||
Path: agentTokenName,
|
Path: agentTokenName,
|
||||||
Audience: tenantControlPlane.Status.Addons.Konnectivity.ClusterRoleBinding.Name,
|
Audience: tenantControlPlane.Status.Addons.Konnectivity.ClusterRoleBinding.Name,
|
||||||
ExpirationSeconds: pointer.Int64(3600),
|
ExpirationSeconds: pointer.To(int64(3600)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
DefaultMode: pointer.Int32(420),
|
DefaultMode: pointer.To(int32(420)),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type CertificateResource struct {
|
|||||||
Client client.Client
|
Client client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CertificateResource) ShouldStatusBeUpdated(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) bool {
|
func (r *CertificateResource) ShouldStatusBeUpdated(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) bool {
|
||||||
return tenantControlPlane.Status.Addons.Konnectivity.Certificate.Checksum != utilities.GetObjectChecksum(r.resource)
|
return tenantControlPlane.Status.Addons.Konnectivity.Certificate.Checksum != utilities.GetObjectChecksum(r.resource)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ func (r *CertificateResource) GetName() string {
|
|||||||
return "konnectivity-certificate"
|
return "konnectivity-certificate"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CertificateResource) UpdateTenantControlPlaneStatus(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
func (r *CertificateResource) UpdateTenantControlPlaneStatus(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
||||||
if tenantControlPlane.Spec.Addons.Konnectivity != nil {
|
if tenantControlPlane.Spec.Addons.Konnectivity != nil {
|
||||||
tenantControlPlane.Status.Addons.Konnectivity.Certificate.LastUpdate = metav1.Now()
|
tenantControlPlane.Status.Addons.Konnectivity.Certificate.LastUpdate = metav1.Now()
|
||||||
tenantControlPlane.Status.Addons.Konnectivity.Certificate.SecretName = r.resource.GetName()
|
tenantControlPlane.Status.Addons.Konnectivity.Certificate.SecretName = r.resource.GetName()
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type EgressSelectorConfigurationResource struct {
|
|||||||
Client client.Client
|
Client client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *EgressSelectorConfigurationResource) Define(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
func (r *EgressSelectorConfigurationResource) Define(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
||||||
r.resource = &corev1.ConfigMap{
|
r.resource = &corev1.ConfigMap{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: utilities.AddTenantPrefix(r.GetName(), tenantControlPlane),
|
Name: utilities.AddTenantPrefix(r.GetName(), tenantControlPlane),
|
||||||
@@ -39,7 +39,7 @@ func (r *EgressSelectorConfigurationResource) ShouldCleanup(tenantControlPlane *
|
|||||||
return tenantControlPlane.Spec.Addons.Konnectivity == nil
|
return tenantControlPlane.Spec.Addons.Konnectivity == nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *EgressSelectorConfigurationResource) CleanUp(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) (bool, error) {
|
func (r *EgressSelectorConfigurationResource) CleanUp(ctx context.Context, _ *kamajiv1alpha1.TenantControlPlane) (bool, error) {
|
||||||
logger := log.FromContext(ctx, "resource", r.GetName())
|
logger := log.FromContext(ctx, "resource", r.GetName())
|
||||||
|
|
||||||
if err := r.Client.Delete(ctx, r.resource); err != nil {
|
if err := r.Client.Delete(ctx, r.resource); err != nil {
|
||||||
@@ -63,11 +63,11 @@ func (r *EgressSelectorConfigurationResource) GetName() string {
|
|||||||
return "konnectivity-egress-selector-configuration"
|
return "konnectivity-egress-selector-configuration"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *EgressSelectorConfigurationResource) ShouldStatusBeUpdated(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) bool {
|
func (r *EgressSelectorConfigurationResource) ShouldStatusBeUpdated(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) bool {
|
||||||
return tenantControlPlane.Status.Addons.Konnectivity.ConfigMap.Checksum != utilities.GetObjectChecksum(r.resource)
|
return tenantControlPlane.Status.Addons.Konnectivity.ConfigMap.Checksum != utilities.GetObjectChecksum(r.resource)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *EgressSelectorConfigurationResource) UpdateTenantControlPlaneStatus(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
func (r *EgressSelectorConfigurationResource) UpdateTenantControlPlaneStatus(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
||||||
if tenantControlPlane.Spec.Addons.Konnectivity != nil {
|
if tenantControlPlane.Spec.Addons.Konnectivity != nil {
|
||||||
tenantControlPlane.Status.Addons.Konnectivity.ConfigMap.Name = r.resource.GetName()
|
tenantControlPlane.Status.Addons.Konnectivity.ConfigMap.Name = r.resource.GetName()
|
||||||
tenantControlPlane.Status.Addons.Konnectivity.ConfigMap.Checksum = utilities.GetObjectChecksum(r.resource)
|
tenantControlPlane.Status.Addons.Konnectivity.ConfigMap.Checksum = utilities.GetObjectChecksum(r.resource)
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ func (r *KubeadmConfigResource) GetName() string {
|
|||||||
return "kubeadmconfig"
|
return "kubeadmconfig"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *KubeadmConfigResource) UpdateTenantControlPlaneStatus(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
func (r *KubeadmConfigResource) UpdateTenantControlPlaneStatus(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
||||||
tenantControlPlane.Status.KubeadmConfig.LastUpdate = metav1.Now()
|
tenantControlPlane.Status.KubeadmConfig.LastUpdate = metav1.Now()
|
||||||
tenantControlPlane.Status.KubeadmConfig.Checksum = utilities.GetObjectChecksum(r.resource)
|
tenantControlPlane.Status.KubeadmConfig.Checksum = utilities.GetObjectChecksum(r.resource)
|
||||||
tenantControlPlane.Status.KubeadmConfig.ConfigmapName = r.resource.GetName()
|
tenantControlPlane.Status.KubeadmConfig.ConfigmapName = r.resource.GetName()
|
||||||
@@ -116,10 +116,6 @@ func (r *KubeadmConfigResource) mutate(ctx context.Context, tenantControlPlane *
|
|||||||
|
|
||||||
utilities.SetObjectChecksum(r.resource, r.resource.Data)
|
utilities.SetObjectChecksum(r.resource, r.resource.Data)
|
||||||
|
|
||||||
if err := ctrl.SetControllerReference(tenantControlPlane, r.resource, r.Client.Scheme()); err != nil {
|
return ctrl.SetControllerReference(tenantControlPlane, r.resource, r.Client.Scheme())
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (r *KubeconfigResource) CleanUp(context.Context, *kamajiv1alpha1.TenantCont
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *KubeconfigResource) Define(ctx context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
func (r *KubeconfigResource) Define(_ context.Context, tenantControlPlane *kamajiv1alpha1.TenantControlPlane) error {
|
||||||
r.resource = &corev1.Secret{
|
r.resource = &corev1.Secret{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: r.getPrefixedName(tenantControlPlane),
|
Name: r.getPrefixedName(tenantControlPlane),
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"time"
|
|
||||||
|
|
||||||
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
|
||||||
)
|
)
|
||||||
@@ -33,7 +32,6 @@ func UpdateOperationResult(current controllerutil.OperationResult, op controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
func RandomString(n int) string {
|
func RandomString(n int) string {
|
||||||
rand.Seed(time.Now().UnixNano())
|
|
||||||
b := make([]byte, n)
|
b := make([]byte, n)
|
||||||
for i := range b {
|
for i := range b {
|
||||||
b[i] = letters[rand.Intn(len(letters))]
|
b[i] = letters[rand.Intn(len(letters))]
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ func DecodeFromYAML(o string, to runtime.Object) (err error) {
|
|||||||
Strict: false,
|
Strict: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
if to, _, err = encoder.Decode([]byte(o), nil, to); err != nil { //nolint:ineffassign,staticcheck
|
if to, _, err = encoder.Decode([]byte(o), nil, to); err != nil { //nolint:ineffassign,staticcheck,wastedassign
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +86,7 @@ func DecodeFromJSON(o string, to runtime.Object) (err error) {
|
|||||||
Strict: false,
|
Strict: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
if to, _, err = encoder.Decode([]byte(o), nil, to); err != nil { //nolint:ineffassign,staticcheck
|
if to, _, err = encoder.Decode([]byte(o), nil, to); err != nil { //nolint:ineffassign,staticcheck,wastedassign
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -68,11 +68,7 @@ func (d DataStoreValidation) validate(ctx context.Context, ds kamajiv1alpha1.Dat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := d.validateTLSConfig(ctx, ds); err != nil {
|
return d.validateTLSConfig(ctx, ds)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d DataStoreValidation) validateBasicAuth(ctx context.Context, ds kamajiv1alpha1.DataStore) error {
|
func (d DataStoreValidation) validateBasicAuth(ctx context.Context, ds kamajiv1alpha1.DataStore) error {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gomodules.xyz/jsonpatch/v2"
|
"gomodules.xyz/jsonpatch/v2"
|
||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/utils/pointer"
|
pointer "k8s.io/utils/ptr"
|
||||||
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
|
||||||
|
|
||||||
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
kamajiv1alpha1 "github.com/clastix/kamaji/api/v1alpha1"
|
||||||
@@ -37,7 +37,7 @@ func (t TenantControlPlaneDefaults) OnCreate(object runtime.Object) AdmissionRes
|
|||||||
}
|
}
|
||||||
|
|
||||||
if tcp.Spec.ControlPlane.Deployment.Replicas == nil {
|
if tcp.Spec.ControlPlane.Deployment.Replicas == nil {
|
||||||
tcp.Spec.ControlPlane.Deployment.Replicas = pointer.Int32(2)
|
tcp.Spec.ControlPlane.Deployment.Replicas = pointer.To(int32(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@@ -61,7 +61,7 @@ func (t TenantControlPlaneDefaults) OnUpdate(object runtime.Object, oldObject ru
|
|||||||
}
|
}
|
||||||
|
|
||||||
if newTCP.Spec.ControlPlane.Deployment.Replicas == nil {
|
if newTCP.Spec.ControlPlane.Deployment.Replicas == nil {
|
||||||
newTCP.Spec.ControlPlane.Deployment.Replicas = pointer.Int32(2)
|
newTCP.Spec.ControlPlane.Deployment.Replicas = pointer.To(int32(2))
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
Reference in New Issue
Block a user