Skip to content

Commit

Permalink
ci(develop) fix golint for code and lic (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
cuisongliu authored Dec 8, 2021
1 parent 394a895 commit 5bfc7f0
Show file tree
Hide file tree
Showing 100 changed files with 2,450 additions and 1,931 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ env.GO_VERSION }}
- name: Run Check License
run:
run: |
wget https://github.com/google/addlicense/releases/download/v1.0.0/addlicense_1.0.0_Linux_x86_64.tar.gz
tar -zxvf addlicense_1.0.0_Linux_x86_64.tar.gz -C $(go env GOPATH)/bin
chmod a+x $(go env GOPATH)/bin/addlicense
Expand Down
15 changes: 8 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ run:
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
skip-dirs-use-default: true

modules-download-mode: vendor

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
Expand Down Expand Up @@ -39,11 +37,14 @@ linters:
- ifshort
- unconvert

issues:
exclude-rules:
- linters:
- golint
text: "AccessKeyId"
linters-settings:
errcheck:
check-type-assertions: false
ignore: fmt:.*,io/ioutil:^Read.*
exclude-functions:
- io/ioutil.ReadFile
- io.Copy(*bytes.Buffer)
- io.Copy(os.Stdout)

# golangci.com configuration
# https://github.com/golangci/golangci/wiki/Configuration
Expand Down
16 changes: 0 additions & 16 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
<!--
// Copyright © 2019 NAME HERE <EMAIL ADDRESS>
//
// Licensed 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.
-->

# Table of Contents

- [3.3.9-rc.6](#671)
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ To put forward a PR, we assume you have registered a GitHub ID. Then you could f

1. **FORK** sealos to your repository. To make this work, you just need to click the button Fork in right-left of [fanux/sealos](https://github.com/fanux/sealos) main page. Then you will end up with your repository in `https://github.com/<your-username>/sealos`, in which `your-username` is your GitHub username.

1. **CLONE** your own repository to develop locally. Use `git clone https://github.com/<your-username>/sealos.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.
1. **CLONE** your own repository to master locally. Use `git clone https://github.com/<your-username>/sealos.git` to clone repository to your local machine. Then you can create new branches to finish the change you wish to make.

1. **Set Remote** upstream to be `https://github.com/fanux/sealos.git` using the following two commands:

Expand Down Expand Up @@ -120,11 +120,11 @@ To put forward a PR, we assume you have registered a GitHub ID. Then you could f
git push // push to your forked repository after rebase done
```

1. **File a pull request** to fanux/sealos:develop
1. **File a pull request** to fanux/sealos:master

### Branch Definition

Right now we assume every contribution via pull request is for [branch develop](https://github.com/fanux/sealos/tree/develop) in sealos. Before contributing, be aware of branch definition would help a lot.
Right now we assume every contribution via pull request is for [branch master](https://github.com/fanux/sealos/tree/master) in sealos. Before contributing, be aware of branch definition would help a lot.

As a contributor, keep in mind again that every contribution via pull request is for branch master. While in project sealos, there are several other branches, we generally call them rc branches, release branches and backport branches.

Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ filelicense: SHELL:=/bin/bash
filelicense: ## add license
for file in ${Dirs} ; do \
if [[ $$file != '_output' && $$file != 'docs' && $$file != 'vendor' && $$file != 'logger' && $$file != 'applications' ]]; then \
$(ADDLICENSE_BIN) -y $(shell date +"%Y") -c "Alibaba Group Holding Ltd." -f hack/template/LICENSE ./$$file ; \
$(ADDLICENSE_BIN) -y $(shell date +"%Y") -c "sealos." -f hack/template/LICENSE ./$$file ; \
fi \
done

install-ossutil: ## check ossutil if not exist install ossutil tools
ifeq (, $(shell which ossutil))
@{ \
set -e ;\
go install github.com/aliyun/ossutil@latest ;\
curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sh -s -- -b $(GOBIN) v2.2.0 ;\
}
OSSUTIL_BIN=$(GOBIN)/ossutil
else
Expand Down
14 changes: 14 additions & 0 deletions cert/cert.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright © 2021 sealos.
//
// Licensed 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.

package cert

import (
Expand Down
18 changes: 16 additions & 2 deletions cert/cert_cmd.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
// Copyright © 2021 sealos.
//
// Licensed 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.

package cert

import (
"fmt"
"os"

"github.com/wonderivan/logger"
"github.com/fanux/sealos/pkg/logger"
)

// CMD return sealos cert command
Expand Down Expand Up @@ -42,5 +56,5 @@ func GenerateCert(certPATH, certEtcdPATH string, altNames []string, hostIP, host
logger.Error("generator cert config failed %s", err)
os.Exit(-1)
}
certConfig.GenerateAll()
_ = certConfig.GenerateAll()
}
29 changes: 21 additions & 8 deletions cert/kube_certs.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright © 2021 sealos.
//
// Licensed 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.

package cert

import (
Expand All @@ -8,7 +22,7 @@ import (
"os"
"path"

"github.com/wonderivan/logger"
"github.com/fanux/sealos/pkg/logger"
)

var (
Expand Down Expand Up @@ -62,7 +76,7 @@ func CaList(CertPath, CertEtcdPath string) []Config {
}
}

func CertList(CertPath, CertEtcdPath string) []Config {
func List(CertPath, CertEtcdPath string) []Config {
return []Config{
{
Path: CertPath,
Expand Down Expand Up @@ -198,8 +212,7 @@ func NewSealosCertMetaData(certPATH, certEtcdPATH string, apiServerIPAndDomains
}
data.APIServer.DNSNames[altName] = altName
}
ip := net.ParseIP(nodeIP)
if ip != nil {
if ip := net.ParseIP(nodeIP); ip != nil {
data.APIServer.IPs[ip.String()] = ip
}

Expand All @@ -213,8 +226,8 @@ func (meta *SealosCertMetaData) apiServerAltName(certList *[]Config) {
(*certList)[APIserverCert].AltNames.DNSNames[dns] = dns
}

svcDns := fmt.Sprintf("kubernetes.default.svc.%s", meta.DNSDomain)
(*certList)[APIserverCert].AltNames.DNSNames[svcDns] = svcDns
svcDNS := fmt.Sprintf("kubernetes.default.svc.%s", meta.DNSDomain)
(*certList)[APIserverCert].AltNames.DNSNames[svcDNS] = svcDNS
(*certList)[APIserverCert].AltNames.DNSNames[meta.NodeName] = meta.NodeName

for _, ip := range meta.APIServer.IPs {
Expand Down Expand Up @@ -268,10 +281,10 @@ func (meta *SealosCertMetaData) generatorServiceAccountKeyPaire() error {

func (meta *SealosCertMetaData) GenerateAll() error {
cas := CaList(meta.CertPath, meta.CertEtcdPath)
certs := CertList(meta.CertPath, meta.CertEtcdPath)
certs := List(meta.CertPath, meta.CertEtcdPath)
meta.apiServerAltName(&certs)
meta.etcdAltAndCommonName(&certs)
meta.generatorServiceAccountKeyPaire()
_ = meta.generatorServiceAccountKeyPaire()

CACerts := map[string]*x509.Certificate{}
CAKeys := map[string]crypto.Signer{}
Expand Down
14 changes: 14 additions & 0 deletions cert/kube_certs_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright © 2021 sealos.
//
// Licensed 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.

package cert

import (
Expand Down
Loading

0 comments on commit 5bfc7f0

Please sign in to comment.