Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Rainbond
Commits
aa5a2c6a
Commit
aa5a2c6a
authored
3 years ago
by
barnettZQG
Browse files
Options
Download
Email Patches
Plain Diff
remove some unuseful code
parent
638c206a
master
No related merge requests found
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
api/db/db.go
+1
-3
api/db/db.go
api/handler/handler.go
+1
-2
api/handler/handler.go
api/handler/service.go
+6
-4
api/handler/service.go
api/handler/service_operation.go
+1
-1
api/handler/service_operation.go
api/metric/metric.go
+1
-1
api/metric/metric.go
builder/exector/exector_test.go
+0
-2
builder/exector/exector_test.go
builder/parser/discovery/discovery.go
+0
-54
builder/parser/discovery/discovery.go
builder/parser/discovery/etcd.go
+0
-103
builder/parser/discovery/etcd.go
builder/parser/discovery/etcd_test.go
+0
-19
builder/parser/discovery/etcd_test.go
builder/parser/parser.go
+0
-3
builder/parser/parser.go
builder/parser/third_party_service.go
+3
-37
builder/parser/third_party_service.go
with
13 additions
and
229 deletions
+13
-229
api/db/db.go
+
1
-
3
View file @
aa5a2c6a
...
...
@@ -31,7 +31,6 @@ import (
"github.com/goodrain/rainbond/event"
"github.com/goodrain/rainbond/mq/api/grpc/pb"
"github.com/goodrain/rainbond/mq/client"
etcdutil
"github.com/goodrain/rainbond/util/etcd"
"github.com/goodrain/rainbond/worker/discover/model"
"github.com/jinzhu/gorm"
"github.com/sirupsen/logrus"
...
...
@@ -86,8 +85,7 @@ func CreateEventManager(conf option.Config) error {
//MQManager mq manager
type
MQManager
struct
{
EtcdClientArgs
*
etcdutil
.
ClientArgs
DefaultServer
string
DefaultServer
string
}
//NewMQManager new mq manager
...
...
This diff is collapsed.
Click to expand it.
api/handler/handler.go
+
1
-
2
View file @
aa5a2c6a
...
...
@@ -44,8 +44,7 @@ func InitHandle(conf option.Config,
k8sClient
k8sclient
.
Client
,
)
error
{
mq
:=
api_db
.
MQManager
{
EtcdClientArgs
:
etcdClientArgs
,
DefaultServer
:
conf
.
MQAPI
,
DefaultServer
:
conf
.
MQAPI
,
}
mqClient
,
errMQ
:=
mq
.
NewMQManager
()
if
errMQ
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
api/handler/service.go
+
6
-
4
View file @
aa5a2c6a
...
...
@@ -2347,10 +2347,12 @@ func (s *ServiceAction) ListVersionInfo(serviceID string) (*api_model.BuildListR
for
idx
:=
range
bversions
{
bv
:=
bversions
[
idx
]
if
bv
.
Kind
==
"build_from_image"
||
bv
.
Kind
==
"build_from_market_image"
{
image
:=
parser
.
ParseImageName
(
bv
.
RepoURL
)
bv
.
ImageDomain
=
image
.
GetDomain
()
bv
.
ImageRepo
=
image
.
GetRepostory
()
bv
.
ImageTag
=
image
.
GetTag
()
if
bv
.
RepoURL
!=
""
{
image
:=
parser
.
ParseImageName
(
bv
.
RepoURL
)
bv
.
ImageDomain
=
image
.
GetDomain
()
bv
.
ImageRepo
=
image
.
GetRepostory
()
bv
.
ImageTag
=
image
.
GetTag
()
}
}
}
result
:=
&
api_model
.
BuildListRespVO
{
...
...
This diff is collapsed.
Click to expand it.
api/handler/service_operation.go
+
1
-
1
View file @
aa5a2c6a
...
...
@@ -60,6 +60,7 @@ func CreateOperationHandler(mqCli gclient.MQClient) *OperationHandler {
func
(
o
*
OperationHandler
)
Build
(
batchOpReq
model
.
ComponentOpReq
)
(
*
model
.
ComponentOpResult
,
error
)
{
res
:=
batchOpReq
.
BatchOpFailureItem
()
if
err
:=
o
.
build
(
batchOpReq
);
err
!=
nil
{
logrus
.
Errorf
(
"build component failure %s"
,
err
.
Error
())
res
.
ErrMsg
=
err
.
Error
()
}
else
{
res
.
Success
()
...
...
@@ -279,7 +280,6 @@ func (o *OperationHandler) buildFromMarketSlug(r *model.ComponentBuildReq, servi
return
o
.
sendBuildTopic
(
service
.
ServiceID
,
"build_from_market_slug"
,
body
)
}
func
(
o
*
OperationHandler
)
sendBuildTopic
(
serviceID
,
taskType
string
,
body
map
[
string
]
interface
{})
error
{
topic
:=
gclient
.
BuilderTopic
if
o
.
isWindowsService
(
serviceID
)
{
topic
=
gclient
.
WindowsBuilderTopic
...
...
This diff is collapsed.
Click to expand it.
api/metric/metric.go
+
1
-
1
View file @
aa5a2c6a
...
...
@@ -30,7 +30,7 @@ import (
// Metric name parts.
const
(
// Namespace for all metrics.
namespace
=
"r
bd
_api"
namespace
=
"r
egion
_api"
// Subsystem(s).
exporter
=
"exporter"
)
...
...
This diff is collapsed.
Click to expand it.
builder/exector/exector_test.go
+
0
-
2
View file @
aa5a2c6a
...
...
@@ -35,7 +35,6 @@ import (
"github.com/goodrain/rainbond/mq/api/grpc/pb"
mqclient
"github.com/goodrain/rainbond/mq/client"
etcdutil
"github.com/goodrain/rainbond/util/etcd"
k8sutil
"github.com/goodrain/rainbond/util/k8s"
)
...
...
@@ -48,7 +47,6 @@ func Test_exectorManager_buildFromSourceCode(t *testing.T) {
RbdNamespace
:
"rbd-system"
,
MysqlConnectionInfo
:
"EeM2oc:lee7OhQu@tcp(192.168.2.203:3306)/region"
,
}
etcdArgs
:=
etcdutil
.
ClientArgs
{
Endpoints
:
conf
.
EtcdEndPoints
}
event
.
NewManager
(
event
.
EventConfig
{
EventLogServers
:
conf
.
EventLogServers
,
})
...
...
This diff is collapsed.
Click to expand it.
builder/parser/discovery/discovery.go
deleted
100644 → 0
+
0
-
54
View file @
638c206a
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package
discovery
import
(
"strings"
)
// Discoverier blablabla
type
Discoverier
interface
{
Connect
()
error
Fetch
()
([]
*
Endpoint
,
error
)
Close
()
error
}
// NewDiscoverier creates a new Discoverier
func
NewDiscoverier
(
info
*
Info
)
Discoverier
{
switch
strings
.
ToUpper
(
info
.
Type
)
{
case
"ETCD"
:
return
NewEtcd
(
info
)
}
return
nil
}
// Info holds service discovery center information.
type
Info
struct
{
Type
string
`json:"type"`
Servers
[]
string
`json:"servers"`
Key
string
`json:"key"`
Username
string
`json:"username"`
Password
string
`json:"password"`
}
// Endpoint holds endpoint and endpoint status(online or offline).
type
Endpoint
struct
{
Ep
string
`json:"endpoint"`
IsOnline
bool
`json:"is_online"`
}
This diff is collapsed.
Click to expand it.
builder/parser/discovery/etcd.go
deleted
100644 → 0
+
0
-
103
View file @
638c206a
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package
discovery
import
(
"context"
"encoding/json"
"fmt"
"strings"
"time"
c
"github.com/coreos/etcd/clientv3"
"github.com/sirupsen/logrus"
)
// Etcd implements Discoverier
type
etcd
struct
{
cli
*
c
.
Client
endpoints
[]
string
key
string
username
string
password
string
}
// NewEtcd creates a new Discorvery which implemeted by etcd.
func
NewEtcd
(
info
*
Info
)
Discoverier
{
// TODO: validate endpoints
return
&
etcd
{
endpoints
:
info
.
Servers
,
key
:
info
.
Key
,
username
:
info
.
Username
,
password
:
info
.
Password
,
}
}
// Connect connects a etcdv3 client with a given configuration.
func
(
e
*
etcd
)
Connect
()
error
{
cli
,
err
:=
c
.
New
(
c
.
Config
{
Endpoints
:
e
.
endpoints
,
DialTimeout
:
10
*
time
.
Second
,
Username
:
e
.
username
,
Password
:
e
.
password
,
})
if
err
!=
nil
{
logrus
.
Errorf
(
"Endpoints: %s; error connecting etcd: %v"
,
strings
.
Join
(
e
.
endpoints
,
","
),
err
)
return
err
}
e
.
cli
=
cli
return
nil
}
// Fetch fetches data from Etcd.
func
(
e
*
etcd
)
Fetch
()
([]
*
Endpoint
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
5
*
time
.
Second
)
defer
cancel
()
if
e
.
cli
==
nil
{
return
nil
,
fmt
.
Errorf
(
"can't fetching data from etcd without etcdv3 client"
)
}
resp
,
err
:=
e
.
cli
.
Get
(
ctx
,
e
.
key
,
c
.
WithPrefix
())
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error fetching endpoints form etcd: %v"
,
err
)
}
if
resp
==
nil
{
return
nil
,
fmt
.
Errorf
(
"error fetching endpoints form etcd: empty GetResponse"
)
}
var
res
[]
*
Endpoint
for
_
,
kv
:=
range
resp
.
Kvs
{
var
ep
Endpoint
if
err
:=
json
.
Unmarshal
(
kv
.
Value
,
&
ep
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"error parsing the data from etcd: %v"
,
err
)
}
ep
.
Ep
=
strings
.
Replace
(
string
(
kv
.
Key
),
e
.
key
+
"/"
,
""
,
-
1
)
res
=
append
(
res
,
&
ep
)
}
return
res
,
nil
}
// Close shuts down the client's etcd connections.
func
(
e
*
etcd
)
Close
()
error
{
if
e
.
cli
!=
nil
{
return
nil
}
return
e
.
cli
.
Close
()
}
This diff is collapsed.
Click to expand it.
builder/parser/discovery/etcd_test.go
deleted
100644 → 0
+
0
-
19
View file @
638c206a
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. For any non-GPL usage of Rainbond,
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
// must be obtained first.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package
discovery
This diff is collapsed.
Click to expand it.
builder/parser/parser.go
+
0
-
3
View file @
aa5a2c6a
...
...
@@ -26,7 +26,6 @@ import (
"github.com/docker/distribution/reference"
"github.com/goodrain/rainbond/builder/parser/code"
"github.com/goodrain/rainbond/builder/parser/discovery"
"github.com/goodrain/rainbond/builder/parser/types"
"github.com/goodrain/rainbond/builder/sources"
"github.com/sirupsen/logrus"
...
...
@@ -184,8 +183,6 @@ type ServiceInfo struct {
Memory
int
`json:"memory,omitempty"`
Lang
code
.
Lang
`json:"language,omitempty"`
ImageAlias
string
`json:"image_alias,omitempty"`
//For third party services
Endpoints
[]
*
discovery
.
Endpoint
`json:"endpoints,omitempty"`
//os type,default linux
OS
string
`json:"os"`
Name
string
`json:"name,omitempty"`
// module name
...
...
This diff is collapsed.
Click to expand it.
builder/parser/third_party_service.go
+
3
-
37
View file @
aa5a2c6a
...
...
@@ -19,22 +19,16 @@
package
parser
import
(
"encoding/json"
"strings"
"github.com/goodrain/rainbond/builder/parser/discovery"
"github.com/goodrain/rainbond/event"
"github.com/sirupsen/logrus"
)
// ThirdPartyServiceParse is one of the implematation of parser.Parser
type
ThirdPartyServiceParse
struct
{
sourceBody
string
endpoints
[]
*
discovery
.
Endpoint
errors
[]
ParseError
logger
event
.
Logger
errors
[]
ParseError
logger
event
.
Logger
}
// CreateThirdPartyServiceParse creates a new ThirdPartyServiceParse.
...
...
@@ -53,41 +47,13 @@ func (t *ThirdPartyServiceParse) Parse() ParseErrorList {
return
nil
}
var
info
discovery
.
Info
if
err
:=
json
.
Unmarshal
([]
byte
(
t
.
sourceBody
),
&
info
);
err
!=
nil
{
logrus
.
Errorf
(
"wrong source_body: %v, source_body: %s"
,
err
,
t
.
sourceBody
)
t
.
logger
.
Error
(
"第三方检查输入参数错误"
,
map
[
string
]
string
{
"step"
:
"parse"
})
t
.
errors
=
append
(
t
.
errors
,
ParseError
{
FatalError
,
"wrong input data"
,
""
})
return
t
.
errors
}
// TODO: validate data
d
:=
discovery
.
NewDiscoverier
(
&
info
)
err
:=
d
.
Connect
()
if
err
!=
nil
{
t
.
logger
.
Error
(
"error connecting discovery center"
,
map
[
string
]
string
{
"step"
:
"parse"
})
t
.
errors
=
append
(
t
.
errors
,
ParseError
{
FatalError
,
"error connecting discovery center"
,
"please make sure "
+
"the configuration is right and the discovery center is working."
})
return
t
.
errors
}
defer
d
.
Close
()
eps
,
err
:=
d
.
Fetch
()
if
err
!=
nil
{
t
.
logger
.
Error
(
"error fetching endpints"
,
map
[
string
]
string
{
"step"
:
"parse"
})
t
.
errors
=
append
(
t
.
errors
,
ParseError
{
FatalError
,
"error fetching endpints"
,
"please check the given key."
})
return
t
.
errors
}
t
.
endpoints
=
eps
return
nil
}
// GetServiceInfo returns information of third-party service from
// the receiver *ThirdPartyServiceParse.
func
(
t
*
ThirdPartyServiceParse
)
GetServiceInfo
()
[]
ServiceInfo
{
serviceInfo
:=
ServiceInfo
{
Endpoints
:
t
.
endpoints
,
}
serviceInfo
:=
ServiceInfo
{}
return
[]
ServiceInfo
{
serviceInfo
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help