mirror of
https://github.com/project-zot/zot.git
synced 2026-06-18 05:28:07 +08:00
build: add build tags to create customizable binaries
This commit is contained in:
@@ -3,10 +3,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"cli.go",
|
||||
"client.go",
|
||||
"config_cmd.go",
|
||||
"cve_cmd.go",
|
||||
"image_cmd.go",
|
||||
"minimal.go",
|
||||
"root.go",
|
||||
"searcher.go",
|
||||
"service.go",
|
||||
@@ -43,11 +45,13 @@ go_test(
|
||||
"//:exported_testdata",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
gotags = ["extended"],
|
||||
race = "on",
|
||||
deps = [
|
||||
"//errors:go_default_library",
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/compliance/v1_0_0:go_default_library",
|
||||
"//pkg/extensions:go_default_library",
|
||||
"@com_github_opencontainers_go_digest//:go_default_library",
|
||||
"@com_github_opencontainers_image_spec//specs-go/v1:go_default_library",
|
||||
"@com_github_smartystreets_goconvey//convey:go_default_library",
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func enableCli(rootCmd *cobra.Command) {
|
||||
rootCmd.AddCommand(NewConfigCommand())
|
||||
rootCmd.AddCommand(NewImageCommand(NewSearchService()))
|
||||
rootCmd.AddCommand(NewCveCommand(NewSearchService()))
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli //nolint:testpackage
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli //nolint:testpackage
|
||||
|
||||
import (
|
||||
@@ -15,6 +17,7 @@ import (
|
||||
|
||||
zotErrors "github.com/anuvu/zot/errors"
|
||||
"github.com/anuvu/zot/pkg/api"
|
||||
ext "github.com/anuvu/zot/pkg/extensions"
|
||||
"gopkg.in/resty.v1"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
@@ -301,13 +304,13 @@ func TestServerCVEResponse(t *testing.T) {
|
||||
defer os.RemoveAll(dir)
|
||||
|
||||
c.Config.Storage.RootDirectory = dir
|
||||
cveConfig := &api.CVEConfig{
|
||||
cveConfig := &ext.CVEConfig{
|
||||
UpdateInterval: 2,
|
||||
}
|
||||
searchConfig := &api.SearchConfig{
|
||||
searchConfig := &ext.SearchConfig{
|
||||
CVE: cveConfig,
|
||||
}
|
||||
c.Config.Extensions = &api.ExtensionConfig{
|
||||
c.Config.Extensions = &ext.ExtensionConfig{
|
||||
Search: searchConfig,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli //nolint:testpackage
|
||||
|
||||
import (
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// +build minimal
|
||||
|
||||
package cli
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
func enableCli(rootCmd *cobra.Command) {
|
||||
}
|
||||
+1
-3
@@ -97,9 +97,7 @@ func NewRootCmd() *cobra.Command {
|
||||
rootCmd.AddCommand(serveCmd)
|
||||
rootCmd.AddCommand(gcCmd)
|
||||
|
||||
rootCmd.AddCommand(NewConfigCommand())
|
||||
rootCmd.AddCommand(NewImageCommand(NewSearchService()))
|
||||
rootCmd.AddCommand(NewCveCommand(NewSearchService()))
|
||||
enableCli(rootCmd)
|
||||
|
||||
rootCmd.Flags().BoolVarP(&showVersion, "version", "v", false, "show the version and exit")
|
||||
|
||||
|
||||
+19
-17
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
@@ -331,6 +333,23 @@ func validateImageNameTag(input string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type spinnerState struct {
|
||||
spinner *spinner.Spinner
|
||||
enabled bool
|
||||
}
|
||||
|
||||
func (spinner *spinnerState) startSpinner() {
|
||||
if spinner.enabled {
|
||||
spinner.spinner.Start()
|
||||
}
|
||||
}
|
||||
|
||||
func (spinner *spinnerState) stopSpinner() {
|
||||
if spinner.enabled && spinner.spinner.Active() {
|
||||
spinner.spinner.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
type set struct {
|
||||
m map[string]struct{}
|
||||
}
|
||||
@@ -365,23 +384,6 @@ type stringResult struct {
|
||||
Err error
|
||||
}
|
||||
|
||||
type spinnerState struct {
|
||||
spinner *spinner.Spinner
|
||||
enabled bool
|
||||
}
|
||||
|
||||
func (spinner *spinnerState) startSpinner() {
|
||||
if spinner.enabled {
|
||||
spinner.spinner.Start()
|
||||
}
|
||||
}
|
||||
|
||||
func (spinner *spinnerState) stopSpinner() {
|
||||
if spinner.enabled && spinner.spinner.Active() {
|
||||
spinner.spinner.Stop()
|
||||
}
|
||||
}
|
||||
|
||||
type printHeader func(writer io.Writer)
|
||||
|
||||
func printImageTableHeader(writer io.Writer) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// +build extended
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
||||
Reference in New Issue
Block a user