Skip to content

Commit

Permalink
feat(registry): provide registry maintenance readonly mode (#1978)
Browse files Browse the repository at this point in the history
Co-authored-by: root <root@localhost.localdomain>
  • Loading branch information
Huimintai and root committed May 30, 2022
1 parent f469aaa commit b24b841
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ data:
{{- end }}
delete:
enabled: true
maintenance:
readonly:
enabled: false
security:
tokenPrivateKeyFile: /etc/registry/private_key.pem
tokenPublicKeyFile: /etc/registry/public_key.crt
Expand Down
11 changes: 11 additions & 0 deletions pkg/registry/apis/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Storage struct {
Etcd *EtcdStorage
// +optional
Delete *Delete
// +optional
Maintenance *Maintenance
}
type EtcdStorage struct {
CAFile string
Expand Down Expand Up @@ -119,6 +121,15 @@ type Delete struct {
Enabled bool
}

// Maintenance ReadOnly enabled set to true, clients will not be allowed to write to the registry.
type Maintenance struct {
ReadOnly ReadOnly
}

type ReadOnly struct {
Enabled bool
}

type Security struct {
TokenPrivateKeyFile string
TokenPublicKeyFile string
Expand Down
11 changes: 11 additions & 0 deletions pkg/registry/apis/config/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Storage struct {
Etcd *EtcdStorage `json:"etcd,omitempty" yaml:"etcd,omitempty"`
// +optional
Delete *Delete `json:"delete,omitempty" yaml:"delete,omitempty"`
// +optional
Maintenance *Maintenance `json:"maintenance,omitempty" yaml:"maintenance,omitempty"`
}

type EtcdStorage struct {
Expand Down Expand Up @@ -120,6 +122,15 @@ type Delete struct {
Enabled bool `json:"enabled" yaml:"enabled"`
}

// Maintenance ReadOnly enabled set to true, clients will not be allowed to write to the registry.
type Maintenance struct {
ReadOnly ReadOnly `json:"readonly" yaml:"readonly"`
}

type ReadOnly struct {
Enabled bool `json:"enabled" yaml:"enabled"`
}

type Security struct {
TokenPrivateKeyFile string `json:"tokenPrivateKeyFile" yaml:"tokenPrivateKeyFile"`
TokenPublicKeyFile string `json:"tokenPublicKeyFile" yaml:"tokenPublicKeyFile"`
Expand Down
66 changes: 66 additions & 0 deletions pkg/registry/apis/config/v1/zz_generated.conversion.go

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

38 changes: 38 additions & 0 deletions pkg/registry/apis/config/v1/zz_generated.deepcopy.go

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

38 changes: 38 additions & 0 deletions pkg/registry/apis/config/zz_generated.deepcopy.go

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

5 changes: 5 additions & 0 deletions pkg/registry/distribution/distribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,10 @@ func buildStorageConfiguration(opts *Options) map[string]configuration.Parameter
deleteDriver["enabled"] = storageCfg.Delete.Enabled
storage["delete"] = deleteDriver
}
if storageCfg.Maintenance != nil {
storage["maintenance"] = configuration.Parameters{
"readonly": map[interface{}]interface{}{"enabled": storageCfg.Maintenance.ReadOnly.Enabled},
}
}
return storage
}

0 comments on commit b24b841

Please sign in to comment.