Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "enable lint (#327)" #329

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .golangci.yml

This file was deleted.

44 changes: 0 additions & 44 deletions .pipelines/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,47 +63,3 @@ jobs:

- publish: $(System.DefaultWorkingDirectory)/manifest
artifact: manifest

- job: Lint
displayName: 'Lint'

pool:
vmImage: 'ubuntu-latest'

variables:
- group: moc-build
- name: GO111MODULE
value: 'on'

steps:
- task: GoTool@0
inputs:
version: '1.22.5'

- task: InstallSSHKey@0
inputs:
knownHostsEntry: |
$(KNOWN_HOST_GITHUB)
$(KNOWN_HOST_GITHUB_ECDSA)
$(KNOWN_HOST_GITHUB_Ed25519)
sshPublicKey: '$(SSH_PUBLIC_KEY)'
sshKeySecureFile: 'azure-pipelines-ssh-key-new'

- task: AzureCLI@2
inputs:
azureSubscription: 'kva-azuredevops-gcm'
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: |
# Obtain Azure DevOps access token
aadToken=$(az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv)

# Set git configuration for authentication
git config --global http.extraheader "AUTHORIZATION: bearer $aadToken"
git config --global url."ssh://[email protected]/".insteadOf "https://github.com/"
displayName: 'Set git config'

- script: |
make golangci-lint
displayName: 'Run GolangCI-Lint'
workingDirectory: '$(System.DefaultWorkingDirectory)'
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ GOBUILD=$(GOCMD) build -v #-mod=vendor
GOTEST=$(GOCMD) test -v
GOHOSTOS=$(strip $(shell $(GOCMD) env get GOHOSTOS))
MOCKGEN=$(shell command -v mockgen 2> /dev/null)
GOPATH_BIN := $(shell go env GOPATH)/bin

# Private repo workaround
export GOPRIVATE = github.com/microsoft
Expand Down Expand Up @@ -52,7 +51,3 @@ mocks:
go get github.com/golang/[email protected]
go generate ./...

golangci-lint:
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(GOPATH_BIN)/golangci-lint run --config .golangci.yml

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/microsoft/moc

go 1.22.4
go 1.22

