forked from erda-project/erda
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cluster addon reset to mse-addon if it has mse nacos (erda-proj…
…ect#6424) * fix: mse nacos bind registercenter * feat: config-center reset addon * fix: cluster addon interlink without nacos * polish: remove useless code * polish: remove useless code * feat: add new config-center version: 2.0.0 * polish: set plan as variable and remove useless service * feat: no need mse-nacos username and password * polish: specify column names * fix: pass test cover
- Loading branch information
Showing
15 changed files
with
260 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
INSERT INTO `tb_tmc` (`id`, `name`, `engine`, `service_type`, `deploy_mode`, `create_time`, `update_time`, `is_deleted`) VALUES (23,'MSE-Nacos','mse-nacos','ADDON','SAAS','2024-07-09 17:00:00','2024-07-09 17:00:00','N'); | ||
|
||
INSERT INTO `tb_tmc_version` (`id`, `engine`, `version`, `release_id`, `create_time`, `update_time`, `is_deleted`) VALUES (31,'mse-nacos','1.0.0',NULL,'2024-07-09 17:00:00','2024-07-09 17:00:00','N'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
INSERT INTO `tb_tmc_version` (`id`, `engine`, `version`, `release_id`, `create_time`, `update_time`, `is_deleted`) VALUES(32,'config-center','2.0.0',NULL,'2024-08-12 14:30:00','2024-08-12 14:30:00','N') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
internal/apps/msp/resource/deploy/handlers/externalprovider/externalprovider.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) 2021 Terminus, Inc. | ||
// | ||
// Licensed 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 externalprovider | ||
|
||
import ( | ||
"github.com/erda-project/erda/internal/apps/msp/instance/db" | ||
"github.com/erda-project/erda/internal/apps/msp/resource/deploy/handlers" | ||
) | ||
|
||
const ( | ||
MseNacosHost = "MS_NACOS_HOST" | ||
MseNacosPort = "MS_NACOS_PORT" | ||
) | ||
|
||
// TODO it will support like "TSE" "HSE" | ||
var matches = []string{handlers.ResourceMSENacos} | ||
|
||
func (p *provider) IsMatch(tmc *db.Tmc) bool { | ||
for _, res := range matches { | ||
if res == tmc.Engine { | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
|
||
func (p *provider) CheckIfHasCustomConfig(clusterConfig map[string]string) (map[string]string, bool) { | ||
nacosHost, ok := clusterConfig[MseNacosHost] | ||
if !ok { | ||
return nil, false | ||
} | ||
|
||
nacosPort, ok := clusterConfig[MseNacosPort] | ||
if !ok { | ||
return nil, false | ||
} | ||
|
||
return map[string]string{ | ||
"NACOS_HOST": nacosHost, | ||
"NACOS_PORT": nacosPort, | ||
"NACOS_ADDRESS": nacosHost + ":" + nacosPort, | ||
}, true | ||
} |
54 changes: 54 additions & 0 deletions
54
internal/apps/msp/resource/deploy/handlers/externalprovider/provider.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2021 Terminus, Inc. | ||
// | ||
// Licensed 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 externalprovider | ||
|
||
import ( | ||
"github.com/jinzhu/gorm" | ||
|
||
"github.com/erda-project/erda-infra/base/logs" | ||
"github.com/erda-project/erda-infra/base/servicehub" | ||
"github.com/erda-project/erda/internal/apps/msp/resource/deploy/handlers" | ||
) | ||
|
||
type config struct { | ||
} | ||
|
||
// +provider | ||
type provider struct { | ||
*handlers.DefaultDeployHandler | ||
Cfg *config | ||
Log logs.Logger | ||
DB *gorm.DB `autowired:"mysql-client"` | ||
} | ||
|
||
func (p *provider) Init(ctx servicehub.Context) error { | ||
p.DefaultDeployHandler = handlers.NewDefaultHandler(p.DB, p.Log) | ||
return nil | ||
} | ||
|
||
func init() { | ||
servicehub.Register("erda.msp.resource.deploy.handlers.externalprovider", &servicehub.Spec{ | ||
Services: []string{ | ||
"erda.msp.resource.deploy.handlers.externalprovider", | ||
}, | ||
Description: "erda.msp.resource.deploy.handlers.externalprovider", | ||
ConfigFunc: func() interface{} { | ||
return &config{} | ||
}, | ||
Creator: func() servicehub.Provider { | ||
return &provider{} | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.