This is an automated email from the ASF dual-hosted git repository.
sunnianjun pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/shardingsphere-on-cloud.git
The following commit(s) were added to refs/heads/main by this push:
new 2903f76 chore: remove comments and update ci (#338)
2903f76 is described below
commit 2903f76ce306676d9067405206fab553ac6552c1
Author: liyao <[email protected]>
AuthorDate: Fri May 5 17:56:17 2023 +0800
chore: remove comments and update ci (#338)
* chore: remove comments
Signed-off-by: mlycore <[email protected]>
* test: fix commit message lint
Signed-off-by: mlycore <[email protected]>
---------
Signed-off-by: mlycore <[email protected]>
---
.github/workflows/commit-msg.yml | 6 +-
.../controllers/shardingsphere_chaos_controller.go | 12 ---
.../pkg/kubernetes/chaosmesh/chaosmesh.go | 1 +
.../pkg/kubernetes/configmap/factory.go | 6 +-
.../pkg/reconcile/common/configmap.go | 101 ---------------------
.../pkg/reconcile/shardingspherechaos/configmap.go | 78 ----------------
.../shardingsphere_chaos_suite_test.go | 10 +-
7 files changed, 11 insertions(+), 203 deletions(-)
diff --git a/.github/workflows/commit-msg.yml b/.github/workflows/commit-msg.yml
index f9fae1c..c2c10b4 100644
--- a/.github/workflows/commit-msg.yml
+++ b/.github/workflows/commit-msg.yml
@@ -36,6 +36,6 @@ jobs:
key: ${{ runner.os }}-lint-commit-message
- name: Lint commit message
run: |
- git log --oneline ${{ github.event.pull_request.base.sha }}... \
- | grep -vP '^\w{8} Merge ' \
- | grep -vP '^\w{8}
(feat|fix|build|chore|docs|style|refactor|perf|test|ci)(\(\w+(-\w+)?\))?:(\s*).*'
+ ! git log --oneline ${{ github.event.pull_request.base.sha }}... \
+ | grep -vP '^\w{7} Merge ' \
+ | grep -vP '^\w{7}
(feat|fix|docs|style|refactor|perf|revert|test|chore)(\(.+\))?:.{1,68}$'
diff --git
a/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
b/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
index afe274f..77474c5 100644
--- a/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
+++ b/shardingsphere-operator/pkg/controllers/shardingsphere_chaos_controller.go
@@ -295,7 +295,6 @@ func (r *ShardingSphereChaosReconciler)
reconcileConfigMap(ctx context.Context,
fmt.Printf("update configmap error: %s\n", err)
return err
}
- // return r.updateConfigMap(ctx, chaos, cm)
}
if err = r.createConfigMap(ctx, chaos); err != nil {
@@ -377,7 +376,6 @@ func (r *ShardingSphereChaosReconciler) reconcileStatus(ctx
context.Context, cha
return err
}
- // sts := setRtStatus(chaos)
rt, err := r.getRuntimeChaos(ctx, namespacedName)
if err != nil {
return err
@@ -401,7 +399,6 @@ func (r *ShardingSphereChaosReconciler)
setDefaultStatus(chaos *v1alpha1.Shardin
// * AfterExperiment: it has been finished, could start a new experiment
// * InjectChaos: it has been started, could start some pressure
// * recoveredChaos: it has been recovered, could start to verify
-
func getInjectRequirement(ssChaos *v1alpha1.ShardingSphereChaos)
reconcile.InjectRequirement {
var jobName reconcile.InjectRequirement
@@ -631,18 +628,9 @@ func (r *ShardingSphereChaosReconciler)
updateConfigMap(ctx context.Context, cha
exp.Labels = cur.Labels
exp.Annotations = cur.Annotations
return r.ConfigMap.Update(ctx, exp)
-
- // return r.Update(ctx, exp)
}
func (r *ShardingSphereChaosReconciler) createConfigMap(ctx context.Context,
chaos *v1alpha1.ShardingSphereChaos) error {
- /*
- cm := reconcile.NewSSConfigMap(chaos)
- if err := ctrl.SetControllerReference(chaos, cm, r.Scheme); err
!= nil {
- return err
- }
- */
-
cm := r.ConfigMap.Build(ctx, chaos)
err := r.Create(ctx, cm)
diff --git a/shardingsphere-operator/pkg/kubernetes/chaosmesh/chaosmesh.go
b/shardingsphere-operator/pkg/kubernetes/chaosmesh/chaosmesh.go
index 8aebab7..e54cb52 100644
--- a/shardingsphere-operator/pkg/kubernetes/chaosmesh/chaosmesh.go
+++ b/shardingsphere-operator/pkg/kubernetes/chaosmesh/chaosmesh.go
@@ -22,6 +22,7 @@ import (
"reflect"
"github.com/apache/shardingsphere-on-cloud/shardingsphere-operator/api/v1alpha1"
+
chaosmeshapi "github.com/chaos-mesh/chaos-mesh/api/v1alpha1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/types"
diff --git a/shardingsphere-operator/pkg/kubernetes/configmap/factory.go
b/shardingsphere-operator/pkg/kubernetes/configmap/factory.go
index 8c9008d..b9056b6 100644
--- a/shardingsphere-operator/pkg/kubernetes/configmap/factory.go
+++ b/shardingsphere-operator/pkg/kubernetes/configmap/factory.go
@@ -22,10 +22,12 @@ import (
"k8s.io/apimachinery/pkg/runtime"
)
+// ConfigMapFactory generic configmap factory interface
type ConfigMapFactory interface {
NewConfigMapBuilder() ConfigMapBuilder
}
+// NewConfigMapFactory Create a new common configmap factory
func NewConfigMapFactory(obj runtime.Object) ConfigMapFactory {
return &configmapFactory{
obj: obj,
@@ -36,6 +38,7 @@ type configmapFactory struct {
obj runtime.Object
}
+// NewConfigMapBuilder Create a new common configmap builder
func (c *configmapFactory) NewConfigMapBuilder() ConfigMapBuilder {
gvk := c.obj.GetObjectKind().GroupVersionKind()
@@ -75,7 +78,6 @@ type ConfigMapBuilder interface {
Build() *v1.ConfigMap
}
-// configMapBuilder common configmap implementation
type configMapBuilder struct {
configmap *v1.ConfigMap
}
@@ -109,6 +111,7 @@ func (c *configMapBuilder) SetAnnotations(annos
map[string]string) ConfigMapBuil
return c
}
+// SetData set the ConfigMap data
func (c *configMapBuilder) SetData(data map[string]string) ConfigMapBuilder {
if c.configmap.Data == nil {
c.configmap.Data = map[string]string{}
@@ -117,6 +120,7 @@ func (c *configMapBuilder) SetData(data map[string]string)
ConfigMapBuilder {
return c
}
+// SetBinaryData set the ConfigMap binary data
func (c *configMapBuilder) SetBinaryData(binary map[string][]byte)
ConfigMapBuilder {
if c.configmap.BinaryData == nil {
c.configmap.BinaryData = map[string][]byte{}
diff --git a/shardingsphere-operator/pkg/reconcile/common/configmap.go
b/shardingsphere-operator/pkg/reconcile/common/configmap.go
deleted file mode 100644
index 59eacd5..0000000
--- a/shardingsphere-operator/pkg/reconcile/common/configmap.go
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package common
-
-/*
-
-import (
- v1 "k8s.io/api/core/v1"
- "k8s.io/apimachinery/pkg/runtime/schema"
-)
-
-type ConfigMapFactory interface {
- NewConfigMapBuilderFromGVK(gvk schema.GroupVersionKind) ConfigMapBuilder
-}
-
-type configmapFactory struct{}
-
-func (c configmapFactory) NewConfigMapBuilderFromGVK(gvk
schema.GroupVersionKind) ConfigMapBuilder {
- if gvk.Group == "shardingsphere.apache.org" {
- if gvk.Kind == "ComputeNode" && gvk.Version == "v1alpha1" {
- return &commonConfigMapBuilder{}
- }
- }
-
- // if gvk.Group == "shardingsphere.apache.org" && gvk.Kind ==
"ShardingSphereChaos" && gvk.Version == "v1alpha1" {
- // return shardingsphereChaosConfigMapBuilder{}
- // }
-
- return nil
-}
-
-// type computeNodeConfigMapBuilder struct{}
-
-// func (c computeNodeConfigMapFactory) NewConfigMapBuilderFromGVK()
-
-// type shardingsphereChaosConfigMapFactory struct{}
-
-// ConfigMapBuilder generic configmap interface
-type ConfigMapBuilder interface {
- SetName(name string) ConfigMapBuilder
- SetNamespace(namespace string) ConfigMapBuilder
- SetLabels(labels map[string]string) ConfigMapBuilder
- SetAnnotations(annos map[string]string) ConfigMapBuilder
- Build() *v1.ConfigMap
-}
-
-// commonConfigMapBuilder common configmap implementation
-type commonConfigMapBuilder struct {
- configmap *v1.ConfigMap
-}
-
-// NewCommonConfigMapBuilder Create a new common configmap builder
-func NewCommonConfigMapBuilder(configmap *v1.ConfigMap) ConfigMapBuilder {
- return &commonConfigMapBuilder{configmap}
-}
-
-// SetName set the ConfigMap name
-func (c *commonConfigMapBuilder) SetName(name string) ConfigMapBuilder {
- c.configmap.Name = name
- return c
-}
-
-// SetNamespace set the ConfigMap namespace
-func (c *commonConfigMapBuilder) SetNamespace(namespace string)
ConfigMapBuilder {
- c.configmap.Namespace = namespace
- return c
-}
-
-// SetLabels set the ConfigMap labels
-func (c *commonConfigMapBuilder) SetLabels(labels map[string]string)
ConfigMapBuilder {
- c.configmap.Labels = labels
- return c
-}
-
-// SetAnnotations set the ConfigMap annotations
-func (c *commonConfigMapBuilder) SetAnnotations(annos map[string]string)
ConfigMapBuilder {
- c.configmap.Annotations = annos
- return c
-}
-
-// Build returns a ConfigMap
-func (c *commonConfigMapBuilder) Build() *v1.ConfigMap {
- return c.configmap
-}
-
-*/
diff --git
a/shardingsphere-operator/pkg/reconcile/shardingspherechaos/configmap.go
b/shardingsphere-operator/pkg/reconcile/shardingspherechaos/configmap.go
index 78b383b..28973c0 100644
--- a/shardingsphere-operator/pkg/reconcile/shardingspherechaos/configmap.go
+++ b/shardingsphere-operator/pkg/reconcile/shardingspherechaos/configmap.go
@@ -21,84 +21,6 @@ const (
configExperimental = "experimental.sh"
configPressure = "pressure.sh"
configVerify = "verify.sh"
-)
-const (
DefaultConfigMapName = "ssChaos-configmap"
)
-
-/*
-// NewSSConfigMap returns a new ConfigMap
-func NewSSConfigMap(chaos *v1alpha1.ShardingSphereChaos) *corev1.ConfigMap {
- cmb := NewSSConfigMapBuilder()
-
cmb.SetName(chaos.Name).SetNamespace(chaos.Namespace).SetLabels(chaos.Labels)
-
cmb.SetExperimental(chaos.Spec.InjectJob.Experimental).SetPressure(chaos.Spec.InjectJob.Pressure).SetVerify(chaos.Spec.InjectJob.Verify)
-
- return cmb.Build()
-}
-
-// SSConfigMapBuilder is a builder for ConfigMap by ComputeNode
-type SSConfigMapBuilder interface {
- common.ConfigMapBuilder
-
- SetExperimental(v1alpha1.Script) SSConfigMapBuilder
- SetPressure(v1alpha1.Script) SSConfigMapBuilder
- SetVerify(v1alpha1.Script) SSConfigMapBuilder
-}
-
-type configmapBuilder struct {
- common.ConfigMapBuilder
- configmap *corev1.ConfigMap
-}
-
-// NewSSConfigMapBuilder returns a new SSConfigMapBuilder
-func NewSSConfigMapBuilder() SSConfigMapBuilder {
- configMap := defaultConfigMap()
-
- return &configmapBuilder{
- common.NewCommonConfigMapBuilder(configMap),
- configMap,
- }
-}
-
-// SetExperimental sets the experimental command
-func (c *configmapBuilder) SetExperimental(s v1alpha1.Script)
SSConfigMapBuilder {
- c.configmap.Data[configExperimental] = string(s)
- return c
-}
-
-// SetPressure sets the pressure command
-func (c *configmapBuilder) SetPressure(s v1alpha1.Script) SSConfigMapBuilder {
- c.configmap.Data[configPressure] = string(s)
- return c
-}
-
-// SetVerify sets the verify scripts
-func (c *configmapBuilder) SetVerify(s v1alpha1.Script) SSConfigMapBuilder {
- c.configmap.Data[configVerify] = string(s)
- return c
-}
-
-// defaultConfigMap returns a ConfigMap filling with default expected values
-func defaultConfigMap() *corev1.ConfigMap {
- return &corev1.ConfigMap{
- ObjectMeta: metav1.ObjectMeta{
- Name: DefaultConfigMapName,
- Namespace: "default",
- Labels: map[string]string{},
- },
- Data: map[string]string{},
- }
-}
-
-// UpdateConfigMap returns a new ConfigMap
-func UpdateConfigMap(ssChaos *v1alpha1.ShardingSphereChaos, cur
*corev1.ConfigMap) *corev1.ConfigMap {
- exp := &corev1.ConfigMap{}
- exp.ObjectMeta = cur.ObjectMeta
- exp.Labels = cur.Labels
- exp.Annotations = cur.Annotations
- now := NewSSConfigMap(ssChaos)
- exp.Data = now.Data
- return exp
-}
-*/
diff --git
a/shardingsphere-operator/pkg/reconcile/shardingspherechaos/shardingsphere_chaos_suite_test.go
b/shardingsphere-operator/pkg/reconcile/shardingspherechaos/shardingsphere_chaos_suite_test.go
index cd10e4f..493a0f7 100644
---
a/shardingsphere-operator/pkg/reconcile/shardingspherechaos/shardingsphere_chaos_suite_test.go
+++
b/shardingsphere-operator/pkg/reconcile/shardingspherechaos/shardingsphere_chaos_suite_test.go
@@ -17,19 +17,13 @@
package shardingspherechaos_test
import (
+ "testing"
+
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
- "testing"
)
func TestShardingSphereChaos(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "ShardingSphereChaos Suite")
}
-
-//func installChaosMesh() {
-// var (
-// installCmd = "curl -sSL
https://mirrors.chaos-mesh.org/v2.5.1/install.sh | bash -s -- --docker-mirror"
-// )
-//
-//}