remote/s3: there is no ok answer on error

This commit is contained in:
Jakub Janczak 2015-02-06 10:41:50 +01:00 committed by Jakub Janczak
parent bcfb8df116
commit 98d7bcefef
2 changed files with 3 additions and 13 deletions

View File

@ -32,7 +32,7 @@ type RemoteCommand struct {
func (c *RemoteCommand) Run(args []string) int { func (c *RemoteCommand) Run(args []string) int {
args = c.Meta.process(args, false) args = c.Meta.process(args, false)
var address, accessToken, name, path, region, securityToken, bucket string var address, accessToken, name, path, region, securityToken string
cmdFlags := flag.NewFlagSet("remote", flag.ContinueOnError) cmdFlags := flag.NewFlagSet("remote", flag.ContinueOnError)
cmdFlags.BoolVar(&c.conf.disableRemote, "disable", false, "") cmdFlags.BoolVar(&c.conf.disableRemote, "disable", false, "")
cmdFlags.BoolVar(&c.conf.pullOnDisable, "pull", true, "") cmdFlags.BoolVar(&c.conf.pullOnDisable, "pull", true, "")
@ -42,7 +42,6 @@ func (c *RemoteCommand) Run(args []string) int {
cmdFlags.StringVar(&address, "address", "", "") cmdFlags.StringVar(&address, "address", "", "")
cmdFlags.StringVar(&accessToken, "access-token", "", "") cmdFlags.StringVar(&accessToken, "access-token", "", "")
cmdFlags.StringVar(&securityToken, "security-token", "", "") cmdFlags.StringVar(&securityToken, "security-token", "", "")
cmdFlags.StringVar(&bucket, "bucket", "", "")
cmdFlags.StringVar(&region, "region", "", "") cmdFlags.StringVar(&region, "region", "", "")
cmdFlags.StringVar(&name, "name", "", "") cmdFlags.StringVar(&name, "name", "", "")
cmdFlags.StringVar(&path, "path", "", "") cmdFlags.StringVar(&path, "path", "", "")
@ -65,7 +64,6 @@ func (c *RemoteCommand) Run(args []string) int {
"security_token": securityToken, "security_token": securityToken,
"name": name, "name": name,
"path": path, "path": path,
"bucket": bucket,
"region": region, "region": region,
} }
@ -330,7 +328,7 @@ Usage: terraform remote [options]
Options: Options:
-address=url URL of the remote storage server. -address=url URL of the remote storage server.
Required for HTTP backend, optional for Atlas and Consul. Required for HTTP and S3 backend, optional for Atlas and Consul.
-access-token=token Authentication token for state storage server. -access-token=token Authentication token for state storage server.
Required for Atlas backend, optional for Consul. Required for Atlas backend, optional for Consul.
@ -344,8 +342,6 @@ Options:
modifying. Defaults to the "-state" path with modifying. Defaults to the "-state" path with
".backup" extension. Set to "-" to disable backup. ".backup" extension. Set to "-" to disable backup.
-bucket=bucket S3 bucket name. Specific to S3 (required).
-disable Disables remote state management and migrates the state -disable Disables remote state management and migrates the state
to the -state path. to the -state path.
@ -353,7 +349,7 @@ Options:
Required for Atlas backend. Required for Atlas backend.
-path=path Path of the remote state in Consul. Required for the -path=path Path of the remote state in Consul. Required for the
Consul and S3 backend. Consul.
-pull=true Controls if the remote state is pulled before disabling. -pull=true Controls if the remote state is pulled before disabling.
This defaults to true to ensure the latest state is cached This defaults to true to ensure the latest state is cached

View File

@ -80,8 +80,6 @@ func (c *S3RemoteClient) GetState() (*RemoteStatePayload, error) {
// FIXME copied from Atlas // FIXME copied from Atlas
// Handle the common status codes // Handle the common status codes
switch s3Err.StatusCode { switch s3Err.StatusCode {
case http.StatusOK:
// Handled after
case http.StatusNoContent: case http.StatusNoContent:
return nil, nil return nil, nil
case http.StatusNotFound: case http.StatusNotFound:
@ -144,8 +142,6 @@ func (c *S3RemoteClient) PutState(state []byte, force bool) error {
// Handle the error codes // Handle the error codes
switch s3Err.StatusCode { switch s3Err.StatusCode {
case http.StatusOK:
return nil
case http.StatusUnauthorized: case http.StatusUnauthorized:
return ErrRequireAuth return ErrRequireAuth
case http.StatusForbidden: case http.StatusForbidden:
@ -167,8 +163,6 @@ func (c *S3RemoteClient) DeleteState() error {
s3Err := err.(*s3.Error) s3Err := err.(*s3.Error)
// Handle the error codes // Handle the error codes
switch s3Err.StatusCode { switch s3Err.StatusCode {
case http.StatusOK:
return nil
case http.StatusNoContent: case http.StatusNoContent:
return nil return nil
case http.StatusNotFound: case http.StatusNotFound: