Skip to content

Commit

Permalink
feat: Add option latestPolicy for docker hosted storage
Browse files Browse the repository at this point in the history
  • Loading branch information
anmoel committed Aug 9, 2024
1 parent a14f082 commit 6ed7285
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
14 changes: 8 additions & 6 deletions nexus3/pkg/repository/docker/docker_hosted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ import (
)

func getTestDockerHostedRepository(name string) repository.DockerHostedRepository {
writePolicy := repository.StorageWritePolicyAllow
latestPolicy := false
return repository.DockerHostedRepository{
Name: name,
Online: true,

Cleanup: &repository.Cleanup{
PolicyNames: []string{"weekly-cleanup"},
},
Storage: repository.HostedStorage{
Storage: repository.DockerHostedStorage{
BlobStoreName: "default",
StrictContentTypeValidation: true,
WritePolicy: &writePolicy,
WritePolicy: repository.StorageWritePolicyAllow,
LatestPolicy: &latestPolicy,
},
Component: &repository.Component{
ProprietaryComponents: true,
Expand All @@ -37,18 +38,19 @@ func getTestDockerHostedRepository(name string) repository.DockerHostedRepositor
}

func getTestProDockerHostedRepository(name string) repository.DockerHostedRepository {
writePolicy := repository.StorageWritePolicyAllow
latestPolicy := true
return repository.DockerHostedRepository{
Name: name,
Online: true,

Cleanup: &repository.Cleanup{
PolicyNames: []string{"weekly-cleanup"},
},
Storage: repository.HostedStorage{
Storage: repository.DockerHostedStorage{
BlobStoreName: "default",
StrictContentTypeValidation: true,
WritePolicy: &writePolicy,
WritePolicy: repository.StorageWritePolicyAllow,
LatestPolicy: &latestPolicy,
},
Component: &repository.Component{
ProprietaryComponents: true,
Expand Down
21 changes: 18 additions & 3 deletions nexus3/schema/repository/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ type DockerGroupRepository struct {
}

type DockerHostedRepository struct {
Name string `json:"name"`
Online bool `json:"online"`
Storage HostedStorage `json:"storage"`
Name string `json:"name"`
Online bool `json:"online"`
Storage DockerHostedStorage `json:"storage"`
Docker `json:"docker"`

*Cleanup `json:"cleanup,omitempty"`
Expand Down Expand Up @@ -67,3 +67,18 @@ type DockerProxy struct {
// Url of Docker Index to use
IndexURL *string `json:"indexUrl,omitempty"`
}

// DockerHostedStorage contains repository storage for hosted docker
type DockerHostedStorage struct {
// Blob store used to store repository contents
BlobStoreName string `json:"blobStoreName"`

// StrictContentTypeValidation: Whether to validate uploaded content's MIME type appropriate for the repository format
StrictContentTypeValidation bool `json:"strictContentTypeValidation"`

// WritePolicy controls if deployments of and updates to assets are allowed
WritePolicy StorageWritePolicy `json:"writePolicy"`

// LatestPolicy: Whether to allow redeploying the 'latest' tag but defer to the Deployment Policy for all other tags
LatestPolicy *bool `json:"latestPolicy,omitempty"`
}

0 comments on commit 6ed7285

Please sign in to comment.