Skip to content

Commit

Permalink
helper improve code reuse
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoReboul committed Mar 27, 2020
1 parent 26bcadd commit 435aaa4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 38 deletions.
18 changes: 4 additions & 14 deletions listgroups/listgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,10 @@ type Key struct {

// FeedMessage Cloud Asset Inventory feed message
type FeedMessage struct {
Asset Asset `json:"asset"`
Window Window `json:"window"`
Deleted bool `json:"deleted"`
Origin string `json:"origin"`
}

// Window Cloud Asset Inventory feed message time window
type Window struct {
StartTime time.Time `json:"startTime"`
Asset Asset `json:"asset"`
Window helper.Window `json:"window"`
Deleted bool `json:"deleted"`
Origin string `json:"origin"`
}

// Asset uses the new CAI feed format
Expand All @@ -101,11 +96,6 @@ type Asset struct {
Resource *admin.Group `json:"resource"`
}

// PublishRequest Pub/sub
type PublishRequest struct {
Topic string `json:"topic"`
}

// Settings from PubSub triggering event
type Settings struct {
Domain string `json:"domain"`
Expand Down
25 changes: 10 additions & 15 deletions stream2bq/stream2bq.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,16 +148,16 @@ type SpecBQ struct {

// FeedMessage Cloud Asset Inventory feed message
type FeedMessage struct {
Asset Asset `json:"asset"`
Window Window `json:"window"`
Origin string `json:"origin"`
Asset Asset `json:"asset"`
Window helper.Window `json:"window"`
Origin string `json:"origin"`
}

// FeedMessageBQ format to persist in BQ
type FeedMessageBQ struct {
Asset AssetBQ `json:"asset"`
Window Window `json:"window"`
Origin string `json:"origin"`
Asset AssetBQ `json:"asset"`
Window helper.Window `json:"window"`
Origin string `json:"origin"`
}

// Asset Cloud Asset Metadata
Expand Down Expand Up @@ -190,10 +190,10 @@ type AssetBQ struct {

// AssetFeedMessageBQ Cloud Asset Inventory feed message for asset table
type AssetFeedMessageBQ struct {
Asset AssetAssetBQ `json:"asset"`
Window Window `json:"window"`
Deleted bool `json:"deleted"`
Origin string `json:"origin"`
Asset AssetAssetBQ `json:"asset"`
Window helper.Window `json:"window"`
Deleted bool `json:"deleted"`
Origin string `json:"origin"`
}

// AssetAssetBQ format to persist asset in BQ assets table
Expand All @@ -210,11 +210,6 @@ type AssetAssetBQ struct {
Timestamp time.Time `json:"timestamp"`
}

// Window Cloud Asset Inventory feed message time window
type Window struct {
StartTime time.Time `json:"startTime"`
}

// Parameters Constraint's settings
type Parameters map[string]json.RawMessage

Expand Down
13 changes: 4 additions & 9 deletions upload2gcs/upload2gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,10 @@ type Global struct {

// FeedMessage Cloud Asset Inventory feed message
type FeedMessage struct {
Asset Asset `json:"asset"`
Window Window `json:"window"`
Deleted bool `json:"deleted"`
Origin string `json:"origin"`
}

// Window Cloud Asset Inventory feed message time window
type Window struct {
StartTime time.Time `json:"startTime"`
Asset Asset `json:"asset"`
Window helper.Window `json:"window"`
Deleted bool `json:"deleted"`
Origin string `json:"origin"`
}

// Asset Cloud Asset Metadata
Expand Down

0 comments on commit 435aaa4

Please sign in to comment.