File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -91,6 +91,19 @@ func (d *ResourceData) Id() string {
9191 return result
9292}
9393
94+ // ConnInfo returns the connection info for this resource.
95+ func (d * ResourceData ) ConnInfo () map [string ]string {
96+ if d .newState != nil {
97+ return d .newState .ConnInfo
98+ }
99+
100+ if d .state != nil {
101+ return d .state .ConnInfo
102+ }
103+
104+ return nil
105+ }
106+
94107// Dependencies returns the dependencies in this state.
95108func (d * ResourceData ) Dependencies () []terraform.ResourceDependency {
96109 if d .newState != nil {
@@ -111,6 +124,12 @@ func (d *ResourceData) SetId(v string) {
111124 d .newState .ID = v
112125}
113126
127+ // SetConnInfo sets the connection info for a resource.
128+ func (d * ResourceData ) SetConnInfo (v map [string ]string ) {
129+ d .once .Do (d .init )
130+ d .newState .ConnInfo = v
131+ }
132+
114133// SetDependencies sets the dependencies of a resource.
115134func (d * ResourceData ) SetDependencies (ds []terraform.ResourceDependency ) {
116135 d .once .Do (d .init )
@@ -123,6 +142,7 @@ func (d *ResourceData) State() *terraform.ResourceState {
123142 var result terraform.ResourceState
124143 result .ID = d .Id ()
125144 result .Attributes = d .stateObject ("" , d .schema )
145+ result .ConnInfo = d .ConnInfo ()
126146 result .Dependencies = d .Dependencies ()
127147
128148 if v := d .Id (); v != "" {
Original file line number Diff line number Diff line change @@ -1531,6 +1531,22 @@ func TestResourceDataState(t *testing.T) {
15311531 }
15321532}
15331533
1534+ func TestResourceDataSetConnInfo (t * testing.T ) {
1535+ d := & ResourceData {}
1536+ d .SetConnInfo (map [string ]string {
1537+ "foo" : "bar" ,
1538+ })
1539+
1540+ expected := map [string ]string {
1541+ "foo" : "bar" ,
1542+ }
1543+
1544+ actual := d .State ()
1545+ if ! reflect .DeepEqual (actual .ConnInfo , expected ) {
1546+ t .Fatalf ("bad: %#v" , actual )
1547+ }
1548+ }
1549+
15341550func TestResourceDataSetDependencies (t * testing.T ) {
15351551 d := & ResourceData {}
15361552 d .SetDependencies ([]terraform.ResourceDependency {
You can’t perform that action at this time.
0 commit comments