Repository navigation
Enhance CHK reconciliation and normalization features #1885
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ package macro | |
| import ( | ||
| "strconv" | ||
|
|
||
| apiChk "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse-keeper.altinity.com/v1" | ||
| api "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse.altinity.com/v1" | ||
| "github.com/altinity/clickhouse-operator/pkg/apis/common/types" | ||
| "github.com/altinity/clickhouse-operator/pkg/interfaces" | ||
|
|
@@ -68,6 +69,8 @@ func (e *Engine) Replacer() *util.Replacer { | |
| return e.newReplacerCR(t) | ||
| case api.ICluster: | ||
| return e.newReplacerCluster(t) | ||
| case *apiChk.Cluster: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is ICluster interface that covers this functionality. No need to duplicate code. If there are doubts on applicability with CHK - ensure ICluster compatibility |
||
| return e.newReplacerCHKCluster(t) | ||
| case api.IShard: | ||
| return e.newReplacerShard(t) | ||
| case api.IReplica: | ||
|
|
@@ -105,6 +108,16 @@ func (e *Engine) newReplacerCluster(cluster api.ICluster) *util.Replacer { | |
| }) | ||
| } | ||
|
|
||
| // newReplacerCHKCluster | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code duplication? |
||
| func (e *Engine) newReplacerCHKCluster(cluster *apiChk.Cluster) *util.Replacer { | ||
| return util.NewReplacer(map[string]string{ | ||
| e.Get(MacrosNamespace): e.namer.Name(short.Namespace, cluster), | ||
| e.Get(MacrosCRName): e.namer.Name(short.CRName, cluster), | ||
| e.Get(MacrosClusterName): e.namer.Name(short.ClusterName, cluster), | ||
| e.Get(MacrosClusterIndex): strconv.Itoa(cluster.GetRuntime().GetAddress().GetClusterIndex()), | ||
| }) | ||
| } | ||
|
|
||
| // newReplacerShard | ||
| func (e *Engine) newReplacerShard(shard api.IShard) *util.Replacer { | ||
| return util.NewReplacer(map[string]string{ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ import ( | |
| "strconv" | ||
| "strings" | ||
|
|
||
| apiChk "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse-keeper.altinity.com/v1" | ||
| api "github.com/altinity/clickhouse-operator/pkg/apis/clickhouse.altinity.com/v1" | ||
| "github.com/altinity/clickhouse-operator/pkg/util" | ||
| ) | ||
|
|
@@ -132,6 +133,9 @@ func (n *Namer) getNamePartNamespace(obj interface{}) string { | |
| case api.ICluster: | ||
| cluster := obj.(api.ICluster) | ||
| return n.namePartCRName(cluster.GetRuntime().GetAddress().GetNamespace()) | ||
| case *apiChk.Cluster: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same - interface is for a reason |
||
| cluster := obj.(*apiChk.Cluster) | ||
| return n.namePartCRName(cluster.GetRuntime().GetAddress().GetNamespace()) | ||
| case api.IShard: | ||
| shard := obj.(api.IShard) | ||
| return n.namePartCRName(shard.GetRuntime().GetAddress().GetNamespace()) | ||
|
|
@@ -152,6 +156,9 @@ func (n *Namer) getNamePartCRName(obj interface{}) string { | |
| case api.ICluster: | ||
| cluster := obj.(api.ICluster) | ||
| return n.namePartCRName(cluster.GetRuntime().GetAddress().GetCRName()) | ||
| case *apiChk.Cluster: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same - interface use |
||
| cluster := obj.(*apiChk.Cluster) | ||
| return n.namePartCRName(cluster.GetRuntime().GetAddress().GetCRName()) | ||
| case api.IShard: | ||
| shard := obj.(api.IShard) | ||
| return n.namePartCRName(shard.GetRuntime().GetAddress().GetCRName()) | ||
|
|
@@ -169,6 +176,9 @@ func (n *Namer) getNamePartClusterName(obj interface{}) string { | |
| case api.ICluster: | ||
| cluster := obj.(api.ICluster) | ||
| return n.namePartClusterName(cluster.GetRuntime().GetAddress().GetClusterName()) | ||
| case *apiChk.Cluster: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same - interface |
||
| cluster := obj.(*apiChk.Cluster) | ||
| return n.namePartClusterName(cluster.GetRuntime().GetAddress().GetClusterName()) | ||
| case api.IShard: | ||
| shard := obj.(api.IShard) | ||
| return n.namePartClusterName(shard.GetRuntime().GetAddress().GetClusterName()) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check default deleter behavior