mirror of
https://github.com/trufflesecurity/trufflehog.git
synced 2024-11-10 15:14:38 +00:00
Setup SourceUnit interface (#1393)
* Test: Asymmetrical unmarshal API
* Test: Symmetric marshal API
* Revert "Test: Symmetric marshal API"
This reverts commit f51c64a797
.
* Cleanup test example and add SourceUnitUnmarshaller interface
* Add CommonSourceUnit implementation
* Update comments
* Remove UnmarshalJSON
This commit is contained in:
parent
401688d0a8
commit
e12f0f84a1
2 changed files with 25 additions and 0 deletions
12
pkg/sources/source_unit.go
Normal file
12
pkg/sources/source_unit.go
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
package sources
|
||||||
|
|
||||||
|
// CommonSourceUnit is a common implementation of SourceUnit that Sources can
|
||||||
|
// use instead of implementing their own types.
|
||||||
|
type CommonSourceUnit struct {
|
||||||
|
ID string `json:"source_unit_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implement the SourceUnit interface.
|
||||||
|
func (c CommonSourceUnit) SourceUnitID() string {
|
||||||
|
return c.ID
|
||||||
|
}
|
|
@ -44,6 +44,19 @@ type Source interface {
|
||||||
GetProgress() *Progress
|
GetProgress() *Progress
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SourceUnitUnmarshaller defines an optional interface a Source can implement
|
||||||
|
// to support units coming from an external source.
|
||||||
|
type SourceUnitUnmarshaller interface {
|
||||||
|
UnmarshalSourceUnit(data []byte) (SourceUnit, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SourceUnit is an object that represents a Source's unit of work. This is
|
||||||
|
// used as the output of enumeration, progress reporting, and job distribution.
|
||||||
|
type SourceUnit interface {
|
||||||
|
// SourceUnitID uniquely identifies a source unit.
|
||||||
|
SourceUnitID() string
|
||||||
|
}
|
||||||
|
|
||||||
// GCSConfig defines the optional configuration for a GCS source.
|
// GCSConfig defines the optional configuration for a GCS source.
|
||||||
type GCSConfig struct {
|
type GCSConfig struct {
|
||||||
// CloudCred determines whether to use cloud credentials.
|
// CloudCred determines whether to use cloud credentials.
|
||||||
|
|
Loading…
Reference in a new issue