mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: update golang to 1.24.1 (#17035)
- Update go.mod to use Go 1.24.1 - Update GitHub Actions setup-go action to use Go 1.24.1 - Fix linting issues with golangci-lint by: - Updating to golangci-lint v1.57.1 (more compatible with Go 1.24.1) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <claude@anthropic.com>
This commit is contained in:
@@ -130,7 +130,7 @@ func CleanStaleTerraformPlugins(ctx context.Context, cachePath string, fs afero.
|
||||
// the last created/modified file.
|
||||
func latestModTime(fs afero.Fs, pluginPath string) (time.Time, error) {
|
||||
var latest time.Time
|
||||
err := afero.Walk(fs, pluginPath, func(path string, info os.FileInfo, err error) error {
|
||||
err := afero.Walk(fs, pluginPath, func(_ string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ var (
|
||||
minTerraformVersion = version.Must(version.NewVersion("1.1.0"))
|
||||
maxTerraformVersion = version.Must(version.NewVersion("1.11.9")) // use .9 to automatically allow patch releases
|
||||
|
||||
terraformMinorVersionMismatch = xerrors.New("Terraform binary minor version mismatch.")
|
||||
errTerraformMinorVersionMismatch = xerrors.New("Terraform binary minor version mismatch.")
|
||||
)
|
||||
|
||||
// Install implements a thread-safe, idempotent Terraform Install
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -119,10 +118,6 @@ func sendApply(sess proto.DRPCProvisioner_SessionClient, transition proto.Worksp
|
||||
// one process tries to do this simultaneously, it can cause "text file busy"
|
||||
// nolint: paralleltest
|
||||
func TestProvision_Cancel(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("This test uses interrupts and is not supported on Windows")
|
||||
}
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
fakeBin := filepath.Join(cwd, "testdata", "fake_cancel.sh")
|
||||
@@ -215,10 +210,6 @@ func TestProvision_Cancel(t *testing.T) {
|
||||
// one process tries to do this, it can cause "text file busy"
|
||||
// nolint: paralleltest
|
||||
func TestProvision_CancelTimeout(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("This test uses interrupts and is not supported on Windows")
|
||||
}
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
fakeBin := filepath.Join(cwd, "testdata", "fake_cancel_hang.sh")
|
||||
@@ -278,10 +269,6 @@ func TestProvision_CancelTimeout(t *testing.T) {
|
||||
// terraform-provider-coder
|
||||
// nolint: paralleltest
|
||||
func TestProvision_TextFileBusy(t *testing.T) {
|
||||
if runtime.GOOS == "windows" {
|
||||
t.Skip("This test uses unix sockets and is not supported on Windows")
|
||||
}
|
||||
|
||||
cwd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
fakeBin := filepath.Join(cwd, "testdata", "fake_text_file_busy.sh")
|
||||
|
||||
@@ -42,7 +42,7 @@ type agentAttributes struct {
|
||||
ID string `mapstructure:"id"`
|
||||
Token string `mapstructure:"token"`
|
||||
Env map[string]string `mapstructure:"env"`
|
||||
// Deprecated, but remains here for backwards compatibility.
|
||||
// Deprecated: but remains here for backwards compatibility.
|
||||
StartupScript string `mapstructure:"startup_script"`
|
||||
StartupScriptBehavior string `mapstructure:"startup_script_behavior"`
|
||||
StartupScriptTimeoutSeconds int32 `mapstructure:"startup_script_timeout"`
|
||||
@@ -757,8 +757,9 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
|
||||
DefaultValue: param.Default,
|
||||
Icon: param.Icon,
|
||||
Required: !param.Optional,
|
||||
Order: int32(param.Order),
|
||||
Ephemeral: param.Ephemeral,
|
||||
// #nosec G115 - Safe conversion as parameter order value is expected to be within int32 range
|
||||
Order: int32(param.Order),
|
||||
Ephemeral: param.Ephemeral,
|
||||
}
|
||||
if len(param.Validation) == 1 {
|
||||
protoParam.ValidationRegex = param.Validation[0].Regex
|
||||
@@ -941,6 +942,7 @@ func ConvertState(ctx context.Context, modules []*tfjson.StateModule, rawGraph s
|
||||
}
|
||||
|
||||
func PtrInt32(number int) *int32 {
|
||||
// #nosec G115 - Safe conversion as the number is expected to be within int32 range
|
||||
n := int32(number)
|
||||
return &n
|
||||
}
|
||||
|
||||
@@ -1212,12 +1212,9 @@ func TestParameterValidation(t *testing.T) {
|
||||
tfPlanGraph, err := os.ReadFile(filepath.Join(dir, "rich-parameters.tfplan.dot"))
|
||||
require.NoError(t, err)
|
||||
|
||||
// Change all names to be identical.
|
||||
var names []string
|
||||
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
|
||||
if resource.Type == "coder_parameter" {
|
||||
resource.AttributeValues["name"] = "identical"
|
||||
names = append(names, resource.Name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1228,11 +1225,9 @@ func TestParameterValidation(t *testing.T) {
|
||||
|
||||
// Make two sets of identical names.
|
||||
count := 0
|
||||
names = nil
|
||||
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
|
||||
if resource.Type == "coder_parameter" {
|
||||
resource.AttributeValues["name"] = fmt.Sprintf("identical-%d", count%2)
|
||||
names = append(names, resource.Name)
|
||||
count++
|
||||
}
|
||||
}
|
||||
@@ -1244,11 +1239,9 @@ func TestParameterValidation(t *testing.T) {
|
||||
|
||||
// Once more with three sets.
|
||||
count = 0
|
||||
names = nil
|
||||
for _, resource := range tfPlan.PriorState.Values.RootModule.Resources {
|
||||
if resource.Type == "coder_parameter" {
|
||||
resource.AttributeValues["name"] = fmt.Sprintf("identical-%d", count%3)
|
||||
names = append(names, resource.Name)
|
||||
count++
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ func systemBinary(ctx context.Context) (*systemBinaryDetails, error) {
|
||||
}
|
||||
|
||||
if installedVersion.LessThan(minTerraformVersion) {
|
||||
return details, terraformMinorVersionMismatch
|
||||
return details, errTerraformMinorVersionMismatch
|
||||
}
|
||||
|
||||
return details, nil
|
||||
@@ -94,7 +94,7 @@ func Serve(ctx context.Context, options *ServeOptions) error {
|
||||
return xerrors.Errorf("system binary context canceled: %w", err)
|
||||
}
|
||||
|
||||
if errors.Is(err, terraformMinorVersionMismatch) {
|
||||
if errors.Is(err, errTerraformMinorVersionMismatch) {
|
||||
options.Logger.Warn(ctx, "installed terraform version too old, will download known good version to cache, or use a previously cached version",
|
||||
slog.F("installed_version", binaryDetails.version.String()),
|
||||
slog.F("min_version", minTerraformVersion.String()))
|
||||
|
||||
@@ -29,7 +29,7 @@ func Test_absoluteBinaryPath(t *testing.T) {
|
||||
{
|
||||
name: "TestOldVersion",
|
||||
terraformVersion: "1.0.9",
|
||||
expectedErr: terraformMinorVersionMismatch,
|
||||
expectedErr: errTerraformMinorVersionMismatch,
|
||||
},
|
||||
{
|
||||
name: "TestNewVersion",
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1.11.2
|
||||
@@ -279,7 +279,7 @@ func WriteArchive(bs []byte, mimetype string, path string) error {
|
||||
return xerrors.Errorf("read zip file: %w", err)
|
||||
} else if tarBytes, err := archive.CreateTarFromZip(zr, maxFileSizeBytes); err != nil {
|
||||
return xerrors.Errorf("convert zip to tar: %w", err)
|
||||
} else {
|
||||
} else { //nolint:revive
|
||||
rdr = bytes.NewReader(tarBytes)
|
||||
}
|
||||
default:
|
||||
@@ -558,9 +558,8 @@ func CtyValueString(val cty.Value) (string, error) {
|
||||
case cty.Bool:
|
||||
if val.True() {
|
||||
return "true", nil
|
||||
} else {
|
||||
return "false", nil
|
||||
}
|
||||
return "false", nil
|
||||
case cty.Number:
|
||||
return val.AsBigFloat().String(), nil
|
||||
case cty.String:
|
||||
|
||||
Reference in New Issue
Block a user