Skip to content

Commit

Permalink
feat: context优化
Browse files Browse the repository at this point in the history
  • Loading branch information
LidolLxf committed Jan 14, 2025
1 parent b271799 commit 4d2b75f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (l *ListReleaseV1Action) list() (*helmmanager.ReleaseListData, error) {

// 共享集群支持查询集群下所有命名空间的release
func (l *ListReleaseV1Action) listReleaseByNamespaces() ([]*helmmanager.Release, error) {
namespaces, err := project.ListNamespaces(l.req.GetProjectCode(), l.req.GetClusterID())
namespaces, err := project.ListNamespaces(l.ctx, l.req.GetProjectCode(), l.req.GetClusterID())
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (l *ListReleaseV2Action) list() (*helmmanager.ReleaseListData, error) {

// 共享集群支持查询集群下所有命名空间的release
func (l *ListReleaseV2Action) listReleaseByNamespaces() ([]*helmmanager.Release, error) {
namespaces, err := project.ListNamespaces(l.req.GetProjectCode(), l.req.GetClusterID())
namespaces, err := project.ListNamespaces(l.ctx, l.req.GetProjectCode(), l.req.GetClusterID())
if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func GetProjectByCode(projectCode string) (*bcsproject.Project, error) {
}

// ListNamespaces list namespaces
func ListNamespaces(projectCode, clusterID string) ([]*bcsproject.NamespaceData, error) {
func ListNamespaces(ctx context.Context, projectCode, clusterID string) ([]*bcsproject.NamespaceData, error) {
cli, close, err := client.getProjectClient()
defer func() {
if close != nil {
Expand All @@ -123,7 +123,7 @@ func ListNamespaces(projectCode, clusterID string) ([]*bcsproject.NamespaceData,
if err != nil {
return nil, err
}
p, err := cli.Namespace.ListNamespaces(context.Background(), &bcsproject.ListNamespacesRequest{
p, err := cli.Namespace.ListNamespaces(ctx, &bcsproject.ListNamespacesRequest{
ProjectCode: projectCode,
ClusterID: clusterID,
})
Expand Down

0 comments on commit 4d2b75f

Please sign in to comment.