Skip to content

Commit

Permalink
fix env apis
Browse files Browse the repository at this point in the history
Signed-off-by: lou <[email protected]>
  • Loading branch information
27149chen committed Nov 29, 2021
1 parent e2ca018 commit 3c091de
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 51 deletions.
13 changes: 0 additions & 13 deletions pkg/microservice/aslan/core/environment/handler/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,19 +373,6 @@ func GetProductInfo(c *gin.Context) {
ctx.Resp, ctx.Err = service.GetProductInfo(ctx.UserName, envName, projectName, ctx.Logger)
}

func ListRenderCharts(c *gin.Context) {
ctx := internalhandler.NewContext(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()

envName := c.Param("name")
projectName := c.Query("projectName")

ctx.Resp, ctx.Err = service.ListRenderCharts(projectName, envName, ctx.Logger)
if ctx.Err != nil {
ctx.Logger.Errorf("failed to listRenderCharts %s %s: %v", envName, projectName, ctx.Err)
}
}

func GetHelmChartVersions(c *gin.Context) {
ctx := internalhandler.NewContext(c)
defer func() { internalhandler.JSONResponse(c, ctx) }()
Expand Down
1 change: 0 additions & 1 deletion pkg/microservice/aslan/core/environment/handler/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (*Router) Inject(router *gin.RouterGroup) {
environments.PUT("/:name/renderset", gin2.UpdateOperationLogStatus, UpdateHelmProductRenderset)
environments.GET("/:name/helmChartVersions", GetHelmChartVersions)
environments.GET("/:name/productInfo", GetProductInfo)
environments.GET("/:name/helmRenderCharts", ListRenderCharts)
environments.DELETE("/:name", gin2.UpdateOperationLogStatus, DeleteProduct)
environments.GET("/:name/groups", ListGroups)
environments.GET("/:name/workloads", ListWorkloadsInEnv)
Expand Down
23 changes: 0 additions & 23 deletions pkg/microservice/aslan/core/environment/service/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -1197,29 +1197,6 @@ func GetProductIngress(productName string, log *zap.SugaredLogger) ([]*ProductIn
return productIngressInfos, nil
}

// ListRenderCharts 获取集成环境中的values.yaml的值
func ListRenderCharts(productName, envName string, log *zap.SugaredLogger) ([]*template.RenderChart, error) {
renderSetOpt := &commonrepo.RenderSetFindOption{Name: productName}
if envName != "" {
opt := &commonrepo.ProductFindOptions{Name: productName, EnvName: envName}
productResp, err := commonrepo.NewProductColl().Find(opt)
if err != nil {
log.Errorf("GetProduct envName:%s, productName:%s, err:%+v", envName, productName, err)
return nil, e.ErrListRenderSets.AddDesc(err.Error())
}

renderSetName := productResp.Namespace
renderSetOpt = &commonrepo.RenderSetFindOption{Name: renderSetName, Revision: productResp.Render.Revision}
}

renderSet, err := commonrepo.NewRenderSetColl().Find(renderSetOpt)
if err != nil {
log.Errorf("find helm renderset[%s] error: %v", productName, err)
return nil, e.ErrListRenderSets.AddDesc(err.Error())
}
return renderSet.ChartInfos, nil
}

func GetHelmChartVersions(productName, envName string, log *zap.SugaredLogger) ([]*commonmodels.HelmVersions, error) {
var (
helmVersions = make([]*commonmodels.HelmVersions, 0)
Expand Down
2 changes: 1 addition & 1 deletion pkg/microservice/cron/core/service/client/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *Client) GetEnvService(productName, envName string, log *zap.SugaredLogg
err error
envObj = new(service.ProductResp)
)
url := fmt.Sprintf("%s/environment/environments/%s?envName=%s", c.APIBase, productName, envName)
url := fmt.Sprintf("%s/environment/environments/%s?projectName=%s", c.APIBase, envName, productName)
request, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Errorf("GetService new http request error: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/microservice/warpdrive/core/service/taskplugin/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,10 @@ func (p *DeployTaskPlugin) Run(ctx context.Context, pipelineTask *task.Task, _ *
}

func (p *DeployTaskPlugin) getProductInfo(ctx context.Context, args *EnvArgs) (*types.Product, error) {
url := fmt.Sprintf("/api/environment/environments/%s/productInfo", args.ProductName)
url := fmt.Sprintf("/api/environment/environments/%s/productInfo", args.EnvName)

prod := &types.Product{}
_, err := p.httpClient.Get(url, httpclient.SetResult(prod), httpclient.SetQueryParam("envName", args.EnvName))
_, err := p.httpClient.Get(url, httpclient.SetResult(prod), httpclient.SetQueryParam("projectName", args.ProductName))
if err != nil {
return nil, err
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/shared/client/aslan/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (c *Client) ListEnvironments(projectName string) ([]*Environment, error) {
url := "/environment/environments"

res := make([]*Environment, 0)
_, err := c.Get(url, httpclient.SetQueryParam("productName", projectName), httpclient.SetResult(&res))
_, err := c.Get(url, httpclient.SetQueryParam("projectName", projectName), httpclient.SetResult(&res))
if err != nil {
return nil, err
}
Expand All @@ -36,10 +36,10 @@ func (c *Client) ListEnvironments(projectName string) ([]*Environment, error) {
}

func (c *Client) GetEnvironment(envName, projectName string) (*Environment, error) {
url := fmt.Sprintf("/environment/environments/%s", projectName)
url := fmt.Sprintf("/environment/environments/%s", envName)

res := &Environment{}
_, err := c.Get(url, httpclient.SetQueryParam("envName", envName), httpclient.SetResult(res))
_, err := c.Get(url, httpclient.SetQueryParam("projectName", projectName), httpclient.SetResult(res))
if err != nil {
return nil, err
}
Expand All @@ -48,10 +48,10 @@ func (c *Client) GetEnvironment(envName, projectName string) (*Environment, erro
}

func (c *Client) ListHelmServicesInEnvironment(envName, projectName string) ([]*Service, error) {
url := fmt.Sprintf("/environment/environments/%s/groups/helm", projectName)
url := fmt.Sprintf("/environment/environments/%s/groups", envName)

res := &ServicesResp{}
_, err := c.Get(url, httpclient.SetQueryParam("envName", envName), httpclient.SetResult(res))
_, err := c.Get(url, httpclient.SetQueryParam("projectName", projectName), httpclient.SetResult(res))
if err != nil {
return nil, err
}
Expand All @@ -60,20 +60,20 @@ func (c *Client) ListHelmServicesInEnvironment(envName, projectName string) ([]*
}

func (c *Client) ListServices(envName, projectName string) ([]*Service, error) {
url := fmt.Sprintf("/environment/environments/%s/groups", projectName)
url := fmt.Sprintf("/environment/environments/%s/groups", envName)

res := make([]*Service, 0)
_, err := c.Get(url, httpclient.SetQueryParam("envName", envName), httpclient.SetResult(&res))
_, err := c.Get(url, httpclient.SetQueryParam("projectName", projectName), httpclient.SetResult(&res))

return res, err
}

func (c *Client) GetServiceDetail(projectName, serviceName, envName string) (*ServiceDetail, error) {
url := fmt.Sprintf("/environment/environments/%s/services/%s", projectName, serviceName)
url := fmt.Sprintf("/environment/environments/%s/services/%s", envName, serviceName)

res := &ServiceDetail{}
req := map[string]string{
"envName": envName,
"projectName": projectName,
}
_, err := c.Get(url, httpclient.SetQueryParams(req), httpclient.SetResult(res))
if err != nil {
Expand All @@ -100,7 +100,7 @@ func (c *Client) ListServicesStatusByEnvironment(envName, projectName string) ([
for _, s := range ss {
res = append(res, &ServiceStatus{
ServiceName: s.ServiceName,
Status: s.Status,
Status: s.Status,
})
}

Expand All @@ -113,7 +113,7 @@ func (c *Client) ListServicesStatusByEnvironment(envName, projectName string) ([
for _, s := range ss {
res = append(res, &ServiceStatus{
ServiceName: s.ServiceName,
Status: s.Status,
Status: s.Status,
})
}
}
Expand Down

0 comments on commit 3c091de

Please sign in to comment.