Skip to content

Commit

Permalink
update-namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangming committed Nov 11, 2024
1 parent 1662b71 commit 6544fb4
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions store/postgresql/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ package postgresql

import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"github.com/polarismesh/polaris/common/utils"

Check failure on line 25 in store/postgresql/namespace.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.19)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/polaris-contrib/store-postgresql) --custom-order (gci)
"strconv"
"time"

"github.com/polarismesh/polaris/common/model"

Check failure on line 29 in store/postgresql/namespace.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.19)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/polaris-contrib/store-postgresql) --custom-order (gci)
Expand Down Expand Up @@ -281,8 +283,10 @@ func namespaceFetchRows(rows *sql.Rows) ([]*model.Namespace, error) {
defer rows.Close()

var (
out []*model.Namespace
flag int
out []*model.Namespace
ctimeStr, mtimeStr string
flag int
serviceExportTo string
)

for rows.Next() {
Expand All @@ -293,13 +297,29 @@ func namespaceFetchRows(rows *sql.Rows) ([]*model.Namespace, error) {
&space.Token,
&space.Owner,
&flag,
&space.CreateTime,
&space.ModifyTime)
&ctimeStr,
&mtimeStr,
&serviceExportTo)
if err != nil {
log.Errorf("[Store][database] fetch namespace rows scan err: %s", err.Error())
return nil, err
}

// 将字符串转换为int64
ctimeFloat, err := strconv.ParseFloat(ctimeStr, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse create_time: %v", err)
}
mtimeFloat, err := strconv.ParseFloat(mtimeStr, 64)
if err != nil {
return nil, fmt.Errorf("failed to parse modify_time: %v", err)
}
space.CreateTime = time.Unix(int64(ctimeFloat), 0)
space.ModifyTime = time.Unix(int64(mtimeFloat), 0)

space.ServiceExportTo = map[string]struct{}{}
_ = json.Unmarshal([]byte(serviceExportTo), &space.ServiceExportTo)

space.Valid = true
if flag == 1 {
space.Valid = false
Expand Down

0 comments on commit 6544fb4

Please sign in to comment.