-
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.
feat: Add support for OCI Registry feeds (#273)
- Loading branch information
1 parent
376f033
commit 1d2223a
Showing
4 changed files
with
96 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,42 @@ | ||
package feeds | ||
|
||
import ( | ||
"github.com/OctopusDeploy/go-octopusdeploy/v2/internal" | ||
"github.com/go-playground/validator/v10" | ||
"github.com/go-playground/validator/v10/non-standard/validators" | ||
) | ||
|
||
// OCIRegistryFeed represents a feed of Open Container Initiative Registry. | ||
type OCIRegistryFeed struct { | ||
FeedURI string `json:"FeedUri,omitempty"` | ||
|
||
feed | ||
} | ||
|
||
// NewOCIRegistryFeed creates and initializes a OCIRegistry feed. | ||
func NewOCIRegistryFeed(name string) (*OCIRegistryFeed, error) { | ||
if internal.IsEmpty(name) { | ||
return nil, internal.CreateRequiredParameterIsEmptyOrNilError("name") | ||
} | ||
|
||
feed := OCIRegistryFeed{ | ||
FeedURI: "oci://registry-1.docker.io", | ||
feed: *newFeed(name, FeedTypeOCIRegistry), | ||
} | ||
|
||
if err := feed.Validate(); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &feed, nil | ||
} | ||
|
||
// Validate checks the state of this feed and returns an error if invalid. | ||
func (m *OCIRegistryFeed) Validate() error { | ||
v := validator.New() | ||
err := v.RegisterValidation("notblank", validators.NotBlank) | ||
if err != nil { | ||
return err | ||
} | ||
return v.Struct(m) | ||
} |