Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add readonly flag #277

Merged
merged 8 commits into from
Jul 30, 2024
Merged
12 changes: 5 additions & 7 deletions cmd/hauler/cli/store/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ type ServeRegistryOpts struct {
Port int
RootDir string
ConfigFile string

storedir string
ReadOnly bool
}

func (o *ServeRegistryOpts) AddFlags(cmd *cobra.Command) {
Expand All @@ -35,6 +34,7 @@ func (o *ServeRegistryOpts) AddFlags(cmd *cobra.Command) {
f.IntVarP(&o.Port, "port", "p", 5000, "Port to listen on.")
f.StringVar(&o.RootDir, "directory", "registry", "Directory to use for backend. Defaults to $PWD/registry")
f.StringVarP(&o.ConfigFile, "config", "c", "", "Path to a config file, will override all other configs")
f.BoolVar(&o.ReadOnly, "readonly", true, "Run the registry as readonly.")
dweomer marked this conversation as resolved.
Show resolved Hide resolved
}

func ServeRegistryCmd(ctx context.Context, o *ServeRegistryOpts, s *store.Layout) error {
Expand Down Expand Up @@ -81,8 +81,6 @@ type ServeFilesOpts struct {
Port int
Timeout int
RootDir string

storedir string
}

func (o *ServeFilesOpts) AddFlags(cmd *cobra.Command) {
Expand Down Expand Up @@ -136,9 +134,9 @@ func (o *ServeRegistryOpts) defaultRegistryConfig() *configuration.Configuration
Storage: configuration.Storage{
"cache": configuration.Parameters{"blobdescriptor": "inmemory"},
"filesystem": configuration.Parameters{"rootdirectory": o.RootDir},

// TODO: Ensure this is toggleable via cli arg if necessary
// "maintenance": configuration.Parameters{"readonly.enabled": false},
"maintenance": configuration.Parameters{
"readonly": map[any]any{"enabled": o.ReadOnly},
},
},
}

Expand Down