-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Daniel Hill <6022646+funkbunker@users.noreply.github.com>
- Loading branch information
1 parent
17b4d2a
commit 6754870
Showing
5 changed files
with
108 additions
and
1 deletion.
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
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,55 @@ | ||
package feeds | ||
|
||
import ( | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/internal" | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/core" | ||
"github.com/go-playground/validator/v10" | ||
"github.com/go-playground/validator/v10/non-standard/validators" | ||
) | ||
|
||
// S3Feed represents an Amazon Web Services (AWS) S3 Bucket Feed | ||
type S3Feed struct { | ||
AccessKey string `json:"AccessKey,omitempty"` | ||
SecretKey *core.SensitiveValue `json:"SecretKey,omitempty"` | ||
UseMachineCredentials bool `json:"UseMachineCredentials"` | ||
feed | ||
} | ||
|
||
// NewS3Feed creates and initializes an Amazon S3 Bucket Feed | ||
func NewS3Feed(name string, accessKey string, secretKey *core.SensitiveValue, useMachineCredentials bool) (*S3Feed, error) { | ||
if internal.IsEmpty(name) { | ||
return nil, internal.CreateRequiredParameterIsEmptyOrNilError("name") | ||
} | ||
if !useMachineCredentials { | ||
if internal.IsEmpty(accessKey) { | ||
return nil, internal.CreateRequiredParameterIsEmptyOrNilError("accessKey") | ||
} | ||
|
||
if secretKey == nil { | ||
return nil, internal.CreateRequiredParameterIsEmptyOrNilError("secretKey") | ||
} | ||
} | ||
feed := S3Feed{ | ||
AccessKey: accessKey, | ||
SecretKey: secretKey, | ||
UseMachineCredentials: useMachineCredentials, | ||
feed: *newFeed(name, FeedTypeS3), | ||
} | ||
|
||
// validate to ensure that all expectations are met | ||
if err := feed.Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &feed, nil | ||
} | ||
|
||
// Validate checks the state of this Amazon Web Services (AWS) S3 Bucket Feed | ||
func (a *S3Feed) Validate() error { | ||
v := validator.New() | ||
err := v.RegisterValidation("notblank", validators.NotBlank) | ||
if err != nil { | ||
return err | ||
} | ||
return v.Struct(a) | ||
} |
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