mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00: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:
@ -529,8 +529,9 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
|
||||
// We always want to run the replica manager even if we don't have DERP
|
||||
// enabled, since it's used to detect other coder servers for licensing.
|
||||
api.replicaManager, err = replicasync.New(ctx, options.Logger, options.Database, options.Pubsub, &replicasync.Options{
|
||||
ID: api.AGPL.ID,
|
||||
RelayAddress: options.DERPServerRelayAddress,
|
||||
ID: api.AGPL.ID,
|
||||
RelayAddress: options.DERPServerRelayAddress,
|
||||
// #nosec G115 - DERP region IDs are small and fit in int32
|
||||
RegionID: int32(options.DERPServerRegionID),
|
||||
TLSConfig: meshTLSConfig,
|
||||
UpdateInterval: options.ReplicaSyncUpdateInterval,
|
||||
|
@ -61,6 +61,7 @@ func (api *API) postGroupByOrganization(rw http.ResponseWriter, r *http.Request)
|
||||
DisplayName: req.DisplayName,
|
||||
OrganizationID: org.ID,
|
||||
AvatarURL: req.AvatarURL,
|
||||
// #nosec G115 - Quota allowance is small and fits in int32
|
||||
QuotaAllowance: int32(req.QuotaAllowance),
|
||||
})
|
||||
if database.IsUniqueViolation(err) {
|
||||
@ -222,6 +223,7 @@ func (api *API) patchGroup(rw http.ResponseWriter, r *http.Request) {
|
||||
updateGroupParams.Name = req.Name
|
||||
}
|
||||
if req.QuotaAllowance != nil {
|
||||
// #nosec G115 - Quota allowance is small and fits in int32
|
||||
updateGroupParams.QuotaAllowance = int32(*req.QuotaAllowance)
|
||||
}
|
||||
if req.DisplayName != nil {
|
||||
|
@ -32,10 +32,13 @@ func (api *API) postJFrogXrayScan(rw http.ResponseWriter, r *http.Request) {
|
||||
err := api.Database.UpsertJFrogXrayScanByWorkspaceAndAgentID(ctx, database.UpsertJFrogXrayScanByWorkspaceAndAgentIDParams{
|
||||
WorkspaceID: req.WorkspaceID,
|
||||
AgentID: req.AgentID,
|
||||
Critical: int32(req.Critical),
|
||||
High: int32(req.High),
|
||||
Medium: int32(req.Medium),
|
||||
ResultsUrl: req.ResultsURL,
|
||||
// #nosec G115 - Vulnerability counts are small and fit in int32
|
||||
Critical: int32(req.Critical),
|
||||
// #nosec G115 - Vulnerability counts are small and fit in int32
|
||||
High: int32(req.High),
|
||||
// #nosec G115 - Vulnerability counts are small and fit in int32
|
||||
Medium: int32(req.Medium),
|
||||
ResultsUrl: req.ResultsURL,
|
||||
})
|
||||
if httpapi.Is404Error(err) {
|
||||
httpapi.ResourceNotFound(rw)
|
||||
|
@ -389,7 +389,7 @@ func ParseClaimsIgnoreNbf(rawJWT string, keys map[string]ed25519.PublicKey) (*Cl
|
||||
var vErr *jwt.ValidationError
|
||||
if xerrors.As(err, &vErr) {
|
||||
// zero out the NotValidYet error to check if there were other problems
|
||||
vErr.Errors = vErr.Errors & (^jwt.ValidationErrorNotValidYet)
|
||||
vErr.Errors &= (^jwt.ValidationErrorNotValidYet)
|
||||
if vErr.Errors != 0 {
|
||||
// There are other errors besides not being valid yet. We _could_ go
|
||||
// through all the jwt.ValidationError bits and try to work out the
|
||||
|
@ -75,7 +75,7 @@ func (api *API) updateNotificationTemplateMethod(rw http.ResponseWriter, r *http
|
||||
|
||||
err := api.Database.InTx(func(tx database.Store) error {
|
||||
var err error
|
||||
template, err = api.Database.UpdateNotificationTemplateMethodByID(r.Context(), database.UpdateNotificationTemplateMethodByIDParams{
|
||||
template, err = tx.UpdateNotificationTemplateMethodByID(r.Context(), database.UpdateNotificationTemplateMethodByIDParams{
|
||||
ID: template.ID,
|
||||
Method: nm,
|
||||
})
|
||||
|
@ -14,15 +14,15 @@ func NewEnterprisePortSharer() *EnterprisePortSharer {
|
||||
}
|
||||
|
||||
func (EnterprisePortSharer) AuthorizedLevel(template database.Template, level codersdk.WorkspaceAgentPortShareLevel) error {
|
||||
max := codersdk.WorkspaceAgentPortShareLevel(template.MaxPortSharingLevel)
|
||||
maxLevel := codersdk.WorkspaceAgentPortShareLevel(template.MaxPortSharingLevel)
|
||||
switch level {
|
||||
case codersdk.WorkspaceAgentPortShareLevelPublic:
|
||||
if max != codersdk.WorkspaceAgentPortShareLevelPublic {
|
||||
return xerrors.Errorf("port sharing level not allowed. Max level is '%s'", max)
|
||||
if maxLevel != codersdk.WorkspaceAgentPortShareLevelPublic {
|
||||
return xerrors.Errorf("port sharing level not allowed. Max level is '%s'", maxLevel)
|
||||
}
|
||||
case codersdk.WorkspaceAgentPortShareLevelAuthenticated:
|
||||
if max == codersdk.WorkspaceAgentPortShareLevelOwner {
|
||||
return xerrors.Errorf("port sharing level not allowed. Max level is '%s'", max)
|
||||
if maxLevel == codersdk.WorkspaceAgentPortShareLevelOwner {
|
||||
return xerrors.Errorf("port sharing level not allowed. Max level is '%s'", maxLevel)
|
||||
}
|
||||
default:
|
||||
return xerrors.New("port sharing level is invalid.")
|
||||
|
@ -78,6 +78,7 @@ func (*EnterpriseTemplateScheduleStore) Get(ctx context.Context, db database.Sto
|
||||
if tpl.AutostopRequirementWeeks == 0 {
|
||||
tpl.AutostopRequirementWeeks = 1
|
||||
}
|
||||
// #nosec G115 - Safe conversion as we've verified tpl.AutostopRequirementDaysOfWeek is <= 255
|
||||
err = agpl.VerifyTemplateAutostopRequirement(uint8(tpl.AutostopRequirementDaysOfWeek), tpl.AutostopRequirementWeeks)
|
||||
if err != nil {
|
||||
return agpl.TemplateScheduleOptions{}, err
|
||||
@ -89,6 +90,7 @@ func (*EnterpriseTemplateScheduleStore) Get(ctx context.Context, db database.Sto
|
||||
DefaultTTL: time.Duration(tpl.DefaultTTL),
|
||||
ActivityBump: time.Duration(tpl.ActivityBump),
|
||||
AutostopRequirement: agpl.TemplateAutostopRequirement{
|
||||
// #nosec G115 - Safe conversion as we've verified tpl.AutostopRequirementDaysOfWeek is <= 255
|
||||
DaysOfWeek: uint8(tpl.AutostopRequirementDaysOfWeek),
|
||||
Weeks: tpl.AutostopRequirementWeeks,
|
||||
},
|
||||
|
@ -508,13 +508,13 @@ func (api *API) scimPutUser(rw http.ResponseWriter, r *http.Request) {
|
||||
httpapi.Write(ctx, rw, http.StatusOK, sUser)
|
||||
}
|
||||
|
||||
func immutabilityViolation[T comparable](old, new T) bool {
|
||||
func immutabilityViolation[T comparable](old, newVal T) bool {
|
||||
var empty T
|
||||
if new == empty {
|
||||
if newVal == empty {
|
||||
// No change
|
||||
return false
|
||||
}
|
||||
return old != new
|
||||
return old != newVal
|
||||
}
|
||||
|
||||
//nolint:revive // active is not a control flag
|
||||
|
@ -605,6 +605,7 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
|
||||
startingRegionID, _ := getProxyDERPStartingRegionID(api.Options.BaseDERPMap)
|
||||
// #nosec G115 - Safe conversion as DERP region IDs are small integers expected to be within int32 range
|
||||
regionID := int32(startingRegionID) + proxy.RegionID
|
||||
|
||||
err := api.Database.InTx(func(db database.Store) error {
|
||||
@ -625,7 +626,8 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
|
||||
// it if it exists. If it doesn't exist, create it.
|
||||
now := time.Now()
|
||||
replica, err := db.GetReplicaByID(ctx, req.ReplicaID)
|
||||
if err == nil {
|
||||
switch {
|
||||
case err == nil:
|
||||
// Replica exists, update it.
|
||||
if replica.StoppedAt.Valid && !replica.StartedAt.IsZero() {
|
||||
// If the replica deregistered, it shouldn't be able to
|
||||
@ -650,7 +652,7 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("update replica: %w", err)
|
||||
}
|
||||
} else if xerrors.Is(err, sql.ErrNoRows) {
|
||||
case xerrors.Is(err, sql.ErrNoRows):
|
||||
// Replica doesn't exist, create it.
|
||||
replica, err = db.InsertReplica(ctx, database.InsertReplicaParams{
|
||||
ID: req.ReplicaID,
|
||||
@ -667,7 +669,7 @@ func (api *API) workspaceProxyRegister(rw http.ResponseWriter, r *http.Request)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert replica: %w", err)
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
return xerrors.Errorf("get replica: %w", err)
|
||||
}
|
||||
|
||||
|
@ -113,9 +113,11 @@ func (c *committer) CommitQuota(
|
||||
}
|
||||
|
||||
return &proto.CommitQuotaResponse{
|
||||
Ok: permit,
|
||||
Ok: permit,
|
||||
// #nosec G115 - Safe conversion as quota credits consumed value is expected to be within int32 range
|
||||
CreditsConsumed: int32(consumed),
|
||||
Budget: int32(budget),
|
||||
// #nosec G115 - Safe conversion as quota budget value is expected to be within int32 range
|
||||
Budget: int32(budget),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user