-
Notifications
You must be signed in to change notification settings - Fork 25
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 #16 from trek10inc/change_structure
Change structure
- Loading branch information
Showing
243 changed files
with
1,846 additions
and
1,682 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package awsets | ||
|
||
import "github.com/trek10inc/awsets/resource" | ||
|
||
// Cacher is an interface that defines the necessary functions for an AWSets | ||
// cache. | ||
type Cacher interface { | ||
Initialize(accountId string) error | ||
IsCached(region string, kind ListerName) bool | ||
SaveGroup(kind ListerName, group *resource.Group) error | ||
LoadGroup(region string, kind ListerName) (*resource.Group, error) | ||
} | ||
|
||
// NoOpCache is the default cache provided by AWSets. It does nothing, and | ||
// will never load nor save any data. | ||
type NoOpCache struct { | ||
} | ||
|
||
func (c NoOpCache) Initialize(accountId string) error { | ||
return nil | ||
} | ||
|
||
func (c NoOpCache) IsCached(region string, kind ListerName) bool { | ||
return false | ||
} | ||
|
||
func (c NoOpCache) SaveGroup(kind ListerName, group *resource.Group) error { | ||
return nil | ||
} | ||
|
||
func (c NoOpCache) LoadGroup(region string, kind ListerName) (*resource.Group, error) { | ||
return resource.NewGroup(), nil | ||
} |
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,57 @@ | ||
package context | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
) | ||
|
||
type AWSetsCtx struct { | ||
AWSCfg aws.Config | ||
AccountId string | ||
WorkerId int | ||
Context context.Context | ||
Lister string | ||
StatusChan chan<- StatusUpdate | ||
TotalJobs int | ||
} | ||
|
||
func (c *AWSetsCtx) Region() string { | ||
return c.AWSCfg.Region | ||
} | ||
|
||
func (c *AWSetsCtx) Copy(region string) *AWSetsCtx { | ||
|
||
cop := &AWSetsCtx{ | ||
AWSCfg: c.AWSCfg.Copy(), | ||
AccountId: c.AccountId, | ||
Context: c.Context, | ||
StatusChan: c.StatusChan, | ||
Lister: c.Lister, | ||
WorkerId: c.WorkerId, | ||
TotalJobs: c.TotalJobs, | ||
} | ||
cop.AWSCfg.Region = region | ||
return cop | ||
} | ||
|
||
func (c *AWSetsCtx) SendStatus(statusType StatusType, msg string) { | ||
if c.StatusChan == nil { | ||
return | ||
} | ||
su := StatusUpdate{ | ||
Type: statusType, | ||
Lister: c.Lister, | ||
Region: c.Region(), | ||
Message: msg, | ||
WorkerId: c.WorkerId, | ||
TotalJobs: c.TotalJobs, | ||
} | ||
c.StatusChan <- su | ||
} | ||
|
||
func (c *AWSetsCtx) Close() { | ||
if c.StatusChan != nil { | ||
close(c.StatusChan) | ||
} | ||
} |
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,4 +1,4 @@ | ||
package option | ||
package context | ||
|
||
type StatusType string | ||
|
||
|
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
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.