-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathdb.go
57 lines (49 loc) · 1.74 KB
/
db.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package types
import (
"database/sql"
"time"
"github.com/jinzhu/gorm"
)
/*********************************************
* Database object types
*
* Each type corresponds to a table in the DB
*********************************************/
// Version is an S3 bucket version
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"`
}
// State is a Terraform State
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"`
}
// Module is a Terraform module in a State
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"`
}
// Resource is a Terraform resource in a Module
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"`
}
// Attribute is a Terraform attribute in a Resource
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"`
}