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

repository: move v0manifest.Version to dedicate package #929

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (

"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/environment"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
"github.com/pingcap/tiup/pkg/repository/v1manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/tui"
"github.com/pingcap/tiup/pkg/version"
Expand Down Expand Up @@ -202,7 +202,7 @@ func showComponentVersions(env *environment.Environment, component string, opt l
for plat := range comp.Platforms {
versions := comp.VersionList(plat)
for ver, verinfo := range versions {
if v0manifest.Version(ver).IsNightly() && ver == comp.Nightly {
if pkgver.Version(ver).IsNightly() && ver == comp.Nightly {
platforms[version.NightlyVersion] = append(platforms[version.NightlyVersion], plat)
released[version.NightlyVersion] = verinfo.Released
} else {
Expand All @@ -213,7 +213,7 @@ func showComponentVersions(env *environment.Environment, component string, opt l
}
verList := []string{}
for v := range platforms {
if v0manifest.Version(v).IsNightly() {
if pkgver.Version(v).IsNightly() {
continue
}
verList = append(verList, v)
Expand Down
4 changes: 2 additions & 2 deletions cmd/mirror.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
"github.com/pingcap/tiup/pkg/repository"
"github.com/pingcap/tiup/pkg/repository/model"
ru "github.com/pingcap/tiup/pkg/repository/utils"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
"github.com/pingcap/tiup/pkg/repository/v1manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/utils"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -208,7 +208,7 @@ func newMirrorModifyCmd() *cobra.Command {
publishInfo.Yank = &yanked
}
} else if flagSet.Exist("yank") {
if v0manifest.Version(ver).IsNightly() {
if pkgver.Version(ver).IsNightly() {
return errors.New("nightly version can't be yanked")
}
for p := range m.Platforms {
Expand Down
4 changes: 2 additions & 2 deletions components/playground/grafana.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/pingcap/tiup/components/playground/instance"
"github.com/pingcap/tiup/pkg/environment"
tiupexec "github.com/pingcap/tiup/pkg/exec"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -205,7 +205,7 @@ http_port = %d
params := &tiupexec.PrepareCommandParams{
Ctx: ctx,
Component: "grafana",
Version: v0manifest.Version(g.version),
Version: pkgver.Version(g.version),
InstanceDir: dir,
WD: dir,
Args: args,
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/drainer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"path/filepath"
"strings"

"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -71,7 +71,7 @@ func (d *Drainer) NodeID() string {
}

// Start implements Instance interface.
func (d *Drainer) Start(ctx context.Context, version v0manifest.Version) error {
func (d *Drainer) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(d.Dir, 0755); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions components/playground/instance/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"context"
"fmt"

"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
)

// Config of the instance.
Expand All @@ -43,7 +43,7 @@ type Instance interface {
Pid() int
// Start the instance process.
// Will kill the process once the context is done.
Start(ctx context.Context, version v0manifest.Version) error
Start(ctx context.Context, version pkgver.Version) error
// Component Return the component name.
Component() string
// LogFile return the log file name
Expand All @@ -65,7 +65,7 @@ func (inst *instance) StatusAddrs() (addrs []string) {
}

// CompVersion return the format to run specified version of a component.
func CompVersion(comp string, version v0manifest.Version) string {
func CompVersion(comp string, version pkgver.Version) string {
if version.IsEmpty() {
return comp
}
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strings"

"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -66,7 +66,7 @@ func (inst *PDInstance) Name() string {
}

// Start calls set inst.cmd and Start
func (inst *PDInstance) Start(ctx context.Context, version v0manifest.Version) error {
func (inst *PDInstance) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(inst.Dir, 0755); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/environment"
tiupexec "github.com/pingcap/tiup/pkg/exec"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
)

// Process represent process to be run by playground
Expand Down Expand Up @@ -85,7 +85,7 @@ func (p *process) Cmd() *exec.Cmd {
}

// NewComponentProcess create a Process instance.
func NewComponentProcess(ctx context.Context, dir, binPath, component string, version v0manifest.Version, arg ...string) (Process, error) {
func NewComponentProcess(ctx context.Context, dir, binPath, component string, version pkgver.Version, arg ...string) (Process, error) {
if dir == "" {
panic("dir must be set")
}
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/pump.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"
"time"

"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -82,7 +82,7 @@ func (p *Pump) Addr() string {
}

// Start implements Instance interface.
func (p *Pump) Start(ctx context.Context, version v0manifest.Version) error {
func (p *Pump) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(p.Dir, 0755); err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions components/playground/instance/ticdc.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ package instance
import (
"context"
"fmt"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
"github.com/pingcap/tiup/pkg/utils"
"os"
"path/filepath"
"strings"

pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

// TiCDC represent a ticdc instance.
Expand Down Expand Up @@ -50,7 +51,7 @@ func NewTiCDC(binPath string, dir, host, configPath string, id int, pds []*PDIns
}

// Start implements Instance interface.
func (c *TiCDC) Start(ctx context.Context, version v0manifest.Version) error {
func (c *TiCDC) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(c.Dir, 0755); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/tidb.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"strconv"
"strings"

"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -51,7 +51,7 @@ func NewTiDBInstance(binPath string, dir, host, configPath string, id int, pds [
}

// Start calls set inst.cmd and Start
func (inst *TiDBInstance) Start(ctx context.Context, version v0manifest.Version) error {
func (inst *TiDBInstance) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(inst.Dir, 0755); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions components/playground/instance/tiflash.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/pingcap/tiup/pkg/cluster/api"
"github.com/pingcap/tiup/pkg/environment"
"github.com/pingcap/tiup/pkg/repository"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -98,7 +98,7 @@ func (inst *TiFlashInstance) StatusAddrs() (addrs []string) {
}

// Start calls set inst.cmd and Start
func (inst *TiFlashInstance) Start(ctx context.Context, version v0manifest.Version) error {
func (inst *TiFlashInstance) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(inst.Dir, 0755); err != nil {
return err
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func (inst *TiFlashInstance) StoreAddr() string {
return fmt.Sprintf("%s:%d", advertiseHost(inst.Host), inst.ServicePort)
}

func (inst *TiFlashInstance) checkConfig(deployDir, clusterManagerPath string, version v0manifest.Version, tidbStatusAddrs, endpoints []string) error {
func (inst *TiFlashInstance) checkConfig(deployDir, clusterManagerPath string, version pkgver.Version, tidbStatusAddrs, endpoints []string) error {
if inst.ConfigPath == "" {
inst.ConfigPath = path.Join(inst.Dir, "tiflash.toml")
}
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/tiflash_proxy_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"fmt"
"io"

"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"golang.org/x/mod/semver"
)

Expand Down Expand Up @@ -46,7 +46,7 @@ data-dir = "%[6]s"
max-open-files = 256
`

func writeTiFlashProxyConfig(w io.Writer, version v0manifest.Version, ip, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
func writeTiFlashProxyConfig(w io.Writer, version pkgver.Version, ip, deployDir string, servicePort, proxyPort, proxyStatusPort int) error {
// TODO: support multi-dir
dataDir := fmt.Sprintf("%s/flash", deployDir)
logDir := fmt.Sprintf("%s/log", deployDir)
Expand Down
4 changes: 2 additions & 2 deletions components/playground/instance/tikv.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"strings"

"github.com/pingcap/errors"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func (inst *TiKVInstance) Addr() string {
}

// Start calls set inst.cmd and Start
func (inst *TiKVInstance) Start(ctx context.Context, version v0manifest.Version) error {
func (inst *TiKVInstance) Start(ctx context.Context, version pkgver.Version) error {
if err := os.MkdirAll(inst.Dir, 0755); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions components/playground/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/pingcap/tiup/components/playground/instance"
"github.com/pingcap/tiup/pkg/environment"
tiupexec "github.com/pingcap/tiup/pkg/exec"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
)

Expand Down Expand Up @@ -142,7 +142,7 @@ scrape_configs:
params := &tiupexec.PrepareCommandParams{
Ctx: ctx,
Component: "prometheus",
Version: v0manifest.Version(version),
Version: pkgver.Version(version),
InstanceDir: dir,
WD: dir,
Args: args,
Expand Down
6 changes: 3 additions & 3 deletions components/playground/playground.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import (
"github.com/pingcap/tiup/pkg/cliutil/progress"
"github.com/pingcap/tiup/pkg/cluster/api"
"github.com/pingcap/tiup/pkg/environment"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/utils"
"golang.org/x/mod/semver"
"golang.org/x/sync/errgroup"
Expand Down Expand Up @@ -413,7 +413,7 @@ func (p *Playground) sanitizeComponentConfig(cid string, cfg *instance.Config) e

func (p *Playground) startInstance(ctx context.Context, inst instance.Instance) error {
fmt.Printf("Start %s instance\n", inst.Component())
err := inst.Start(ctx, v0manifest.Version(p.bootOptions.version))
err := inst.Start(ctx, pkgver.Version(p.bootOptions.version))
if err != nil {
return errors.AddStack(err)
}
Expand Down Expand Up @@ -1003,7 +1003,7 @@ func (p *Playground) bootGrafana(ctx context.Context, env *environment.Environme
if err := installIfMissing(env.Profile(), "grafana", options.version); err != nil {
return nil, errors.AddStack(err)
}
installPath, err := env.Profile().ComponentInstalledPath("grafana", v0manifest.Version(options.version))
installPath, err := env.Profile().ComponentInstalledPath("grafana", pkgver.Version(options.version))
if err != nil {
return nil, errors.AddStack(err)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/cluster/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import (
"github.com/pingcap/tiup/pkg/file"
"github.com/pingcap/tiup/pkg/logger/log"
"github.com/pingcap/tiup/pkg/meta"
"github.com/pingcap/tiup/pkg/repository/v0manifest"
pkgver "github.com/pingcap/tiup/pkg/repository/version"
"github.com/pingcap/tiup/pkg/set"
"github.com/pingcap/tiup/pkg/utils"
"github.com/pingcap/tiup/pkg/version"
Expand Down Expand Up @@ -1238,7 +1238,7 @@ func (m *Manager) Deploy(
switch inst.ComponentName() {
case spec.ComponentTiSpark:
env := environment.GlobalEnv()
var sparkVer v0manifest.Version
var sparkVer pkgver.Version
if sparkVer, _, iterErr = env.V1Repository().LatestStableVersion(spec.ComponentSpark, false); iterErr != nil {
return
}
Expand Down Expand Up @@ -2015,7 +2015,7 @@ func buildScaleOutTask(
switch inst.ComponentName() {
case spec.ComponentTiSpark:
env := environment.GlobalEnv()
var sparkVer v0manifest.Version
var sparkVer pkgver.Version
if sparkVer, _, iterErr = env.V1Repository().LatestStableVersion(spec.ComponentSpark, false); iterErr != nil {
return
}
Expand Down
Loading