-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #897 from cloudskiff/add_state_source_in_resources
Add resource source for terraform state
- Loading branch information
Showing
7 changed files
with
172,003 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
package config | ||
|
||
import "fmt" | ||
|
||
type SupplierConfig struct { | ||
Key string | ||
Backend string | ||
Path string | ||
} | ||
|
||
func (c *SupplierConfig) String() string { | ||
str := c.Key | ||
if c.Backend != "" { | ||
str += fmt.Sprintf("+%s", c.Backend) | ||
} | ||
if str != "" { | ||
str += "://" | ||
} | ||
if c.Path != "" { | ||
str += c.Path | ||
} | ||
return str | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package config | ||
|
||
import "testing" | ||
|
||
func TestSupplierConfig_String(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
config SupplierConfig | ||
want string | ||
}{ | ||
{ | ||
name: "test with empty config", | ||
config: SupplierConfig{}, | ||
want: "", | ||
}, | ||
{ | ||
name: "test with empty path", | ||
config: SupplierConfig{ | ||
Key: "tfstate", | ||
Backend: "s3", | ||
Path: "", | ||
}, | ||
want: "tfstate+s3://", | ||
}, | ||
{ | ||
name: "test valid config", | ||
config: SupplierConfig{ | ||
Key: "tfstate", | ||
Backend: "s3", | ||
Path: "my-bucket/terraform.tfstate", | ||
}, | ||
want: "tfstate+s3://my-bucket/terraform.tfstate", | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := tt.config.String(); got != tt.want { | ||
t.Errorf("String() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.