Skip to content

Commit

Permalink
Merge pull request #58 from aerospike/go22
Browse files Browse the repository at this point in the history
updating go to 1.22 and fixing vulnerability.
  • Loading branch information
a-spiker authored Sep 30, 2024
2 parents 465f90b + 437c989 commit 141a52a
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup-go
uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- name: Checkout sources
uses: actions/checkout@v3
- name: Generate Mocks
Expand All @@ -26,5 +26,5 @@ jobs:
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
version: v1.59.1
args: --timeout=5m
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ linters-settings:
- performance
- style
govet:
check-shadowing: true
enable:
- fieldalignment
- shadow
nolintlint:
require-explanation: true
require-specific: true
Expand Down Expand Up @@ -56,7 +56,7 @@ linters:

run:
issues-exit-code: 1
go: '1.21'
go: '1.22'
# skip-dirs:
# - sample
# skip-files:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ endif
MOCKGEN ?= $(GOBIN)/mockgen
MOCKGEN_VERSION ?= v0.3.0
GOLANGCI_LINT ?= $(GOBIN)/golangci-lint
GOLANGCI_LINT_VERSION ?= v1.54.0
GOLANGCI_LINT_VERSION ?= v1.59.1

.PHONY: golanci-lint
golanci-lint: $(GOLANGCI_LINT) ## Download golangci-lint locally if necessary.
Expand Down
1 change: 1 addition & 0 deletions asconfig/as_getconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ func traverseConfig(logger logr.Logger, conf interface{}, path, context string)
if !ok {
return nil, fmt.Errorf("invalid configuration type")
}

conf = stats[token]
}

Expand Down
8 changes: 8 additions & 0 deletions asconfig/as_setconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,30 @@ func createSetConfigXDRCmdList(tokens []string, operationValueMap map[Operation]
// Assuming there are only 2 section types in XDR context (DC and Namespace)
if token == KeyName {
objectAddedOrRemoved = true

if prevToken == info.ConfigDCContext {
// example of a command: set-config:context=xdr;dc=dc1;action=create
if _, ok := operationValueMap[Add]; ok {
action = "create"
}

if _, ok := operationValueMap[Remove]; ok {
action = "delete"
}
}

if prevToken == info.ConfigNamespaceContext {
// example of a command: set-config:context=xdr;dc=dc1;namespace=test;action=add
if _, ok := operationValueMap[Add]; ok {
action = Add
}

if _, ok := operationValueMap[Remove]; ok {
action = Remove
}
}
}

prevToken = token
}
}
Expand Down Expand Up @@ -423,9 +428,11 @@ func rearrangeConfigMap(log logr.Logger, configMap DynamicConfigMap) []string {
if strings.HasSuffix(k, sep+keyNodeAddressPorts) {
if _, ok := v[Remove]; ok {
dc := rearrangedConfigMap.PushFront(k)

if lastDC == nil {
lastDC = dc
}

continue
} else if lastDCConfig != nil {
// Add 'node-address-ports' after all DC direct fields
Expand All @@ -441,6 +448,7 @@ func rearrangeConfigMap(log logr.Logger, configMap DynamicConfigMap) []string {
// Add modified DC direct fields after the DC names and before the namespaces
nap = rearrangedConfigMap.InsertAfter(k, lastDC)
}

if lastDCConfig == nil {
lastDCConfig = nap
}
Expand Down
1 change: 1 addition & 0 deletions asconfig/as_setconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func (s *AsSetConfigTestSuite) TestCreateSetConfigCmdList() {

s.mockASConn.EXPECT().RunInfo(gomock.Any(), gomock.Any()).Return(map[string]string{
"logs": "0:stderr"}, nil).AnyTimes()

result, err := CreateSetConfigCmdList(logger, tc.inputConf, s.mockASConn, policy)

s.Assert().Nil(err)
Expand Down
1 change: 1 addition & 0 deletions asconfig/generate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ func (s *GenerateUnitTestSuite) TestGenerate() {
s.Run(tc.name, func() {
s.mockGetter.EXPECT().AllConfigs().Return(convertIntToInt64(tc.allConfigs), nil)
s.mockGetter.EXPECT().GetAsInfo("metadata").Return(tc.metadata, nil)

logger := logr.Discard()
expected := newGenConf(
convertIntToInt64(tc.expected),
Expand Down
3 changes: 3 additions & 0 deletions asconfig/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -965,6 +965,7 @@ func convertInterfaceSlice(log logr.Logger, k string, v []interface{}) (result i
switch v1.(type) {
case string:
temp := make([]string, len(v))

for i, s := range v {
if boolVal, isBool := s.(bool); isBool && isSpecialStringField(k) {
temp[i] = strconv.FormatBool(boolVal)
Expand All @@ -977,11 +978,13 @@ func convertInterfaceSlice(log logr.Logger, k string, v []interface{}) (result i

case map[string]interface{}, lib.Stats:
temp := make([]Conf, len(v))

for i, m := range v {
m1, ok := m.(map[string]interface{})
if !ok {
m1, ok = m.(lib.Stats)
}

if ok {
temp[i] = toConf(log, m1)
} else {
Expand Down
2 changes: 1 addition & 1 deletion deployment/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ func (c *cluster) getClusterNamespaces(hostIDs []string) (
namespaces := map[string][]string{}

for hostID, info := range infoResults {
if len(info[CmdNamespaces]) > 0 {
if info[CmdNamespaces] != "" {
namespaces[hostID] = strings.Split(info[CmdNamespaces], ";")
} else {
return nil, fmt.Errorf(
Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/aerospike/aerospike-management-lib

go 1.21
go 1.22

require (
github.com/aerospike/aerospike-client-go/v7 v7.1.0
Expand Down Expand Up @@ -35,9 +35,9 @@ require (
go.opentelemetry.io/otel/metric v1.25.0 // indirect
go.opentelemetry.io/otel/sdk v1.25.0 // indirect
go.opentelemetry.io/otel/trace v1.25.0 // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.14.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand All @@ -50,10 +50,10 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/yuin/gopher-lua v1.1.1 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
google.golang.org/grpc v1.63.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
24 changes: 12 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,36 +108,36 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
15 changes: 8 additions & 7 deletions info/as_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const (
constStatSIndex = "sindex/" // StatSindex
constStatNSNames = "namespaces" // StatNamespaces
constStatDCNames = "dcs" // StatDcs need dc names
constStatLogIDS = "logs" // StatLogs need logging id
constStatLogIDs = "logs" // StatLogs need logging id

cmdConfigNetwork = "get-config:context=network" // ConfigNetwork
cmdConfigService = "get-config:context=service" // ConfigService
Expand Down Expand Up @@ -397,7 +397,7 @@ func GetTLSNamesCmd() string {

// GetLogNamesCmd returns the command to get log names
func GetLogNamesCmd() string {
return constStatLogIDS
return constStatLogIDs
}

// GetSindexNamesCmd returns the command to get sindex names
Expand Down Expand Up @@ -436,7 +436,7 @@ func ParseTLSNames(m map[string]string) []string {

// ParseLogNames parses all log names
func ParseLogNames(m map[string]string) []string {
logs := ParseIntoMap(m[constStatLogIDS], ";", ":")
logs := ParseIntoMap(m[constStatLogIDs], ";", ":")
names := make([]string, 0, len(logs))

for _, l := range logs {
Expand Down Expand Up @@ -467,7 +467,7 @@ func ParseSetNames(m map[string]string, ns string) []string {

func (info *AsInfo) getCoreInfo() (map[string]string, error) {
m, err := info.RequestInfo(
constStatNSNames, constStatDCNames, constStatSIndex, constStatLogIDS, cmdMetaBuild,
constStatNSNames, constStatDCNames, constStatSIndex, constStatLogIDs, cmdMetaBuild,
)
if err != nil {
return nil, err
Expand Down Expand Up @@ -589,7 +589,7 @@ func (info *AsInfo) createConfigCmdList(
cmdList = append(cmdList, cmdConfigSecurity)

case ConfigLoggingContext:
logs := ParseIntoMap(m[constStatLogIDS], ";", ":")
logs := ParseIntoMap(m[constStatLogIDs], ";", ":")
for id := range logs {
cmdList = append(cmdList, cmdConfigLogging+id)
}
Expand Down Expand Up @@ -1070,7 +1070,7 @@ func parseConfigInfo(rawMap map[string]string) lib.Stats {

func parseAllLoggingConfig(rawMap map[string]string, cmd string) lib.Stats {
logConfigMap := make(lib.Stats)
logs := ParseIntoMap(rawMap[constStatLogIDS], ";", ":")
logs := ParseIntoMap(rawMap[constStatLogIDs], ";", ":")

for id := range logs {
m := parseBasicConfigInfo(rawMap[cmd+id], ":")
Expand Down Expand Up @@ -1118,7 +1118,7 @@ func parseConfigSetsInfo(res string) lib.Stats {

for _, setStat := range ml {
set := setStat.TryString("set", "")
if len(set) > 0 {
if set != "" {
for k := range setStat {
if !strings.Contains(k, "-") {
// TODO: Is it good enough to consider keys with '-' as
Expand Down Expand Up @@ -1448,6 +1448,7 @@ func parseLatencyInfo(log logr.Logger, rawStr string) lib.Stats {
}

nstats["tps"] = nstats.TryFloat("tps", 0) + opsCount

nBuckets := nstats["buckets"].([]string)
if len(buckets) > len(nBuckets) {
nstats["buckets"] = append(nBuckets, buckets[len(nBuckets):]...)
Expand Down
2 changes: 1 addition & 1 deletion test/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var PortStart = 10000
var IP = "127.0.0.1"
var WordDirAbs = "test/work"
var Image = "aerospike/aerospike-server-enterprise:7.0.0.2"
var ContainerPrefix = "aerospike_mgmt_lib_test_" //nolint:gosec // This is not a credential
var ContainerPrefix = "aerospike_mgmt_lib_test_"
var User = "admin"
var Password = "admin"

Expand Down

0 comments on commit 141a52a

Please sign in to comment.