Skip to content

Commit

Permalink
fix: fix broken ci lint check (#4)
Browse files Browse the repository at this point in the history
Signed-off-by: Junduo Dong <[email protected]>
  • Loading branch information
An-DJ authored Nov 21, 2023
1 parent 2f1d9ed commit 8f15d82
Show file tree
Hide file tree
Showing 14 changed files with 86 additions and 26 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: build

on:
push:
Expand All @@ -39,11 +39,6 @@ jobs:
with:
go-version: '1.20'

- name: Lint check
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/bin v1.51.2
golangci-lint run
- name: Build
run: go build .

Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/go-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 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.
#

# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: go-lint

on:
push:
branches: [ "main" ]
pull_request:
branches:
- 'main'

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Lint check
run: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sudo sh -s -- -b /usr/local/bin v1.51.2
golangci-lint run
3 changes: 2 additions & 1 deletion action/common/args_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ package common

import (
"bytes"
"github.com/stretchr/testify/assert"
"os"
"testing"

"github.com/stretchr/testify/assert"
)

var argsTestCases = []struct {
Expand Down
3 changes: 2 additions & 1 deletion action/quit.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
package action

import (
"os"

"github.com/seata/seata-ctl/action/common"
"github.com/spf13/cobra"
"os"
)

func init() {
Expand Down
7 changes: 3 additions & 4 deletions action/set/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,15 @@ var ConfigCmd = &cobra.Command{
if err != nil {
common.Log("", err)
}
configType := seata.NORMAL_CONFIG
configType := seata.NormalConfig
if setRegistry {
configType = seata.REGISTRY_CONF
configType = seata.RegistryConf
} else if setConfigCenter {
configType = seata.CONFIG_CENTER_CONF
configType = seata.ConfigCenterConf
}
common.Log(seata.SetConfiguration(data, configType))
kvData = "{}"
setRegistry = false
setConfigCenter = false
configType = seata.NORMAL_CONFIG
},
}
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ package cmd

import (
"fmt"
"os"

"github.com/seata/seata-ctl/action"
"github.com/seata/seata-ctl/action/common"
"github.com/seata/seata-ctl/seata"
"github.com/spf13/cobra"
"github.com/spf13/viper"
"os"
)

var (
Expand All @@ -39,7 +40,7 @@ var (

func init() {
credential := seata.GetAuth()
rootCmd.PersistentFlags().StringVar(&credential.ServerIp, "ip", "127.0.0.1", "Seata Server IP")
rootCmd.PersistentFlags().StringVar(&credential.ServerIP, "ip", "127.0.0.1", "Seata Server IP")
rootCmd.PersistentFlags().IntVar(&credential.ServerPort, "port", 7091, "Seata Server Admin Port")
rootCmd.PersistentFlags().StringVar(&credential.Username, "username", "seata", "Username")
rootCmd.PersistentFlags().StringVar(&credential.Password, "password", "seata", "Password")
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.9.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
3 changes: 2 additions & 1 deletion seata/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"bytes"
"encoding/json"
"errors"
"github.com/jedib0t/go-pretty/v6/table"
"net/http"
"sort"

"github.com/jedib0t/go-pretty/v6/table"
)

func BuildPostRequestWithArrayData(urlStr string, data []string) (*http.Request, error) {
Expand Down
4 changes: 2 additions & 2 deletions seata/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
var auth Auth

type Auth struct {
ServerIp string
ServerIP string
ServerPort int
Username string
Password string
Expand All @@ -52,7 +52,7 @@ func (auth *Auth) GetToken() (string, error) {
}

func (auth *Auth) GetAddress() string {
return auth.ServerIp + ":" + strconv.Itoa(auth.ServerPort)
return auth.ServerIP + ":" + strconv.Itoa(auth.ServerPort)
}

func GetAuth() *Auth {
Expand Down
13 changes: 11 additions & 2 deletions seata/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ func GetConfigurations(params []string) (string, error) {
}

resp, err := (&http.Client{}).Do(request)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand All @@ -66,9 +69,9 @@ func GetConfigurations(params []string) (string, error) {
func SetConfiguration(data map[string]string, configType ConfigType) (string, error) {
urlStr := HTTPProtocol + GetAuth().GetAddress()
switch configType {
case REGISTRY_CONF:
case RegistryConf:
urlStr = urlStr + RegistryConfigurationURL
case CONFIG_CENTER_CONF:
case ConfigCenterConf:
urlStr = urlStr + ConfigCenterConfigurationURL
default:
urlStr = urlStr + ConfigurationURL
Expand All @@ -79,6 +82,9 @@ func SetConfiguration(data map[string]string, configType ConfigType) (string, er
}

resp, err := (&http.Client{}).Do(request)
if err != nil {
return "", err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down Expand Up @@ -110,6 +116,9 @@ func ReloadConfiguration() {
request.Header.Set("authorization", token)
request.Header.Set("Content-Type", "application/json")
resp, err := (&http.Client{}).Do(request)
if err != nil {
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions seata/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const (
type ConfigType int

const (
REGISTRY_CONF ConfigType = iota
CONFIG_CENTER_CONF
NORMAL_CONFIG
RegistryConf ConfigType = iota
ConfigCenterConf
NormalConfig
)

type BaseResponse struct {
Expand Down
6 changes: 5 additions & 1 deletion seata/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ package seata
import (
"encoding/json"
"fmt"
"github.com/jedib0t/go-pretty/v6/table"
"io"
"net/http"
"os"

"github.com/jedib0t/go-pretty/v6/table"
)

type NodeStatusResponse struct {
Expand All @@ -47,6 +48,9 @@ func GetStatus() {
request, _ := http.NewRequest("GET", url, nil)
request.Header.Set("authorization", token)
resp, err := (&http.Client{}).Do(request)
if err != nil {
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down
9 changes: 9 additions & 0 deletions seata/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ func BeginTxn(timeout int) {
request, _ := http.NewRequest("POST", url, nil)
request.Header.Set("authorization", token)
resp, err := (&http.Client{}).Do(request)
if err != nil {
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down Expand Up @@ -72,6 +75,9 @@ func CommitTxn(xid string) {
request, _ := http.NewRequest("POST", url, nil)
request.Header.Set("authorization", token)
resp, err := (&http.Client{}).Do(request)
if err != nil {
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down Expand Up @@ -102,6 +108,9 @@ func RollbackTxn(xid string) {
request, _ := http.NewRequest("POST", url, nil)
request.Header.Set("authorization", token)
resp, err := (&http.Client{}).Do(request)
if err != nil {
return
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
Expand Down

0 comments on commit 8f15d82

Please sign in to comment.