require (
github.com/golang-jwt/jwt v3.2.2+incompatible
Expand Down
13 changes: 6 additions & 7 deletions pkg/auth/auth_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ func GetWssdConfigLocation() string {
// Create the default config path and set the
// env variable
defaultPath = filepath.Join(wd, DefaultWSSDFolder)
os.Setenv(AccessFileDirPath, defaultPath) //nolint:golint,errcheck
os.Setenv(AccessFileDirPath, defaultPath)
}

if execName, err := getExecutableName(); err == nil {
defaultPath = filepath.Join(defaultPath, execName)
}
// needs to be fixed later since a large number of repos use this
os.MkdirAll(defaultPath, os.ModePerm) //nolint:golint,errcheck
os.MkdirAll(defaultPath, os.ModePerm)
accessFilePath := filepath.Join(defaultPath, AccessFileDefaultName)
return accessFilePath
}
Expand All @@ -109,9 +108,9 @@ func GetMocConfigLocationName(subfolder, filename string) string {
// Create the default config path and set the
// env variable
defaultPath := filepath.Join(wd, DefaultWSSDFolder, subfolder)
os.MkdirAll(defaultPath, os.ModePerm) //nolint:golint,errcheck
os.MkdirAll(defaultPath, os.ModePerm)
wssdConfigPath = filepath.Join(defaultPath, file)
os.Setenv(WssdConfigPath, wssdConfigPath) //nolint:golint,errcheck
os.Setenv(WssdConfigPath, wssdConfigPath)
}
return wssdConfigPath
}
Expand All @@ -127,9 +126,9 @@ func getClientTokenLocation() string {
// Create the default token path and set the
// env variable
defaultPath := filepath.Join(wd, DefaultWSSDFolder)
os.MkdirAll(defaultPath, os.ModePerm) //nolint:golint,errcheck
os.MkdirAll(defaultPath, os.ModePerm)
clientTokenPath = filepath.Join(defaultPath, ClientTokenName)
os.Setenv(ClientTokenPath, clientTokenPath) //nolint:golint,errcheck
os.Setenv(ClientTokenPath, clientTokenPath)
}
return clientTokenPath
}
3 changes: 0 additions & 3 deletions pkg/auth/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func GenerateClientCsr(loginconfig LoginConfig) (string, WssdConfig, error) {
return "", WssdConfig{}, err
}
accessFile, err := readAccessFile(GetWssdConfigLocation())
if err != nil {
return "", WssdConfig{}, err
}
cloudAgentIpAddress, err := wssdnet.GetIPAddress()
if err != nil {
return "", WssdConfig{}, err
Expand Down
7 changes: 1 addition & 6 deletions pkg/certs/certificateAuthority.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ func (ca *CertificateAuthority) SignRequest(csrPem []byte, oldCertPem []byte, co
return nil, errors.Wrapf(errors.InvalidInput, "Old certificate verification failed : %v", err)
}
oldCert, err = DecodeCertPEM(oldCertPem)
if err != nil {
return
}
}
err = csr.CheckSignature()
if err != nil {
Expand Down Expand Up @@ -305,9 +302,7 @@ func (ca *CertificateAuthority) SignRequest(csrPem []byte, oldCertPem []byte, co
if ext.Id.Equal(oidOriginalCertificate) {
origCertDER = ext.Value
} else if ext.Id.Equal(oidRenewCount) {
if _, err := asn1.Unmarshal(ext.Value, &renewCount); err != nil {
return nil, errors.Wrapf(err, "Failed to unmarshall renew count")
}
asn1.Unmarshal(ext.Value, &renewCount)
}
}

Expand Down
4 changes: 1 addition & 3 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,7 @@ func MarshalOutput(data interface{}, query string, outputType string) ([]byte, e
if err != nil {
return nil, err
}
if err := marshal.FromJSONBytes(jsonByte, &queryTarget); err != nil {
return nil, err
}
marshal.FromJSONBytes(jsonByte, &queryTarget)
if query != "" {
result, err = jmespath.Search(query, queryTarget)
if err != nil {
Expand Down
8 changes: 2 additions & 6 deletions pkg/logging/loggingRedirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ var (

func createLogFile(logFileAbsolutePath string, logFileName string) (*os.File, error) {
// Create log path
if err := os.MkdirAll(logFileAbsolutePath, os.ModeDir); err != nil {
return nil, err
}
os.MkdirAll(logFileAbsolutePath, os.ModeDir)

err := path.CheckPath(logFileAbsolutePath)
if err != nil {
Expand All @@ -42,9 +40,7 @@ func createLogFile(logFileAbsolutePath string, logFileName string) (*os.File, er
// If there are contents in the file already, move the file and replace it.
if st.Size() > 0 {
logFile.Close()
if err := os.Rename(path, path+".old"); err != nil {
return nil, err
}
os.Rename(path, path+".old")
logFile, err = os.Create(path)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion pkg/logging/redirectstderr_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

func RedirectStdErr(file *os.File) {
err := syscall.Dup3(int(file.Fd()), int(os.Stderr.Fd()), 0)
if err != nil { //nolint:golint,staticcheck
if err != nil {
}
return
}
10 changes: 5 additions & 5 deletions pkg/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,27 @@ func GetFromStatuses(statuses map[string]*string) (status *common.Status) {
status = &common.Status{}
if val, ok := statuses["ProvisionState"]; ok {
ps := new(common.ProvisionStatus)
proto.UnmarshalText(*val, ps) //nolint:golint,errcheck
proto.UnmarshalText(*val, ps)
status.ProvisioningStatus = ps
}
if val, ok := statuses["HealthState"]; ok {
ps := new(common.Health)
proto.UnmarshalText(*val, ps) //nolint:golint,errcheck
proto.UnmarshalText(*val, ps)
status.Health = ps
}
if val, ok := statuses["Error"]; ok {
ps := new(common.Error)
proto.UnmarshalText(*val, ps) //nolint:golint,errcheck
proto.UnmarshalText(*val, ps)
status.LastError = ps
}
if val, ok := statuses["DownloadStatus"]; ok {
ps := new(common.DownloadStatus)
proto.UnmarshalText(*val, ps) //nolint:golint,errcheck
proto.UnmarshalText(*val, ps)
status.DownloadStatus = ps
}
if val, ok := statuses["PlacementStatus"]; ok {
ps := new(common.PlacementStatus)
proto.UnmarshalText(*val, ps) //nolint:golint,errcheck
proto.UnmarshalText(*val, ps)
status.PlacementStatus = ps
}
if val, ok := statuses["UploadStatus"]; ok {
Expand Down
4 changes: 2 additions & 2 deletions pkg/validations/proxy_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func ValidateProxyURL(proxyURL string) (*url.URL, error) {
parsedURL, err := url.ParseRequestURI(proxyURL)

if err != nil {
return nil, errors.Wrapf(errors.InvalidInput, "%s", err.Error())
return nil, errors.Wrapf(errors.InvalidInput, err.Error())
}

// Check if url scheme is http or https
Expand Down Expand Up @@ -54,7 +54,7 @@ func TestProxyUrlConnection(parsedURL *url.URL, certContent string, getRequestUr
// Test the HTTP GET request
response, err := client.Get(getRequestUrl)
if err != nil {
return errors.Wrapf(errors.InvalidInput, "%s", err.Error())
return errors.Wrapf(errors.InvalidInput, err.Error())
} else {
defer response.Body.Close()
fmt.Println("Connected successfully to the proxy server")
Expand Down
Loading