Skip to content

Commit

Permalink
Add key fields to PackageRevisionResources (#3036)
Browse files Browse the repository at this point in the history
  • Loading branch information
justinsb committed Apr 21, 2022
1 parent 1954726 commit 23a710f
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 28 deletions.
47 changes: 36 additions & 11 deletions porch/api/generated/openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions porch/api/porch/types_packagerevisionresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@ type PackageRevisionResourcesList struct {

// PackageRevisionResourcesSpec represents resources (as ResourceList serialized as yaml string) of the PackageRevision.
type PackageRevisionResourcesSpec struct {
// PackageName identifies the package in the repository.
PackageName string `json:"packageName,omitempty"`

// Revision identifies the version of the package.
Revision string `json:"revision,omitempty"`

// RepositoryName is the name of the Repository object containing this package.
RepositoryName string `json:"repository,omitempty"`

// Resources are the content of the package.
Resources map[string]string `json:"resources,omitempty"`
}
10 changes: 7 additions & 3 deletions porch/api/porch/types_packagerevisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,18 @@ const (

// PackageRevisionSpec defines the desired state of PackageRevision
type PackageRevisionSpec struct {
// PackageName identifies the package in the repository.
PackageName string `json:"packageName,omitempty"`
Revision string `json:"revision,omitempty"`

// Parent references a package that provides resources to us
Parent *ParentReference `json:"parent,omitempty"`
// Revision identifies the version of the package.
Revision string `json:"revision,omitempty"`

// RepositoryName is the name of the Repository object containing this package.
RepositoryName string `json:"repository,omitempty"`

// Parent references a package that provides resources to us
Parent *ParentReference `json:"parent,omitempty"`

Lifecycle PackageRevisionLifecycle `json:"lifecycle,omitempty"`

Tasks []Task `json:"tasks,omitempty"`
Expand Down
10 changes: 10 additions & 0 deletions porch/api/porch/v1alpha1/types_packagerevisionresources.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,15 @@ type PackageRevisionResourcesList struct {

// PackageRevisionResourcesSpec represents resources (as ResourceList serialized as yaml string) of the PackageRevision.
type PackageRevisionResourcesSpec struct {
// PackageName identifies the package in the repository.
PackageName string `json:"packageName,omitempty"`

// Revision identifies the version of the package.
Revision string `json:"revision,omitempty"`

// RepositoryName is the name of the Repository object containing this package.
RepositoryName string `json:"repository,omitempty"`

// Resources are the content of the package.
Resources map[string]string `json:"resources,omitempty"`
}
10 changes: 7 additions & 3 deletions porch/api/porch/v1alpha1/types_packagerevisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ const (

// PackageRevisionSpec defines the desired state of PackageRevision
type PackageRevisionSpec struct {
// PackageName identifies the package in the repository.
PackageName string `json:"packageName,omitempty"`
Revision string `json:"revision,omitempty"`

// Parent references a package that provides resources to us
Parent *ParentReference `json:"parent,omitempty"`
// Revision identifies the version of the package.
Revision string `json:"revision,omitempty"`

// RepositoryName is the name of the Repository object containing this package.
RepositoryName string `json:"repository,omitempty"`

// Parent references a package that provides resources to us
Parent *ParentReference `json:"parent,omitempty"`

Lifecycle PackageRevisionLifecycle `json:"lifecycle,omitempty"`

Tasks []Task `json:"tasks,omitempty"`
Expand Down
10 changes: 8 additions & 2 deletions porch/api/porch/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 15 additions & 5 deletions porch/repository/pkg/git/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func (p *gitPackageRevision) uid() types.UID {
}

func (p *gitPackageRevision) GetPackageRevision() (*v1alpha1.PackageRevision, error) {
key := p.Key()

return &v1alpha1.PackageRevision{
TypeMeta: metav1.TypeMeta{
Kind: "PackageRevision",
Expand All @@ -84,11 +86,12 @@ func (p *gitPackageRevision) GetPackageRevision() (*v1alpha1.PackageRevision, er
},
},
Spec: v1alpha1.PackageRevisionSpec{
PackageName: p.path,
Revision: p.revision,
RepositoryName: p.parent.name,
Lifecycle: p.Lifecycle(),
Tasks: p.tasks,
PackageName: key.Package,
Revision: key.Revision,
RepositoryName: key.Repository,

Lifecycle: p.Lifecycle(),
Tasks: p.tasks,
},
Status: v1alpha1.PackageRevisionStatus{},
}, nil
Expand Down Expand Up @@ -120,6 +123,9 @@ func (p *gitPackageRevision) GetResources(ctx context.Context) (*v1alpha1.Packag
//resources[path.Join(p.path, file.Name)] = content
}
}

key := p.Key()

return &v1alpha1.PackageRevisionResources{
TypeMeta: metav1.TypeMeta{
Kind: "PackageRevisionResources",
Expand All @@ -136,6 +142,10 @@ func (p *gitPackageRevision) GetResources(ctx context.Context) (*v1alpha1.Packag
OwnerReferences: []metav1.OwnerReference{}, // TODO: should point to repository resource
},
Spec: v1alpha1.PackageRevisionResourcesSpec{
PackageName: key.Package,
Revision: key.Revision,
RepositoryName: key.Repository,

Resources: resources,
},
}, nil
Expand Down
17 changes: 13 additions & 4 deletions porch/repository/pkg/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,8 @@ func (p *ociPackageRevision) GetResources(ctx context.Context) (*v1alpha1.Packag
return nil, err
}

key := p.Key()

return &v1alpha1.PackageRevisionResources{
TypeMeta: metav1.TypeMeta{
Kind: "PackageRevisionResources",
Expand All @@ -334,6 +336,10 @@ func (p *ociPackageRevision) GetResources(ctx context.Context) (*v1alpha1.Packag
UID: p.uid,
},
Spec: v1alpha1.PackageRevisionResourcesSpec{
PackageName: key.Package,
Revision: key.Revision,
RepositoryName: key.Repository,

Resources: resources.Contents,
},
}, nil
Expand All @@ -353,6 +359,8 @@ func (p *ociPackageRevision) Key() repository.PackageRevisionKey {
}

func (p *ociPackageRevision) GetPackageRevision() (*v1alpha1.PackageRevision, error) {
key := p.Key()

return &v1alpha1.PackageRevision{
TypeMeta: metav1.TypeMeta{
Kind: "PackageRevision",
Expand All @@ -368,10 +376,11 @@ func (p *ociPackageRevision) GetPackageRevision() (*v1alpha1.PackageRevision, er
UID: p.uid,
},
Spec: v1alpha1.PackageRevisionSpec{
PackageName: p.packageName,
Revision: p.revision,
RepositoryName: p.parent.name,
Tasks: p.tasks,
PackageName: key.Package,
Revision: key.Revision,
RepositoryName: key.Repository,

Tasks: p.tasks,
},
}, nil
}
Expand Down

0 comments on commit 23a710f

Please sign in to comment.