Clean the fork command specific types
@@ -38,67 +38,4 @@ type AppMetadata struct {
Description string `json:"description,omitempty"`
Namespace string `json:"namespace,omitempty"`
Maintainers Maintainers `json:"maintainers,omitempty"`
- Parents Parents `yaml:",omitempty" json:"parents,omitempty"`
-}
-
-// Parents is a list of ParentMetadata items
-type Parents []ParentMetadata
-
-// ParentMetadata contains historical data of forked packages
-type ParentMetadata struct {
- Name string `json:"name"`
- Namespace string `json:"namespace,omitempty"`
- Version string `json:"version"`
- Maintainers Maintainers `json:"maintainers,omitempty"`
-}
-
-// Modifier is a function signature that takes and returns an AppMetadata object
-type Modifier func(AppMetadata) AppMetadata
-
-// From returns an AppMetadata instance based on the provided AppMetadata
-// and applicable modifier functions
-func From(orig AppMetadata, modifiers ...Modifier) AppMetadata {
- parent := ParentMetadata{
- Name: orig.Name,
- Namespace: orig.Namespace,
- Version: orig.Version,
- Maintainers: orig.Maintainers,
- }
-
- result := AppMetadata{
- Version: orig.Version,
- Name: orig.Name,
- Namespace: orig.Namespace,
- Description: orig.Description,
- Maintainers: orig.Maintainers,
- Parents: append(orig.Parents, parent),
- }
- for _, f := range modifiers {
- result = f(result)
- }
- return result
-}
-
-// WithMaintainers returns a modified AppMetadata with updated maintainers field
-func WithMaintainers(maintainers Maintainers) Modifier {
- return func(parent AppMetadata) AppMetadata {
- parent.Maintainers = maintainers
- return parent
- }
-}
-
-// WithName returns a modified AppMetadata with updated name field
-func WithName(name string) Modifier {
- return func(parent AppMetadata) AppMetadata {
- parent.Name = name
- return parent
- }
-}
-
-// WithNamespace returns a modified AppMetadata with updated namespace field
-func WithNamespace(namespace string) Modifier {
- return func(parent AppMetadata) AppMetadata {
- parent.Namespace = namespace
- return parent
- }
}
