Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Zhengyi Lai <zheng1@yunify.com>
  • Loading branch information
zheng1 committed Jan 21, 2021
1 parent e8183da commit fdf596a
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 28 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Expand Up @@ -11,8 +11,7 @@ COPY . .

RUN mkdir -p /openpitrix_bin
RUN go generate openpitrix.io/openpitrix/pkg/version && \
CGO_ENABLED=0 GOBIN=/openpitrix_bin go install -ldflags '-w -s' -v -tags netgo openpitrix.io/openpitrix/cmd/... && \
CGO_ENABLED=0 GOBIN=/openpitrix_bin go install -ldflags '-w -s' -v -tags netgo openpitrix.io/openpitrix/metadata/cmd/...
CGO_ENABLED=0 GOBIN=/openpitrix_bin go install -ldflags '-w -s' -v -tags netgo openpitrix.io/openpitrix/cmd/hyperpitrix

FROM alpine:3.7

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
@@ -1,6 +1,6 @@
FROM alpine:3.7

COPY ./* /usr/local/bin/
COPY ./hyperpitrix /usr/local/bin/

RUN apk add --update ca-certificates && \
update-ca-certificates && \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -36,7 +36,7 @@ endef
COMPOSE_APP_SERVICES=openpitrix-runtime-manager openpitrix-app-manager openpitrix-category-manager openpitrix-repo-indexer openpitrix-api-gateway openpitrix-repo-manager openpitrix-job-manager openpitrix-task-manager openpitrix-cluster-manager openpitrix-market-manager openpitrix-pilot-service openpitrix-account-service openpitrix-attachment-manager openpitrix-isv-manager openpitrix-notification openpitrix-im-service openpitrix-am-service
#COMPOSE_APP_SERVICES=openpitrix-pilot-service openpitrix-im-service openpitrix-am-service hyperpitrix
COMPOSE_DB_CTRL=openpitrix-db-init openpitrix-im-db-init openpitrix-am-db-init openpitrix-app-db-ctrl openpitrix-repo-db-ctrl openpitrix-runtime-db-ctrl openpitrix-job-db-ctrl openpitrix-task-db-ctrl openpitrix-cluster-db-ctrl openpitrix-iam-db-ctrl openpitrix-attachment-db-ctrl openpitrix-isv-db-ctrl openpitrix-notification-db-ctrl openpitrix-im-db-ctrl openpitrix-am-db-ctrl
CMD?=...
CMD?=hyperpitrix
WITH_METADATA?=yes
WITH_K8S=no
comma:= ,
Expand Down
5 changes: 1 addition & 4 deletions cmd/hyperpitrix/main.go
Expand Up @@ -6,7 +6,6 @@
package main

import (
"openpitrix.io/openpitrix/pkg/apigateway"
"openpitrix.io/openpitrix/pkg/config"
"openpitrix.io/openpitrix/pkg/service/app"
"openpitrix.io/openpitrix/pkg/service/attachment"
Expand Down Expand Up @@ -40,7 +39,5 @@ func main() {
go app.Serve(getConf("app"))
go attachment.Serve(getConf("attachment"))
go runtime_provider.Serve(getConf(""))
go helm.Serve(getConf(""))

apigateway.Serve(getConf(""))
helm.Serve(getConf(""))
}
3 changes: 3 additions & 0 deletions pkg/config/global_config.go
Expand Up @@ -89,6 +89,9 @@ func (r *RuntimeProviderConfig) GetPort() int {
}

func (r *RuntimeProviderConfig) GetHost(provider string) string {
if provider == constants.ProviderKubernetes {
return constants.ClusterManagerHost
}
if len(r.Host) > 0 {
return r.Host
} else {
Expand Down
2 changes: 1 addition & 1 deletion pkg/constants/common.go
Expand Up @@ -9,7 +9,7 @@ import (
)

const (
hyperpitrix = "hyperpitrix"
hyperpitrix = "127.0.0.1"
prefix = "openpitrix-"
ProviderPrefix = "openpitrix-rp-"
RepoManagerHost = hyperpitrix
Expand Down
10 changes: 0 additions & 10 deletions pkg/service/app/resource_control.go
Expand Up @@ -491,10 +491,6 @@ func formatAppSet(ctx context.Context, apps []*models.App, active bool) ([]*pb.A
if err != nil {
return pbApps, err
}
vendorMap, err := getVendorMap(ctx, userIds)
if err != nil {
return pbApps, err
}
for _, app := range apps {

var pbApp *pb.App
Expand All @@ -508,12 +504,6 @@ func formatAppSet(ctx context.Context, apps []*models.App, active bool) ([]*pb.A
if categorySet, ok := rcMap[app.AppId]; ok {
pbApp.CategorySet = categorySet
}
if vendor, ok := vendorMap[app.Isv]; ok {
pbApp.CompanyJoinTime = vendor.StatusTime
pbApp.CompanyName = vendor.CompanyName
pbApp.CompanyProfile = vendor.CompanyProfile
pbApp.CompanyWebsite = vendor.CompanyWebsite
}

pbApps = append(pbApps, pbApp)
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/service/helm/constants.go
Expand Up @@ -4,8 +4,10 @@

package helm

import "openpitrix.io/openpitrix/pkg/constants"

const (
Provider = "kubernetes"
Provider = constants.ProviderKubernetes
ProviderConfig = `
provider_type: helm
enable: true
Expand Down
3 changes: 1 addition & 2 deletions pkg/service/helm/server.go
@@ -1,7 +1,6 @@
package helm

import (
providerclient "openpitrix.io/openpitrix/pkg/client/runtime_provider"
"openpitrix.io/openpitrix/pkg/config"
"openpitrix.io/openpitrix/pkg/manager"
runtimeprovider "openpitrix.io/openpitrix/pkg/service/runtime_provider"
Expand All @@ -20,7 +19,7 @@ type Server struct {

func Serve(cfg *config.Config) {
pi.SetGlobal(cfg)
err := providerclient.RegisterRuntimeProvider(Provider, ProviderConfig)
err := pi.Global().RegisterRuntimeProvider(Provider, ProviderConfig)
if err != nil {
logger.Critical(nil, "failed to register provider config: %+v", err)
}
Expand Down
13 changes: 7 additions & 6 deletions pkg/service/task/controller.go
Expand Up @@ -136,13 +136,14 @@ func (c *Controller) HandleTask(ctx context.Context, taskId string, cb func()) e
return err
}

pilotClient, err := pilotclient.NewClient()
if err != nil {
logger.Error(ctx, "Connect to pilot service failed: %+v", err)
return err
}

if task.Target == constants.TargetPilot {

pilotClient, err := pilotclient.NewClient()
if err != nil {
logger.Error(ctx, "Connect to pilot service failed: %+v", err)
return err
}

switch task.TaskAction {
case vmbased.ActionSetDroneConfig:
config := new(pbtypes.SetDroneConfigRequest)
Expand Down

0 comments on commit fdf596a

Please sign in to comment.