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

fix: change local artifact validation logic from tag to if blocks #183

Merged
merged 5 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions cmd/gtctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,11 @@ func NewRootCommand() *cobra.Command {
)

cmd := &cobra.Command{
Use: "gtctl",
Short: "gtctl is a command-line tool for managing GreptimeDB cluster.",
Long: fmt.Sprintf("%s\ngtctl is a command-line tool for managing GreptimeDB cluster.", GtctlTextBanner),
Version: version.Get().String(),
SilenceUsage: true,
SilenceErrors: true,
shawnh2 marked this conversation as resolved.
Show resolved Hide resolved
Use: "gtctl",
Short: "gtctl is a command-line tool for managing GreptimeDB cluster.",
Long: fmt.Sprintf("%s\ngtctl is a command-line tool for managing GreptimeDB cluster.", GtctlTextBanner),
Version: version.Get().String(),
SilenceUsage: true,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
type verboser interface {
SetVerbosity(log.Level)
Expand Down
10 changes: 10 additions & 0 deletions pkg/cluster/baremetal/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ func (c *Cluster) createCluster(ctx context.Context, options *opt.CreateOptions)
if c.config.Cluster.Artifact != nil {
if c.config.Cluster.Artifact.Local != "" {
binPath = c.config.Cluster.Artifact.Local

// Ensure the binary path exists.
if exist, _ := fileutils.IsFileExists(binPath); !exist {
return fmt.Errorf("greptimedb cluster artifact '%s' is not exist", binPath)
}
} else {
src, err := c.am.NewSource(artifacts.GreptimeBinName, c.config.Cluster.Artifact.Version,
artifacts.ArtifactTypeBinary, clusterOpt.UseGreptimeCNArtifacts)
Expand Down Expand Up @@ -124,6 +129,11 @@ func (c *Cluster) createEtcdCluster(ctx context.Context, options *opt.CreateOpti
if c.config.Etcd.Artifact != nil {
if c.config.Etcd.Artifact.Local != "" {
binPath = c.config.Etcd.Artifact.Local

// Ensure the binary path exists.
if exist, _ := fileutils.IsFileExists(binPath); !exist {
return fmt.Errorf("etcd artifact '%s' is not exist", binPath)
}
} else {
src, err := c.am.NewSource(artifacts.EtcdBinName, c.config.Etcd.Artifact.Version,
artifacts.ArtifactTypeBinary, etcdOpt.UseGreptimeCNArtifacts)
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/baremetal.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type BareMetalClusterComponentsConfig struct {

type Artifact struct {
// Local is the local path of binary(greptime or etcd).
Local string `yaml:"local" validate:"omitempty,file"`
Local string `yaml:"local" validate:"omitempty,filepath"`

// Version is the release version of binary(greptime or etcd).
// Usually, it points to the version of binary of GitHub release.
Expand Down
Loading