-
Notifications
You must be signed in to change notification settings - Fork 166
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a types package to better organize types
- Loading branch information
Showing
5 changed files
with
140 additions
and
111 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package types | ||
|
||
/******************************************************* | ||
* Compare types | ||
* | ||
* Used to compute the diff between two state versions | ||
*******************************************************/ | ||
|
||
type StateInfo struct { | ||
VersionID string `json:"version_id"` | ||
ResourceCount int `json:"resource_count"` | ||
} | ||
|
||
type ResourceDiff struct { | ||
OnlyInOld map[string]string `json:"only_in_old"` | ||
OnlyInNew map[string]string `json:"only_in_new"` | ||
UnifiedDiff string `json:"unified_diff"` | ||
} | ||
|
||
type StateCompare struct { | ||
Stats struct { | ||
From StateInfo `json:"from"` | ||
To StateInfo `json:"to"` | ||
} `json:"stats"` | ||
Differences struct { | ||
OnlyInOld []string `json:"only_in_old"` | ||
OnlyInNew []string `json:"only_in_new"` | ||
InBoth []string `json:"in_both"` | ||
ResourceDiff map[string]ResourceDiff `json:"resource_diff"` | ||
} `json:"differences"` | ||
} |
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,52 @@ | ||
package types | ||
|
||
import ( | ||
"database/sql" | ||
"time" | ||
|
||
"github.com/jinzhu/gorm" | ||
) | ||
|
||
/********************************************* | ||
* Database object types | ||
* | ||
* Each type corresponds to a table in the DB | ||
*********************************************/ | ||
|
||
type Version struct { | ||
ID uint `sql:"AUTO_INCREMENT" gorm:"primary_key" json:"-"` | ||
VersionID string `gorm:"index" json:"version_id"` | ||
LastModified time.Time `json:"last_modified"` | ||
} | ||
|
||
type State struct { | ||
gorm.Model `json:"-"` | ||
Path string `gorm:"index" json:"path"` | ||
Version Version `json:"version"` | ||
VersionID sql.NullInt64 `gorm:"index" json:"-"` | ||
TFVersion string `json:"terraform_version"` | ||
Serial int64 `json:"serial"` | ||
Modules []Module `json:"modules"` | ||
} | ||
|
||
type Module struct { | ||
ID uint `sql:"AUTO_INCREMENT" gorm:"primary_key" json:"-"` | ||
StateID sql.NullInt64 `gorm:"index" json:"-"` | ||
Path string `json:"path"` | ||
Resources []Resource `json:"resources"` | ||
} | ||
|
||
type Resource struct { | ||
ID uint `sql:"AUTO_INCREMENT" gorm:"primary_key" json:"-"` | ||
ModuleID sql.NullInt64 `gorm:"index" json:"-"` | ||
Type string `gorm:"index" json:"type"` | ||
Name string `gorm:"index" json:"name"` | ||
Attributes []Attribute `json:"attributes"` | ||
} | ||
|
||
type Attribute struct { | ||
ID uint `sql:"AUTO_INCREMENT" gorm:"primary_key" json:"-"` | ||
ResourceID sql.NullInt64 `gorm:"index" json:"-"` | ||
Key string `gorm:"index" json:"key"` | ||
Value string `gorm:"index" json:"value"` | ||
} |
Oops, something went wrong.