Skip to content

Commit

Permalink
Merge pull request runatlantis#78 from hootsuite/dyanmono
Browse files Browse the repository at this point in the history
Delete dynamodb locking code since Atlantis only works with disk righ…
  • Loading branch information
lkysow authored Jul 18, 2017
2 parents dc87ccc + 99a0f0c commit 5ece13a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 319 deletions.
15 changes: 0 additions & 15 deletions cmd/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const (
ghHostnameFlag = "gh-hostname"
ghPasswordFlag = "gh-password"
ghUserFlag = "gh-user"
lockingBackendFlag = "locking-backend"
lockingTableFlag = "locking-dynamodb-table"
logLevelFlag = "log-level"
portFlag = "port"
requireApprovalFlag = "require-approval"
Expand Down Expand Up @@ -70,16 +68,6 @@ var stringFlags = []stringFlag{
description: "GitHub username of API user. Can also be specified via the ATLANTIS_GH_USER environment variable.",
env: "ATLANTIS_GH_USER",
},
{
name: lockingBackendFlag,
description: "Which backend to use for locking. file or dynamodb.",
value: "file",
},
{
name: lockingTableFlag,
description: "Name of table in DynamoDB to use for locking. Only read if " + lockingBackendFlag + " is set to dynamodb.",
value: "atlantis-locks",
},
{
name: logLevelFlag,
description: "Log level. Either debug, info, warn, or error.",
Expand Down Expand Up @@ -196,9 +184,6 @@ func validate(config server.ServerConfig) error {
if config.GithubPassword == "" {
return fmt.Errorf("--%s must be set", ghPasswordFlag)
}
if config.LockingBackend != server.LockingFileBackend && config.LockingBackend != server.LockingDynamoDBBackend {
return fmt.Errorf("unsupported locking backend %q: not one of %q or %q", config.LockingBackend, server.LockingFileBackend, server.LockingDynamoDBBackend)
}
return nil
}

Expand Down
273 changes: 0 additions & 273 deletions locking/dynamodb/dynamodb.go

This file was deleted.

46 changes: 15 additions & 31 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ import (
"strings"
"time"

"github.com/aws/aws-sdk-go/aws/session"
"github.com/elazarl/go-bindata-assetfs"
gh "github.com/google/go-github/github"
"github.com/gorilla/mux"
"github.com/hootsuite/atlantis/aws"
"github.com/hootsuite/atlantis/github"
"github.com/hootsuite/atlantis/locking"
"github.com/hootsuite/atlantis/locking/boltdb"
"github.com/hootsuite/atlantis/locking/dynamodb"
"github.com/hootsuite/atlantis/logging"
"github.com/hootsuite/atlantis/models"
"github.com/hootsuite/atlantis/prerun"
Expand All @@ -30,9 +28,7 @@ import (
)

const (
lockRoute = "lock-detail"
LockingFileBackend = "file"
LockingDynamoDBBackend = "dynamodb"
lockRoute = "lock-detail"
)

// Server listens for GitHub events and runs the necessary Atlantis command
Expand All @@ -49,18 +45,16 @@ type Server struct {

// the mapstructure tags correspond to flags in cmd/server.go
type ServerConfig struct {
AWSRegion string `mapstructure:"aws-region"`
AssumeRole string `mapstructure:"aws-assume-role-arn"`
AtlantisURL string `mapstructure:"atlantis-url"`
DataDir string `mapstructure:"data-dir"`
GithubHostname string `mapstructure:"gh-hostname"`
GithubPassword string `mapstructure:"gh-password"`
GithubUser string `mapstructure:"gh-user"`
LockingBackend string `mapstructure:"locking-backend"`
LockingDynamoDBTable string `mapstructure:"locking-dynamodb-table"`
LogLevel string `mapstructure:"log-level"`
Port int `mapstructure:"port"`
RequireApproval bool `mapstructure:"require-approval"`
AWSRegion string `mapstructure:"aws-region"`
AssumeRole string `mapstructure:"aws-assume-role-arn"`
AtlantisURL string `mapstructure:"atlantis-url"`
DataDir string `mapstructure:"data-dir"`
GithubHostname string `mapstructure:"gh-hostname"`
GithubPassword string `mapstructure:"gh-password"`
GithubUser string `mapstructure:"gh-user"`
LogLevel string `mapstructure:"log-level"`
Port int `mapstructure:"port"`
RequireApproval bool `mapstructure:"require-approval"`
}

type CommandContext struct {
Expand Down Expand Up @@ -98,21 +92,11 @@ func NewServer(config ServerConfig) (*Server, error) {
RoleARN: config.AssumeRole,
}

var awsSession *session.Session
var lockingClient *locking.Client
if config.LockingBackend == LockingDynamoDBBackend {
awsSession, err = awsConfig.CreateSession()
if err != nil {
return nil, errors.Wrap(err, "creating aws session for DynamoDB")
}
lockingClient = locking.NewClient(dynamodb.New(config.LockingDynamoDBTable, awsSession))
} else {
backend, err := boltdb.New(config.DataDir)
if err != nil {
return nil, err
}
lockingClient = locking.NewClient(backend)
boltdb, err := boltdb.New(config.DataDir)
if err != nil {
return nil, err
}
lockingClient := locking.NewClient(boltdb)
preRun := &prerun.PreRun{}
configReader := &ConfigReader{}
concurrentRunLocker := NewConcurrentRunLocker()
Expand Down

0 comments on commit 5ece13a

Please sign in to comment.