style(assets): rename container to set

This commit is contained in:
Nightapes
2020-03-24 19:51:18 +01:00
parent 666716d627
commit 92600059c2

View File

@@ -11,16 +11,16 @@ import (
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// Container struct // Set struct
type Container struct { type Set struct {
Assets []*Asset Assets []*Asset
repository string repository string
algorithm string algorithm string
} }
//New container for assets //New container for assets
func New(repository, algorithm string) *Container { func New(repository, algorithm string) *Set {
return &Container{ return &Set{
Assets: []*Asset{}, Assets: []*Asset{},
repository: repository, repository: repository,
algorithm: algorithm, algorithm: algorithm,
@@ -28,29 +28,29 @@ func New(repository, algorithm string) *Container {
} }
// Add assets to the list // Add assets to the list
func (a *Container) Add(assetConfigs ...config.Asset) error { func (s *Set) Add(assetConfigs ...config.Asset) error {
for _, assetConfig := range assetConfigs { for _, assetConfig := range assetConfigs {
asset, err := NewAsset(a.repository, assetConfig, a.algorithm) asset, err := NewAsset(s.repository, assetConfig, s.algorithm)
if err != nil { if err != nil {
return err return err
} }
a.Assets = append(a.Assets, asset) s.Assets = append(s.Assets, asset)
} }
return nil return nil
} }
func (a *Container) All() []*Asset { func (s *Set) All() []*Asset {
return a.Assets return s.Assets
} }
func (a *Container) GenerateChecksum() error { func (s *Set) GenerateChecksum() error {
checksumFile, err := ioutil.TempFile(os.TempDir(), "checksum.*.txt") checksumFile, err := ioutil.TempFile(os.TempDir(), "checksum.*.txt")
if err != nil { if err != nil {
return errors.Wrap(err, "Could not generate tmp file for checksum") return errors.Wrap(err, "Could not generate tmp file for checksum")
} }
defer checksumFile.Close() defer checksumFile.Close()
lines := []string{} lines := []string{}
for _, asset := range a.Assets { for _, asset := range s.Assets {
checksum, err := asset.getChecksum() checksum, err := asset.getChecksum()
if err != nil { if err != nil {
return err return err
@@ -68,7 +68,7 @@ func (a *Container) GenerateChecksum() error {
return err return err
} }
a.Assets = append(a.Assets, &Asset{ s.Assets = append(s.Assets, &Asset{
path: filePath, path: filePath,
name: "checksum.txt", name: "checksum.txt",
isCompressed: false, isCompressed: false,