Skip to content

Commit

Permalink
bcs-log-manager、 bcs-kube-agent、 bcs-k8s-watch、bcs-helm-manager规范修改 (#…
Browse files Browse the repository at this point in the history
…2663)

* bcs-helm-manager规范修改

* bcs-k8s-watch规范修改

* bcs-kube-agent规范修改

* bcs-log-manager规范修改
  • Loading branch information
LidolLxf authored Sep 28, 2023
1 parent dcc4400 commit 65548fa
Show file tree
Hide file tree
Showing 161 changed files with 612 additions and 608 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* limitations under the License.
*/

// Package main xxx
package main

import (
Expand Down
2 changes: 2 additions & 0 deletions bcs-services/bcs-helm-manager/internal/actions/addons/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* limitations under the License.
*/

// Package addons xxx
package addons

import (
Expand All @@ -18,6 +19,7 @@ import (

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *StopAddonsAction) Handle(ctx context.Context,
return nil
}

func (s *StopAddonsAction) saveDB(ctx context.Context, ns, chartName string) error {
func (s *StopAddonsAction) saveDB(ctx context.Context, ns, chartName string) error { // nolint
old, err := s.model.GetRelease(ctx, s.req.GetClusterID(), ns, s.req.GetName())
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,10 @@ func (u *UpgradeAddonsAction) saveDB(ctx context.Context, ns, chartName string)
create := false
old, err := u.model.GetRelease(ctx, u.req.GetClusterID(), ns, u.req.GetName())
if err != nil {
if errors.Is(err, drivers.ErrTableRecordNotFound) {
create = true
} else {
if !errors.Is(err, drivers.ErrTableRecordNotFound) {
return err
}
create = true
}

createBy := auth.GetUserFromCtx(ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* limitations under the License.
*/

// Package chart xxx
package chart

import (
Expand Down Expand Up @@ -153,7 +154,7 @@ func (d *DeleteChartVersionAction) deleteChartVersion() error {
repository, err := d.model.GetRepository(d.ctx, projectCode, repoName)
if err != nil {
blog.Errorf("delete chart version failed, %s, "+
"projectCode: %s, repository: %s, chartName: %s, version: %s, operator: %s",
"projectCode: %s, repository: %s, chartName: %s, version: %s, operator: %s", // nolint
err.Error(), projectCode, repoName, chartName, version, username)
d.setResp(common.ErrHelmManagerListActionFailed, err.Error())
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (g *GetChartDetailV1Action) setResp(err common.HelmManagerError, message st
}

func getValuesFiles(files map[string]*repo.FileContent, chartName string) []string {
valuesFile := make([]string, 0, 0)
valuesFile := make([]string, 0)
defaultValuesFile := fmt.Sprintf("%s/%s", chartName, "values.yaml")
hasDefaultValuesFile := false
for _, item := range files {
Expand All @@ -232,7 +232,7 @@ func getValuesFiles(files map[string]*repo.FileContent, chartName string) []stri
}
}

sort.Sort(sort.StringSlice(valuesFile))
sort.Strings(valuesFile)
if hasDefaultValuesFile {
valuesFile = append([]string{defaultValuesFile}, valuesFile...)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (d *DownloadChartAction) downloadChart() error {

d.resp.ContentType = "application/octet-stream"
d.resp.Data = content
grpc.SendHeader(d.ctx, metadata.New(map[string]string{
grpc.SendHeader(d.ctx, metadata.New(map[string]string{ // nolint
"Content-Disposition": fmt.Sprintf("attachment; filename=%s-%s.tgz", chartName, version),
}))
blog.Infof("download chart successfully, "+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (l *ListChartActionV1) list() error {
return nil
}

func (l *ListChartActionV1) getCondition() *operator.Condition {
func (l *ListChartActionV1) getCondition() *operator.Condition { // nolint
cond := make(operator.M)
if l.req.ProjectCode != nil {
cond.Update(entity.FieldKeyProjectID, contextx.GetProjectCodeFromCtx(l.ctx))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* 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 chart
Expand All @@ -18,9 +17,9 @@ import (
"fmt"
"os"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/chartmuseum/helm-push/pkg/helm"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* limitations under the License.
*/

// Package release xxx
package release

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Licensed under the MIT License (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under
* 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 release
Expand All @@ -20,6 +19,7 @@ import (

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/release"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ func (l *ListReleaseV1Action) mergeReleases(clusterReleases,
release = filterIndex(int((l.req.GetPage()-1)*l.req.GetSize()), int(l.req.GetSize()), release)
}
return &helmmanager.ReleaseListData{
Page: common.GetUint32P(uint32(l.req.GetPage())),
Size: common.GetUint32P(uint32(l.req.GetSize())),
Page: common.GetUint32P(l.req.GetPage()),
Size: common.GetUint32P(l.req.GetSize()),
Total: common.GetUint32P(uint32(total)),
Data: release,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewReleasePreviewAction(model store.HelmManagerModel, platform repo.Platfor
}

// ReleasePreviewAction provides the action to get release preview
type ReleasePreviewAction struct {
type ReleasePreviewAction struct { // nolint
ctx context.Context

model store.HelmManagerModel
Expand Down Expand Up @@ -94,8 +94,7 @@ func (r *ReleasePreviewAction) getReleasePreview() (*helmmanager.ReleasePreview,

// revision 之间对比,用于回滚
if r.req.GetRevision() != 0 {
newRelease := &release.Release{}
newRelease, err = r.releaseHandler.Cluster(r.req.GetClusterID()).Get(r.ctx, release.GetOption{
newRelease, err := r.releaseHandler.Cluster(r.req.GetClusterID()).Get(r.ctx, release.GetOption{ // nolint
Namespace: r.req.GetNamespace(), Name: r.req.GetName(), Revision: int(r.req.GetRevision())})
if err != nil {
return nil, fmt.Errorf("get release revision %d failed, err %s", r.req.GetRevision(), err.Error())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,15 @@ func (r *RollbackReleaseV1Action) saveDB() error {
create := false
_, err := r.model.GetRelease(r.ctx, r.req.GetClusterID(), r.req.GetNamespace(), r.req.GetName())
if err != nil {
if errors.Is(err, drivers.ErrTableRecordNotFound) {
create = true
} else {
if !errors.Is(err, drivers.ErrTableRecordNotFound) {
return err
}
create = true
}

username := auth.GetUserFromCtx(r.ctx)
if create {
if err := r.model.CreateRelease(r.ctx, &entity.Release{
if err = r.model.CreateRelease(r.ctx, &entity.Release{
Name: r.req.GetName(),
ProjectCode: contextx.GetProjectCodeFromCtx(r.ctx),
Namespace: r.req.GetNamespace(),
Expand All @@ -141,9 +140,9 @@ func (r *RollbackReleaseV1Action) saveDB() error {
entity.FieldKeyStatus: helmrelease.StatusPendingRollback.String(),
entity.FieldKeyMessage: "",
}
if err := r.model.UpdateRelease(r.ctx, r.req.GetClusterID(), r.req.GetNamespace(),
if err = r.model.UpdateRelease(r.ctx, r.req.GetClusterID(), r.req.GetNamespace(),
r.req.GetName(), rl); err != nil {

return err
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,15 @@ func (u *UninstallReleaseV1Action) saveDB() error {
create := false
_, err := u.model.GetRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(), u.req.GetName())
if err != nil {
if errors.Is(err, drivers.ErrTableRecordNotFound) {
create = true
} else {
if !errors.Is(err, drivers.ErrTableRecordNotFound) {
return err
}
create = true
}

username := auth.GetUserFromCtx(u.ctx)
if create {
if err := u.model.CreateRelease(u.ctx, &entity.Release{
if err = u.model.CreateRelease(u.ctx, &entity.Release{
ProjectCode: contextx.GetProjectCodeFromCtx(u.ctx),
Name: u.req.GetName(),
Namespace: u.req.GetNamespace(),
Expand All @@ -132,9 +131,9 @@ func (u *UninstallReleaseV1Action) saveDB() error {
entity.FieldKeyStatus: helmrelease.StatusUninstalling.String(),
entity.FieldKeyMessage: "",
}
if err := u.model.UpdateRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(),
if err = u.model.UpdateRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(),
u.req.GetName(), rl); err != nil {

return err
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ func (u *UpgradeReleaseV1Action) saveDB() error {
create := false
old, err := u.model.GetRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(), u.req.GetName())
if err != nil {
if errors.Is(err, drivers.ErrTableRecordNotFound) {
create = true
} else {
if !errors.Is(err, drivers.ErrTableRecordNotFound) {
return err
}
create = true
}

createBy := auth.GetUserFromCtx(u.ctx)
Expand All @@ -140,7 +139,7 @@ func (u *UpgradeReleaseV1Action) saveDB() error {
if create {
u.createBy = createBy
u.updateBy = createBy
if err := u.model.CreateRelease(u.ctx, &entity.Release{
if err = u.model.CreateRelease(u.ctx, &entity.Release{
Name: u.req.GetName(),
ProjectCode: contextx.GetProjectCodeFromCtx(u.ctx),
Namespace: u.req.GetNamespace(),
Expand Down Expand Up @@ -179,9 +178,9 @@ func (u *UpgradeReleaseV1Action) saveDB() error {
entity.FieldKeyStatus: helmrelease.StatusPendingUpgrade.String(),
entity.FieldKeyMessage: "",
}
if err := u.model.UpdateRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(),
if err = u.model.UpdateRelease(u.ctx, u.req.GetClusterID(), u.req.GetNamespace(),
u.req.GetName(), rl); err != nil {

return err
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"strings"
"time"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"gopkg.in/yaml.v2"
"helm.sh/helm/v3/pkg/releaseutil"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/repo"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store"
helmmanager "github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/proto/bcs-helm-manager"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* limitations under the License.
*/

// Package repository xxx
package repository

import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"context"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/utils/contextx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"context"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/utils/contextx"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (

"github.com/Tencent/bk-bcs/bcs-common/common/blog"
"github.com/Tencent/bk-bcs/bcs-common/pkg/odm/operator"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store/entity"
Expand All @@ -26,7 +27,7 @@ import (
)

const (
defaultSize = 1000
defaultSize = 1000 // nolint
)

// NewListRepositoryAction return a new ListRepositoryAction instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"context"

"github.com/Tencent/bk-bcs/bcs-common/common/blog"

"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/auth"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/common"
"github.com/Tencent/bk-bcs/bcs-services/bcs-helm-manager/internal/store"
Expand Down
Loading

0 comments on commit 65548fa

Please sign in to comment.