mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-12-02 11:47:36 +08:00
Merge branch 'V5.2' of https://github.com/goodrain/rainbond into coding/2934
This commit is contained in:
commit
f7ec943f40
@ -310,6 +310,8 @@ func (p *PluginAction) buildPlugin(b *api_model.BuildPluginStruct, plugin *dbmod
|
||||
ImageInfo: b.Body.ImageInfo,
|
||||
Repo: b.Body.RepoURL,
|
||||
GitURL: plugin.GitURL,
|
||||
GitUsername: b.Body.Username,
|
||||
GitPassword: b.Body.Password,
|
||||
}
|
||||
taskType := "plugin_image_build"
|
||||
if plugin.BuildModel == "dockerfile" {
|
||||
|
@ -218,6 +218,14 @@ type BuildPluginStruct struct {
|
||||
// in: body
|
||||
// required: false
|
||||
RepoURL string `json:"repo_url" validate:"repo_url"`
|
||||
// git username
|
||||
// in: body
|
||||
// required: false
|
||||
Username string `json:"username"`
|
||||
// git password
|
||||
// in: body
|
||||
// required: false
|
||||
Password string `json:"password"`
|
||||
// 版本信息, 协助选择插件版本
|
||||
// in:body
|
||||
// required: true
|
||||
|
@ -90,7 +90,7 @@ func (e *exectorManager) runD(t *model.BuildPluginTaskBody, logger event.Logger)
|
||||
if err := util.CheckAndCreateDir(sourceDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := sources.GitClone(sources.CodeSourceInfo{RepositoryURL: t.GitURL, Branch: t.Repo}, sourceDir, logger, 4); err != nil {
|
||||
if _, err := sources.GitClone(sources.CodeSourceInfo{RepositoryURL: t.GitURL, Branch: t.Repo, User: t.GitUsername, Password: t.GitPassword}, sourceDir, logger, 4); err != nil {
|
||||
logger.Error("拉取代码失败", map[string]string{"step": "builder-exector", "status": "failure"})
|
||||
logrus.Errorf("[plugin]git clone code error %v", err)
|
||||
return err
|
||||
|
@ -26,6 +26,8 @@ type BuildPluginTaskBody struct {
|
||||
Operator string `json:"operator"`
|
||||
Repo string `json:"repo"`
|
||||
GitURL string `json:"git_url"`
|
||||
GitUsername string `json:"git_username"`
|
||||
GitPassword string `json:"git_password"`
|
||||
ImageURL string `json:"image_url"`
|
||||
EventID string `json:"event_id"`
|
||||
DeployVersion string `json:"deploy_version"`
|
||||
|
@ -19,7 +19,6 @@
|
||||
package option
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
@ -90,10 +89,10 @@ func (a *Worker) AddFlags(fs *pflag.FlagSet) {
|
||||
fs.StringVar(&a.HostIP, "host-ip", "", "the ip of this worker,it must be global connected ip")
|
||||
fs.IntVar(&a.ServerPort, "server-port", 6535, "the listen port that app runtime server")
|
||||
fs.StringVar(&a.NodeAPI, "node-api", "http://172.30.42.1:6100", "node discover api, node docker endpoints")
|
||||
flag.StringVar(&a.LeaderElectionNamespace, "leader-election-namespace", "rainbond", "Namespace where this attacher runs.")
|
||||
flag.StringVar(&a.LeaderElectionIdentity, "leader-election-identity", "", "Unique idenity of this attcher. Typically name of the pod where the attacher runs.")
|
||||
flag.StringVar(&a.RBDNamespace, "rbd-system-namespace", "rbd-system", "rbd components kubernetes namespace")
|
||||
flag.StringVar(&a.GrdataPVCName, "grdata-pvc-name", "rbd-cpt-grdata", "The name of grdata persistent volume claim")
|
||||
fs.StringVar(&a.LeaderElectionNamespace, "leader-election-namespace", "rainbond", "Namespace where this attacher runs.")
|
||||
fs.StringVar(&a.LeaderElectionIdentity, "leader-election-identity", "", "Unique idenity of this attcher. Typically name of the pod where the attacher runs.")
|
||||
fs.StringVar(&a.RBDNamespace, "rbd-system-namespace", "rbd-system", "rbd components kubernetes namespace")
|
||||
fs.StringVar(&a.GrdataPVCName, "grdata-pvc-name", "rbd-cpt-grdata", "The name of grdata persistent volume claim")
|
||||
}
|
||||
|
||||
//SetLog 设置log
|
||||
|
@ -298,8 +298,7 @@ func (a *AppService) SetServices(svcs []*corev1.Service) {
|
||||
//GetServices get services
|
||||
func (a *AppService) GetServices(canCopy bool) []*corev1.Service {
|
||||
if canCopy {
|
||||
cr := make([]*corev1.Service, len(a.services))
|
||||
copy(cr, a.services[0:])
|
||||
return append(a.services[:0:0], a.services...)
|
||||
}
|
||||
return a.services
|
||||
}
|
||||
@ -335,8 +334,7 @@ func (a *AppService) AddEndpoints(ep *corev1.Endpoints) {
|
||||
// GetEndpoints returns endpoints in AppService
|
||||
func (a *AppService) GetEndpoints(canCopy bool) []*corev1.Endpoints {
|
||||
if canCopy {
|
||||
cr := make([]*corev1.Endpoints, len(a.endpoints))
|
||||
copy(cr, a.endpoints[0:])
|
||||
return append(a.endpoints[:0:0], a.endpoints...)
|
||||
}
|
||||
return a.endpoints
|
||||
}
|
||||
@ -464,8 +462,7 @@ func (a *AppService) DeleteSecrets(d *corev1.Secret) {
|
||||
//GetSecrets get secrets
|
||||
func (a *AppService) GetSecrets(canCopy bool) []*corev1.Secret {
|
||||
if canCopy {
|
||||
cr := make([]*corev1.Secret, len(a.secrets))
|
||||
copy(cr, a.secrets[0:])
|
||||
return append(a.secrets[:0:0], a.secrets...)
|
||||
}
|
||||
return a.secrets
|
||||
}
|
||||
@ -501,8 +498,7 @@ func (a *AppService) DeletePods(d *corev1.Pod) {
|
||||
//GetPods get pods
|
||||
func (a *AppService) GetPods(canCopy bool) []*corev1.Pod {
|
||||
if canCopy {
|
||||
cr := make([]*corev1.Pod, len(a.pods))
|
||||
copy(cr, a.pods[0:])
|
||||
return append(a.pods[:0:0], a.pods...)
|
||||
}
|
||||
return a.pods
|
||||
}
|
||||
|
@ -508,10 +508,15 @@ func NewProvisionController(
|
||||
return
|
||||
}
|
||||
|
||||
path, err := getDataPath(pv.Spec.PersistentVolumeSource)
|
||||
if err != nil {
|
||||
logrus.Errorf("get data path: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
// rainbondsssc
|
||||
switch pv.Spec.StorageClassName {
|
||||
case "rainbondsssc":
|
||||
path := pv.Spec.PersistentVolumeSource.HostPath.Path
|
||||
if err := os.RemoveAll(path); err != nil {
|
||||
logrus.Errorf("path: %s; name: %s; remove pv hostpath: %v", path, pv.Name, err)
|
||||
}
|
||||
@ -532,8 +537,6 @@ func NewProvisionController(
|
||||
return
|
||||
}
|
||||
|
||||
path := pv.Spec.PersistentVolumeSource.HostPath.Path
|
||||
|
||||
if err := deletePath(nodeIP, path); err != nil {
|
||||
logrus.Errorf("delete path: %v", err)
|
||||
return
|
||||
@ -1328,3 +1331,19 @@ func deletePath(nodeIP, path string) error {
|
||||
|
||||
return fmt.Errorf("delete local path: %s; status code: %d; err: %v", path, statusCode, err)
|
||||
}
|
||||
|
||||
func getDataPath(source v1.PersistentVolumeSource) (string, error) {
|
||||
switch {
|
||||
case source.HostPath != nil:
|
||||
return source.HostPath.Path, nil
|
||||
case source.NFS != nil:
|
||||
return source.NFS.Path, nil
|
||||
case source.Glusterfs != nil:
|
||||
//glusterfs:
|
||||
// endpoints: glusterfs-cluster
|
||||
// path: myVol1
|
||||
return source.Glusterfs.Path, nil
|
||||
default:
|
||||
return "", fmt.Errorf("unsupported persistence volume source")
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user