Skip to content

Commit

Permalink
small updates/fixed unit test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zackbradys committed Aug 24, 2024
1 parent c32ca71 commit 9bbbc5b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ airgap-scp.sh
dist/
tmp/
bin/
/store/
/registry/
store/
registry/
fileserver/
cmd/hauler/binaries
2 changes: 2 additions & 0 deletions internal/flags/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ type InfoOpts struct {
OutputFormat string
TypeFilter string
SizeUnit string
ListRepos bool
}

func (o *InfoOpts) AddFlags(cmd *cobra.Command) {
f := cmd.Flags()

f.StringVarP(&o.OutputFormat, "output", "o", "table", "Output format (table, json)")
f.StringVarP(&o.TypeFilter, "type", "t", "all", "Filter on type (image, chart, file, sigs, atts, sbom)")
f.BoolVar(&o.ListRepos, "list-repos", false, "List all repository names")

// TODO: Regex/globbing
}
33 changes: 16 additions & 17 deletions internal/flags/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ type ServeRegistryOpts struct {
ConfigFile string
ReadOnly bool

TLSKey string
TLSCert string
TLSKey string
}

func (o *ServeRegistryOpts) AddFlags(cmd *cobra.Command) {
f := cmd.Flags()

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.")
f.IntVarP(&o.Port, "port", "p", 5000, "Port used to accept incoming connections")
f.StringVar(&o.RootDir, "directory", "registry", "Directory to use for backend. Defaults to $PWD/registry")
f.StringVarP(&o.ConfigFile, "config", "c", "", "Path to config file, overrides all other flags")
f.BoolVar(&o.ReadOnly, "readonly", true, "Run the registry as readonly")

f.StringVar(&o.TLSKey, "tls-key", "", "TLS key file location.")
f.StringVar(&o.TLSCert, "tls-cert", "", "TLS cert file location.")
f.StringVar(&o.TLSCert, "tls-cert", "", "Location of the TLS Certificate")
f.StringVar(&o.TLSKey, "tls-key", "", "Location of the TLS Key")

cmd.MarkFlagsRequiredTogether("tls-cert", "tls-key")
}
Expand All @@ -51,15 +51,14 @@ func (o *ServeRegistryOpts) DefaultRegistryConfig() *configuration.Configuration
cfg.HTTP.TLS.Key = o.TLSKey
}

// Add validation configuration
cfg.Validation.Manifests.URLs.Allow = []string{".+"}

cfg.Log.Level = "info"
cfg.HTTP.Addr = fmt.Sprintf(":%d", o.Port)
cfg.HTTP.Headers = http.Header{
"X-Content-Type-Options": []string{"nosniff"},
}

cfg.Log.Level = "info"
cfg.Validation.Manifests.URLs.Allow = []string{".+"}

return cfg
}

Expand All @@ -70,19 +69,19 @@ type ServeFilesOpts struct {
Timeout int
RootDir string

TLSKey string
TLSCert string
TLSKey string
}

func (o *ServeFilesOpts) AddFlags(cmd *cobra.Command) {
f := cmd.Flags()

f.IntVarP(&o.Port, "port", "p", 8080, "Port to listen on.")
f.IntVarP(&o.Timeout, "timeout", "t", 60, "Set the http request timeout duration in seconds for both reads and write.")
f.StringVar(&o.RootDir, "directory", "fileserver", "Directory to use for backend. Defaults to $PWD/fileserver")
f.IntVarP(&o.Port, "port", "p", 8080, "Port used to accept incoming connections")
f.IntVarP(&o.Timeout, "timeout", "t", 60, "Timeout duration for HTTP Requests in seconds for both reads/writes")
f.StringVar(&o.RootDir, "directory", "fileserver", "Directory to use for backend. Defaults to $PWD/fileserver")

f.StringVar(&o.TLSKey, "tls-key", "", "TLS key file location.")
f.StringVar(&o.TLSCert, "tls-cert", "", "TLS cert file location.")
f.StringVar(&o.TLSCert, "tls-cert", "", "Location of the TLS Certificate")
f.StringVar(&o.TLSKey, "tls-key", "", "Location of the TLS Key")

cmd.MarkFlagsRequiredTogether("tls-cert", "tls-key")
}

0 comments on commit 9bbbc5b

Please sign in to comment.