github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/resource_aws_codebuild_project_migrate.go (about) 1 package aws 2 3 import ( 4 "fmt" 5 "log" 6 "strings" 7 8 "github.com/hashicorp/terraform/terraform" 9 ) 10 11 func resourceAwsCodebuildMigrateState( 12 v int, is *terraform.InstanceState, meta interface{}) (*terraform.InstanceState, error) { 13 switch v { 14 case 0: 15 log.Println("[INFO] Found AWS Codebuild State v0; migrating to v1") 16 return migrateCodebuildStateV0toV1(is) 17 default: 18 return is, fmt.Errorf("Unexpected schema version: %d", v) 19 } 20 } 21 22 func migrateCodebuildStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { 23 if is.Empty() { 24 log.Println("[DEBUG] Empty InstanceState; nothing to migrate.") 25 return is, nil 26 } 27 28 log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes) 29 30 if is.Attributes["timeout"] != "" { 31 is.Attributes["build_timeout"] = strings.TrimSpace(is.Attributes["timeout"]) 32 } 33 34 log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes) 35 return is, nil 36 }