Skip to content

Commit

Permalink
Merge branch 'sealerio:main' into rootfs
Browse files Browse the repository at this point in the history
  • Loading branch information
sjcsjc123 authored Oct 26, 2023
2 parents dc9f859 + 2366836 commit d7d8bd4
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
fi
- name: Install go ci lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.39.0
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.0

- name: Run Linter
run: golangci-lint run -v
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ jobs:
- name: Check out code
uses: actions/checkout@v3
- name: Run Gosec Security Scanner
uses: securego/gosec@master
uses: securego/gosec@v2.14.0
with:
args: ./...
args: ./...
14 changes: 8 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ linters:
enable:
- gofmt
- goimports
- golint
- revive
- stylecheck
- goconst
- gosimple
Expand All @@ -34,26 +34,28 @@ linters:
- ineffassign
- vet
- typecheck
- deadcode
- errcheck
- govet
- staticcheck
- structcheck
- unused
- varcheck
- nilerr
- unparam
- ifshort
- unconvert

issues:
exclude-rules:
- linters:
- golint
text: "AccessKeyId"
- linters:
- typecheck
text: "has no field or method"
- linters:
- revive
text: "just return error instead"

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
service:
# use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.39.0
golangci-lint-version: 1.44.0
4 changes: 2 additions & 2 deletions pkg/checker/node_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ func (n *NodeChecker) Check(cluster *v2.Cluster, phase string) error {
return err
}
var notReadyNodeList []string
var readyCount uint32 = 0
var readyCount uint32
var nodeCount uint32
var notReadyCount uint32 = 0
var notReadyCount uint32
for _, node := range nodes.Items {
nodeIP, nodePhase := getNodeStatus(node)
if nodePhase != ReadyNodeStatus {
Expand Down
4 changes: 2 additions & 2 deletions pkg/checker/pod_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ func (n *PodChecker) Check(cluster *v2.Cluster, phase string) error {
return err
}
for _, podNamespace := range namespacePodList {
var runningCount uint32 = 0
var notRunningCount uint32 = 0
var runningCount uint32
var notRunningCount uint32
var podCount uint32
var notRunningPodList []*corev1.Pod
for _, pod := range podNamespace.PodList.Items {
Expand Down
2 changes: 1 addition & 1 deletion pkg/imageengine/buildah/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

func (engine *Engine) Inspect(opts *options.InspectOptions) (*imagev1.ImageSpec, error) {
if len(opts.ImageNameOrID) == 0 {
return nil, errors.Errorf("image name or image id must be specified.")
return nil, errors.Errorf("image name or image id must be specified")
}

var (
Expand Down
5 changes: 1 addition & 4 deletions pkg/infra/aliyun/ali_ecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ func (a *AliProvider) RetryEcsRequest(request requests.AcsRequest, response resp

func (a *AliProvider) RetryEcsAction(request requests.AcsRequest, response responses.AcsResponse, tryTimes int) error {
return utils.Retry(tryTimes, TrySleepTime, func() error {
if err := a.EcsClient.DoAction(request, response); err != nil {
return err
}
return nil
return a.EcsClient.DoAction(request, response)
})
}

Expand Down
5 changes: 1 addition & 4 deletions pkg/infra/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,7 @@ func (a *ApplyProvider) ReconcileContainer() error {
if err := a.applyResult(masterApplyResult); err != nil {
return err
}
if err := a.applyResult(nodeApplyResult); err != nil {
return err
}
return nil
return a.applyResult(nodeApplyResult)
}

func (a *ApplyProvider) applyResult(result *ApplyResult) error {
Expand Down
8 changes: 4 additions & 4 deletions pkg/infradriver/ssh_infradriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,12 @@ func NewInfraDriver(cluster *v2.Cluster) (InfraDriver, error) {
}

// initialize sshConfigs field
for _, host := range cluster.Spec.Hosts {
if err = mergo.Merge(&host.SSH, &cluster.Spec.SSH); err != nil {
for i := range cluster.Spec.Hosts {
if err = mergo.Merge(&cluster.Spec.Hosts[i].SSH, &cluster.Spec.SSH); err != nil {
return nil, err
}
for _, ip := range host.IPS {
ret.sshConfigs[ip.String()] = ssh.NewSSHClient(&host.SSH, true)
for _, ip := range cluster.Spec.Hosts[i].IPS {
ret.sshConfigs[ip.String()] = ssh.NewSSHClient(&cluster.Spec.Hosts[i].SSH, true)
}
}

Expand Down
10 changes: 2 additions & 8 deletions test/testhelper/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,7 @@ func WriteFile(fileName string, content []byte) error {
}
}

if err := os.WriteFile(fileName, content, settings.FileMode0644); err != nil {
return err
}
return nil
return os.WriteFile(fileName, content, settings.FileMode0644)
}

type SSHClient struct {
Expand Down Expand Up @@ -148,10 +145,7 @@ func MarshalYamlToFile(file string, obj interface{}) error {
if err != nil {
return err
}
if err = WriteFile(file, data); err != nil {
return err
}
return nil
return WriteFile(file, data)
}

// GetLocalFileData get file data from local
Expand Down
2 changes: 1 addition & 1 deletion utils/archive/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func Decompress(src io.Reader, dst string, options Options) (int64, error) {
}

var (
size int64 = 0
size int64
dirs []*tar.Header
tr = tar.NewReader(reader)
)
Expand Down
16 changes: 8 additions & 8 deletions utils/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ func NewSSHClient(ssh *v1.SSH, alsoToStdout bool) Interface {

// GetHostSSHClient is used to executed bash command and no std out to be printed.
func GetHostSSHClient(hostIP net.IP, cluster *v2.Cluster) (Interface, error) {
for _, host := range cluster.Spec.Hosts {
for _, ip := range host.IPS {
for i := range cluster.Spec.Hosts {
for _, ip := range cluster.Spec.Hosts[i].IPS {
if hostIP.Equal(ip) {
if err := mergo.Merge(&host.SSH, &cluster.Spec.SSH); err != nil {
if err := mergo.Merge(&cluster.Spec.Hosts[i].SSH, &cluster.Spec.SSH); err != nil {
return nil, err
}
return NewSSHClient(&host.SSH, false), nil
return NewSSHClient(&cluster.Spec.Hosts[i].SSH, false), nil
}
}
}
Expand All @@ -103,13 +103,13 @@ func GetHostSSHClient(hostIP net.IP, cluster *v2.Cluster) (Interface, error) {

// NewStdoutSSHClient is used to show std out when execute bash command.
func NewStdoutSSHClient(hostIP net.IP, cluster *v2.Cluster) (Interface, error) {
for _, host := range cluster.Spec.Hosts {
for _, ip := range host.IPS {
for i := range cluster.Spec.Hosts {
for _, ip := range cluster.Spec.Hosts[i].IPS {
if hostIP.Equal(ip) {
if err := mergo.Merge(&host.SSH, &cluster.Spec.SSH); err != nil {
if err := mergo.Merge(&cluster.Spec.Hosts[i].SSH, &cluster.Spec.SSH); err != nil {
return nil, err
}
return NewSSHClient(&host.SSH, true), nil
return NewSSHClient(&cluster.Spec.Hosts[i].SSH, true), nil
}
}
}
Expand Down
6 changes: 1 addition & 5 deletions utils/yaml/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ func MarshalToFile(file string, obj interface{}) error {
return err
}

if err = osi.NewAtomicWriter(file).WriteFile(data); err != nil {
return err
}

return nil
return osi.NewAtomicWriter(file).WriteFile(data)
}

func MarshalWithDelimiter(configs ...interface{}) ([]byte, error) {
Expand Down

0 comments on commit d7d8bd4

Please sign in to comment.