mirror of
https://github.com/opentofu/opentofu.git
synced 2025-12-18 15:46:08 -05:00
Fix linting on Windows (#3457)
Some checks are pending
build / Build for freebsd_386 (push) Waiting to run
build / Build for linux_386 (push) Waiting to run
build / Build for openbsd_386 (push) Waiting to run
build / Build for windows_386 (push) Waiting to run
build / Build for freebsd_amd64 (push) Waiting to run
build / Build for linux_amd64 (push) Waiting to run
build / Build for openbsd_amd64 (push) Waiting to run
build / Build for solaris_amd64 (push) Waiting to run
build / Build for windows_amd64 (push) Waiting to run
build / Build for freebsd_arm (push) Waiting to run
build / Build for linux_arm (push) Waiting to run
build / Build for linux_arm64 (push) Waiting to run
build / Build for darwin_amd64 (push) Waiting to run
build / Build for darwin_arm64 (push) Waiting to run
build / End-to-end Tests for linux_386 (push) Waiting to run
build / End-to-end Tests for windows_386 (push) Waiting to run
build / End-to-end Tests for darwin_amd64 (push) Waiting to run
build / End-to-end Tests for linux_amd64 (push) Waiting to run
build / End-to-end Tests for windows_amd64 (push) Waiting to run
Quick Checks / List files changed for pull request (push) Waiting to run
Quick Checks / Unit tests for linux_386 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for windows_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm (push) Blocked by required conditions
Quick Checks / Unit tests for darwin_arm64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm64 (push) Blocked by required conditions
Quick Checks / Race Tests (push) Blocked by required conditions
Quick Checks / End-to-end Tests (push) Blocked by required conditions
Quick Checks / Code Consistency Checks (push) Blocked by required conditions
Quick Checks / License Checks (push) Waiting to run
Website checks / List files changed for pull request (push) Waiting to run
Website checks / Build (push) Blocked by required conditions
Website checks / Test Installation Instructions (push) Blocked by required conditions
Some checks are pending
build / Build for freebsd_386 (push) Waiting to run
build / Build for linux_386 (push) Waiting to run
build / Build for openbsd_386 (push) Waiting to run
build / Build for windows_386 (push) Waiting to run
build / Build for freebsd_amd64 (push) Waiting to run
build / Build for linux_amd64 (push) Waiting to run
build / Build for openbsd_amd64 (push) Waiting to run
build / Build for solaris_amd64 (push) Waiting to run
build / Build for windows_amd64 (push) Waiting to run
build / Build for freebsd_arm (push) Waiting to run
build / Build for linux_arm (push) Waiting to run
build / Build for linux_arm64 (push) Waiting to run
build / Build for darwin_amd64 (push) Waiting to run
build / Build for darwin_arm64 (push) Waiting to run
build / End-to-end Tests for linux_386 (push) Waiting to run
build / End-to-end Tests for windows_386 (push) Waiting to run
build / End-to-end Tests for darwin_amd64 (push) Waiting to run
build / End-to-end Tests for linux_amd64 (push) Waiting to run
build / End-to-end Tests for windows_amd64 (push) Waiting to run
Quick Checks / List files changed for pull request (push) Waiting to run
Quick Checks / Unit tests for linux_386 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for windows_amd64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm (push) Blocked by required conditions
Quick Checks / Unit tests for darwin_arm64 (push) Blocked by required conditions
Quick Checks / Unit tests for linux_arm64 (push) Blocked by required conditions
Quick Checks / Race Tests (push) Blocked by required conditions
Quick Checks / End-to-end Tests (push) Blocked by required conditions
Quick Checks / Code Consistency Checks (push) Blocked by required conditions
Quick Checks / License Checks (push) Waiting to run
Website checks / List files changed for pull request (push) Waiting to run
Website checks / Build (push) Blocked by required conditions
Website checks / Test Installation Instructions (push) Blocked by required conditions
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com> Signed-off-by: Diógenes Fernandes <diofeher@gmail.com> Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
parent
ffc9c4d556
commit
530e5c4538
6 changed files with 24 additions and 19 deletions
6
.github/workflows/checks.yml
vendored
6
.github/workflows/checks.yml
vendored
|
|
@ -38,13 +38,13 @@ jobs:
|
|||
steps:
|
||||
- name: "Fetch source code"
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- id: diff
|
||||
- id: diff
|
||||
run: |
|
||||
git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin ${{github.event.pull_request.base.ref}}
|
||||
echo "go=$(git diff --name-only origin/${{github.event.pull_request.base.ref}} | grep -e '\.go' -e '\.github' -e 'go\.mod' -e 'go\.sum' -e '\.tf' -e '\.gitattributes' | wc -l)" | tee -a "$GITHUB_OUTPUT"
|
||||
outputs:
|
||||
go: ${{ steps.diff.outputs.go }}
|
||||
|
||||
|
||||
unit-tests:
|
||||
name: Unit tests for ${{ matrix.goos }}_${{ matrix.goarch }}
|
||||
runs-on: ${{ matrix.runson }}
|
||||
|
|
@ -175,7 +175,7 @@ jobs:
|
|||
# possible for someone who encounters a failure here to replicate
|
||||
# exactly the same run in their local development environment.
|
||||
make golangci-lint
|
||||
|
||||
|
||||
- name: "Copyright headers"
|
||||
run: |
|
||||
go tool github.com/hashicorp/copywrite headers --plan
|
||||
|
|
|
|||
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -23,6 +23,9 @@ website/node_modules
|
|||
website/vendor
|
||||
vendor/
|
||||
|
||||
# "make golangci-lint" places its temprary golangci-lint executable here
|
||||
tools/golangci-lint*
|
||||
|
||||
# VSCode debugging configurations
|
||||
.vscode/launch.json
|
||||
|
||||
|
|
|
|||
6
Makefile
6
Makefile
|
|
@ -46,10 +46,12 @@ generate:
|
|||
protobuf:
|
||||
go run ./tools/protobuf-compile .
|
||||
|
||||
# Golangci-lint
|
||||
# Golangci-lint is installed first and then run twice to cover all platforms.
|
||||
.PHONY: golangci-lint
|
||||
golangci-lint:
|
||||
go run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0 run --timeout 60m ./...
|
||||
GOBIN=$(PWD)/tools go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.6.0
|
||||
GOOS=windows tools/golangci-lint${EXT} run --timeout 60m ./...
|
||||
GOOS=linux tools/golangci-lint${EXT} run --timeout 60m ./...
|
||||
|
||||
# Run license check
|
||||
.PHONY: license-check
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ package flock
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"math"
|
||||
"os"
|
||||
"syscall"
|
||||
|
|
@ -40,7 +41,12 @@ func Lock(f *os.File) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer syscall.CloseHandle(ol.HEvent)
|
||||
defer func() {
|
||||
err := syscall.CloseHandle(ol.HEvent)
|
||||
if err != nil {
|
||||
log.Printf("[ERROR] failed to close file locking event handle: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
return lockFileEx(
|
||||
syscall.Handle(f.Fd()),
|
||||
|
|
@ -96,9 +102,8 @@ func Unlock(*os.File) error {
|
|||
}
|
||||
|
||||
func lockFileEx(h syscall.Handle, flags, reserved, locklow, lockhigh uint32, ol *syscall.Overlapped) (err error) {
|
||||
r1, _, e1 := syscall.Syscall6(
|
||||
r1, _, e1 := syscall.SyscallN(
|
||||
procLockFileEx.Addr(),
|
||||
6,
|
||||
uintptr(h),
|
||||
uintptr(flags),
|
||||
uintptr(reserved),
|
||||
|
|
@ -136,9 +141,8 @@ func createEvent(sa *syscall.SecurityAttributes, manualReset bool, initialState
|
|||
_p1 = 1
|
||||
}
|
||||
|
||||
r0, _, e1 := syscall.Syscall6(
|
||||
r0, _, e1 := syscall.SyscallN(
|
||||
procCreateEventW.Addr(),
|
||||
4,
|
||||
uintptr(unsafe.Pointer(sa)),
|
||||
uintptr(_p0),
|
||||
uintptr(_p1),
|
||||
|
|
|
|||
|
|
@ -29,17 +29,17 @@ func AtomicRename(source, destination string) error {
|
|||
// existing file.
|
||||
srcPtr, err := syscall.UTF16PtrFromString(source)
|
||||
if err != nil {
|
||||
return &os.LinkError{"replace", source, destination, err}
|
||||
return &os.LinkError{Op: "replace", Old: source, New: destination, Err: err}
|
||||
}
|
||||
destPtr, err := syscall.UTF16PtrFromString(destination)
|
||||
if err != nil {
|
||||
return &os.LinkError{"replace", source, destination, err}
|
||||
return &os.LinkError{Op: "replace", Old: source, New: destination, Err: err}
|
||||
}
|
||||
|
||||
flags := uint32(windows.MOVEFILE_REPLACE_EXISTING | windows.MOVEFILE_WRITE_THROUGH)
|
||||
err = windows.MoveFileEx(srcPtr, destPtr, flags)
|
||||
if err != nil {
|
||||
return &os.LinkError{"replace", source, destination, err}
|
||||
return &os.LinkError{Op: "replace", Old: source, New: destination, Err: err}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ const CP_UTF8 = 65001
|
|||
// interface.)
|
||||
|
||||
func SetConsoleCP(codepageID uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetConsoleCP.Addr(), 1, uintptr(codepageID), 0, 0)
|
||||
r1, _, e1 := syscall.SyscallN(procSetConsoleCP.Addr(), uintptr(codepageID), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = e1
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ func SetConsoleCP(codepageID uint32) (err error) {
|
|||
}
|
||||
|
||||
func SetConsoleOutputCP(codepageID uint32) (err error) {
|
||||
r1, _, e1 := syscall.Syscall(procSetConsoleOutputCP.Addr(), 1, uintptr(codepageID), 0, 0)
|
||||
r1, _, e1 := syscall.SyscallN(procSetConsoleOutputCP.Addr(), uintptr(codepageID), 0, 0)
|
||||
if r1 == 0 {
|
||||
err = e1
|
||||
}
|
||||
|
|
@ -160,7 +160,3 @@ func SetConsoleOutputCP(codepageID uint32) (err error) {
|
|||
func staticTrue(f *os.File) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func staticFalse(f *os.File) bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue