Skip to content

Commit

Permalink
Fix rebase again
Browse files Browse the repository at this point in the history
  • Loading branch information
efiacor committed Nov 5, 2024
1 parent 1791a38 commit 12f7597
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 12 deletions.
13 changes: 13 additions & 0 deletions api/porchconfig/v1alpha1/config.porch.kpt.dev_repositories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ spec:
- jsonPath: .spec.type
name: Type
type: string
- jsonPath: .spec.content
name: Content
type: string
- jsonPath: .spec.deployment
name: Deployment
type: boolean
Expand Down Expand Up @@ -56,6 +59,16 @@ spec:
Notes:
- deployment repository - in KRM API ConfigSync would be configured directly? (or via this API)
properties:
content:
default: Package
description: |-
The Content field is deprecated, please do not specify it in new manifests.
For partial backward compatibility it is still recognized, but its only valid value is "Package", and if not specified its default value is also "Package".
type: string
x-kubernetes-validations:
- message: The 'content' field is deprecated, its only valid value
is 'Package'
rule: self == '' || self == 'Package'
deployment:
description: The repository is a deployment repository; final packages
in this repository are deployment ready.
Expand Down
13 changes: 13 additions & 0 deletions api/porchconfig/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
//+kubebuilder:subresource:status
//+kubebuilder:resource:path=repositories,singular=repository
//+kubebuilder:printcolumn:name="Type",type=string,JSONPath=`.spec.type`
//+kubebuilder:printcolumn:name="Content",type=string,JSONPath=`.spec.content`
//+kubebuilder:printcolumn:name="Deployment",type=boolean,JSONPath=`.spec.deployment`
//+kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=='Ready')].status`
//+kubebuilder:printcolumn:name="Address",type=string,JSONPath=`.spec['git','oci']['repo','registry']`
Expand All @@ -42,6 +43,12 @@ const (
RepositoryTypeOCI RepositoryType = "oci"
)

type RepositoryContent string

const (
RepositoryContentPackage RepositoryContent = "Package"
)

// RepositorySpec defines the desired state of Repository
//
// Notes:
Expand All @@ -53,6 +60,12 @@ type RepositorySpec struct {
Deployment bool `json:"deployment,omitempty"`
// Type of the repository (i.e. git, OCI)
Type RepositoryType `json:"type,omitempty"`
// The Content field is deprecated, please do not specify it in new manifests.
// For partial backward compatibility it is still recognized, but its only valid value is "Package", and if not specified its default value is also "Package".
// +kubebuilder:validation:XValidation:message="The 'content' field is deprecated, its only valid value is 'Package'",rule="self == '' || self == 'Package'"
// +kubebuilder:default="Package"
Content *RepositoryContent `json:"content,omitempty"`

// Git repository details. Required if `type` is `git`. Ignored if `type` is not `git`.
Git *GitRepository `json:"git,omitempty"`
// OCI repository details. Required if `type` is `oci`. Ignored if `type` is not `oci`.
Expand Down
5 changes: 5 additions & 0 deletions api/porchconfig/v1alpha1/zz_generated.deepcopy.go

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

9 changes: 1 addition & 8 deletions pkg/cache/memory/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re
return nil, err
}

r, err := oci.OpenRepository(repositorySpec.Name, repositorySpec.Namespace, repositorySpec.Spec.Content, ociSpec, repositorySpec.Spec.Deployment, storage)
r, err := oci.OpenRepository(repositorySpec.Name, repositorySpec.Namespace, ociSpec, repositorySpec.Spec.Deployment, storage)
if err != nil {
return nil, err
}
Expand All @@ -138,9 +138,6 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re

case configapi.RepositoryTypeGit:
gitSpec := repositorySpec.Spec.Git
if !isPackageContent(repositorySpec.Spec.Content) {
return nil, fmt.Errorf("git repository supports Package content only; got %q", string(repositorySpec.Spec.Content))
}
if cachedRepo == nil {
var mbs git.MainBranchStrategy
if gitSpec.CreateBranch {
Expand Down Expand Up @@ -174,10 +171,6 @@ func (c *Cache) OpenRepository(ctx context.Context, repositorySpec *configapi.Re
}
}

func isPackageContent(content configapi.RepositoryContent) bool {
return content == configapi.RepositoryContentPackage
}

func (c *Cache) CloseRepository(repositorySpec *configapi.Repository, allRepos []configapi.Repository) error {
key, err := getCacheKey(repositorySpec)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/cli/testdata/repo-register/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ commands:
- get
- --namespace=repo-register
stdout: |
NAME TYPE DEPLOYMENT READY ADDRESS
test-blueprints git True https://github.com/platkrm/test-blueprints.git
NAME TYPE CONTENT DEPLOYMENT READY ADDRESS
test-blueprints git Package True https://github.com/platkrm/test-blueprints.git
- args:
- porchctl
- repo
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/cli/testdata/rpkg-init-deploy/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ commands:
- get
- --namespace=rpkg-init-deploy
stdout: |
NAME TYPE DEPLOYMENT READY ADDRESS
git git true True http://git-server.test-git-namespace.svc.cluster.local:8080/rpkg-init-deploy
NAME TYPE CONTENT DEPLOYMENT READY ADDRESS
git git Package true True http://git-server.test-git-namespace.svc.cluster.local:8080/rpkg-init-deploy

0 comments on commit 12f7597

Please sign in to comment.