Skip to content

Commit

Permalink
chore: remove x package (runatlantis#3085)
Browse files Browse the repository at this point in the history
  • Loading branch information
krrrr38 authored and ijames-gc committed Feb 13, 2024
1 parent eb0d70c commit 472ed02
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ require (
github.com/xanzy/go-gitlab v0.79.1
go.etcd.io/bbolt v1.3.7
go.uber.org/zap v1.24.0
golang.org/x/exp v0.0.0-20230131013936-aae9b4e6329d
golang.org/x/term v0.4.0
golang.org/x/text v0.6.0
gopkg.in/yaml.v2 v2.4.0
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,6 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20230131013936-aae9b4e6329d h1:EdJVZdqCvJN8QvZSbrto8tf354qfT3cfBUPaxdWuOpQ=
golang.org/x/exp v0.0.0-20230131013936-aae9b4e6329d/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
16 changes: 8 additions & 8 deletions server/core/config/valid/global_cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

version "github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/logging"
"golang.org/x/exp/slices"
"github.com/runatlantis/atlantis/server/utils"
)

const MergeableCommandReq = "mergeable"
Expand Down Expand Up @@ -427,22 +427,22 @@ func (g GlobalCfg) ValidateRepoCfg(rCfg RepoCfg, repoID string) error {
}
}
for _, p := range rCfg.Projects {
if p.WorkflowName != nil && !slices.Contains(allowedOverrides, WorkflowKey) {
if p.WorkflowName != nil && !utils.SlicesContains(allowedOverrides, WorkflowKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", WorkflowKey, AllowedOverridesKey, WorkflowKey)
}
if p.ApplyRequirements != nil && !slices.Contains(allowedOverrides, ApplyRequirementsKey) {
if p.ApplyRequirements != nil && !utils.SlicesContains(allowedOverrides, ApplyRequirementsKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", ApplyRequirementsKey, AllowedOverridesKey, ApplyRequirementsKey)
}
if p.PlanRequirements != nil && !slices.Contains(allowedOverrides, PlanRequirementsKey) {
if p.PlanRequirements != nil && !utils.SlicesContains(allowedOverrides, PlanRequirementsKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", PlanRequirementsKey, AllowedOverridesKey, PlanRequirementsKey)
}
if p.ImportRequirements != nil && !slices.Contains(allowedOverrides, ImportRequirementsKey) {
if p.ImportRequirements != nil && !utils.SlicesContains(allowedOverrides, ImportRequirementsKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", ImportRequirementsKey, AllowedOverridesKey, ImportRequirementsKey)
}
if p.DeleteSourceBranchOnMerge != nil && !slices.Contains(allowedOverrides, DeleteSourceBranchOnMergeKey) {
if p.DeleteSourceBranchOnMerge != nil && !utils.SlicesContains(allowedOverrides, DeleteSourceBranchOnMergeKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", DeleteSourceBranchOnMergeKey, AllowedOverridesKey, DeleteSourceBranchOnMergeKey)
}
if p.RepoLocking != nil && !slices.Contains(allowedOverrides, RepoLockingKey) {
if p.RepoLocking != nil && !utils.SlicesContains(allowedOverrides, RepoLockingKey) {
return fmt.Errorf("repo config not allowed to set '%s' key: server-side config needs '%s: [%s]'", RepoLockingKey, AllowedOverridesKey, RepoLockingKey)
}
}
Expand Down Expand Up @@ -493,7 +493,7 @@ func (g GlobalCfg) ValidateRepoCfg(rCfg RepoCfg, repoID string) error {
}
}

if !slices.Contains(allowedWorkflows, name) {
if !utils.SlicesContains(allowedWorkflows, name) {
return fmt.Errorf("workflow '%s' is not allowed for this repo", name)
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/events/comment_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
"github.com/google/shlex"
"github.com/runatlantis/atlantis/server/events/command"
"github.com/runatlantis/atlantis/server/events/models"
"github.com/runatlantis/atlantis/server/utils"
"github.com/spf13/pflag"
"golang.org/x/exp/slices"
)

const (
Expand Down Expand Up @@ -324,7 +324,7 @@ func (e *CommentParser) parseArgs(name command.Name, args []string, flagSet *pfl
return "", nil, e.errMarkdown("subcommand required", name.String(), flagSet)
}
subCommand, commandArgs = commandArgs[0], commandArgs[1:]
isAvailableSubCommand := slices.Contains(availableSubCommands, subCommand)
isAvailableSubCommand := utils.SlicesContains(availableSubCommands, subCommand)
if !isAvailableSubCommand {
errMsg := fmt.Sprintf("invalid subcommand %s (not %s)", subCommand, strings.Join(availableSubCommands, ", "))
return "", nil, e.errMarkdown(errMsg, name.String(), flagSet)
Expand Down
12 changes: 12 additions & 0 deletions server/utils/slices.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package utils

// SlicesContains reports whether v is present in s.
// https://pkg.go.dev/golang.org/x/exp/slices#Contains
func SlicesContains[E comparable](s []E, v E) bool {
for _, vs := range s {
if v == vs {
return true
}
}
return false
}

0 comments on commit 472ed02

Please sign in to comment.