Skip to content

Commit

Permalink
feat: update prebuilt service's image tag (`zeabur service update tag…
Browse files Browse the repository at this point in the history
…`) (#93)

<!-- Thank you for opening a PR! We really appreciate you taking the
time to help out 🙌 -->

#### Description (required)

<!-- Please describe the change you are proposing, and why -->

Update prebuilt service's image tag with CLI.

```
zeabur service update tag --id <SERVICE_ID> --env-id <ENV_ID> --tag latest
```

#### Related issues & labels (optional)

- Closes #<!-- Add an issue number if this PR will close it. -->
- Suggested label: <!-- Help us triage by suggesting one of our labels
that describes your PR -->
  • Loading branch information
yuaanlin authored Mar 22, 2024
2 parents 6da966f + ae024d1 commit fe5708d
Show file tree
Hide file tree
Showing 27 changed files with 494 additions and 43 deletions.
8 changes: 7 additions & 1 deletion internal/cmd/context/set/set.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ package set
import (
"context"
"fmt"

"github.com/MakeNowJust/heredoc"
"github.com/zeabur/cli/pkg/selector"

"github.com/spf13/cobra"

Expand Down Expand Up @@ -285,7 +287,11 @@ func selectService(f *cmdutil.Factory, opts *Options) error {

projectID := f.Config.GetContext().GetProject().GetID()

serviceInfo, _, err := f.Selector.SelectService(projectID, true)
serviceInfo, _, err := f.Selector.SelectService(selector.SelectServiceOptions{
ProjectID: projectID,
Auto: true,
CreateNew: true,
})
if err != nil {
return err
}
Expand Down
11 changes: 10 additions & 1 deletion internal/cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/model"
"github.com/zeabur/cli/pkg/selector"
"github.com/zeabur/cli/pkg/zcontext"
)

Expand Down Expand Up @@ -80,7 +82,14 @@ func runDeploy(f *cmdutil.Factory, opts *Options) error {

f.Log.Info("Select one service to deploy or create a new one.")

_, service, err := f.Selector.SelectService(project.ID, false)
_, service, err := f.Selector.SelectService(selector.SelectServiceOptions{
ProjectID: project.ID,
Auto: false,
CreateNew: true,
FilterFunc: func(service *model.Service) bool {
return service.Template == "GIT"
},
})
if err != nil {
return err
}
Expand Down
13 changes: 12 additions & 1 deletion internal/cmd/deployment/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"context"
"errors"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
"github.com/zeabur/cli/pkg/model"
)

Expand Down Expand Up @@ -51,7 +53,16 @@ func runGet(f *cmdutil.Factory, opts *Options) error {
func runGetInteractive(f *cmdutil.Factory, opts *Options) error {
if opts.deploymentID == "" {
zctx := f.Config.GetContext()
_, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.serviceID, &opts.serviceName, &opts.environmentID)
_, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.serviceID,
ServiceName: &opts.serviceName,
EnvironmentID: &opts.environmentID,
CreateNew: false,
FilterFunc: func(service *model.Service) bool {
return service.Template == "GIT"
},
})
if err != nil {
return err
}
Expand Down
14 changes: 13 additions & 1 deletion internal/cmd/deployment/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import (
"context"
"errors"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
"github.com/zeabur/cli/pkg/model"
)

type Options struct {
Expand Down Expand Up @@ -48,7 +51,16 @@ func runList(f *cmdutil.Factory, opts *Options) error {

func runListInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()
_, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.serviceID, &opts.serviceName, &opts.environmentID)
_, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.serviceID,
ServiceName: &opts.serviceName,
EnvironmentID: &opts.environmentID,
CreateNew: false,
FilterFunc: func(service *model.Service) bool {
return service.Template == "GIT"
},
})
if err != nil {
return err
}
Expand Down
12 changes: 11 additions & 1 deletion internal/cmd/deployment/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
"github.com/zeabur/cli/pkg/model"
)

Expand Down Expand Up @@ -62,7 +63,16 @@ func runLog(f *cmdutil.Factory, opts *Options) error {
func runLogInteractive(f *cmdutil.Factory, opts *Options) error {
if opts.deploymentID == "" {
zctx := f.Config.GetContext()
_, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.serviceID, &opts.serviceName, &opts.environmentID)
_, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.serviceID,
ServiceName: &opts.serviceName,
EnvironmentID: &opts.environmentID,
CreateNew: false,
FilterFunc: func(service *model.Service) bool {
return service.Template == "GIT"
},
})
if err != nil {
return err
}
Expand Down
18 changes: 16 additions & 2 deletions internal/cmd/domain/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package create
import (
"context"
"fmt"

"github.com/briandowns/spinner"
"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
)

type Options struct {
Expand Down Expand Up @@ -58,7 +60,13 @@ func runCreateDomain(f *cmdutil.Factory, opts *Options) error {
func runCreateDomainInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()

if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down Expand Up @@ -135,7 +143,13 @@ func runCreateDomainInteractive(f *cmdutil.Factory, opts *Options) error {
func runCreateDomainNonInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()

if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down
17 changes: 15 additions & 2 deletions internal/cmd/domain/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/briandowns/spinner"
"github.com/spf13/cobra"
"github.com/zeabur/cli/pkg/fill"

"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
Expand Down Expand Up @@ -57,7 +58,13 @@ func runDeleteDomain(f *cmdutil.Factory, opts *Options) error {
func runDeleteDomainInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()

if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down Expand Up @@ -107,7 +114,13 @@ func runDeleteDomainInteractive(f *cmdutil.Factory, opts *Options) error {
func runDeleteDomainNonInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()

if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down
17 changes: 15 additions & 2 deletions internal/cmd/domain/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/briandowns/spinner"
"github.com/spf13/cobra"
"github.com/zeabur/cli/pkg/fill"

"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
Expand Down Expand Up @@ -54,7 +55,13 @@ func runListDomains(f *cmdutil.Factory, opts *Options) error {
func runListDomainsInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()

if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand All @@ -64,7 +71,13 @@ func runListDomainsInteractive(f *cmdutil.Factory, opts *Options) error {
func runListDomainsNonInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()

if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down
11 changes: 9 additions & 2 deletions internal/cmd/service/expose/expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package expose
import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"

"github.com/zeabur/cli/internal/cmdutil"
)
Expand Down Expand Up @@ -74,8 +76,13 @@ func runExposeNonInteractive(f *cmdutil.Factory, opts *Options) error {
}

func runExposeInteractive(f *cmdutil.Factory, opts *Options) error {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(
f.Config.GetContext(), &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: f.Config.GetContext(),
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down
8 changes: 7 additions & 1 deletion internal/cmd/service/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package get
import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/api"
"github.com/zeabur/cli/pkg/fill"
"github.com/zeabur/cli/pkg/model"

"github.com/zeabur/cli/internal/cmdutil"
Expand Down Expand Up @@ -50,7 +52,11 @@ func runGet(f *cmdutil.Factory, opts *Options) error {
}

func runGetInteractive(f *cmdutil.Factory, opts *Options) error {
if _, err := f.ParamFiller.ServiceByName(f.Config.GetContext(), &opts.id, &opts.name); err != nil {
if _, err := f.ParamFiller.ServiceByName(fill.ServiceByNameOptions{
ProjectCtx: f.Config.GetContext(),
ServiceID: &opts.id,
ServiceName: &opts.name,
}); err != nil {
return err
}

Expand Down
13 changes: 12 additions & 1 deletion internal/cmd/service/instruction/instruction.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
"github.com/zeabur/cli/pkg/model"
)

type Options struct {
Expand Down Expand Up @@ -42,7 +44,16 @@ func NewCmdInstruction(f *cmdutil.Factory) *cobra.Command {

func runInstruction(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
FilterFunc: func(service *model.Service) bool {
return service.Template == "PREBUILT"
},
}); err != nil {
return err
}

Expand Down
9 changes: 8 additions & 1 deletion internal/cmd/service/metric/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
"github.com/zeabur/cli/pkg/model"
)

Expand Down Expand Up @@ -64,7 +65,13 @@ func runMetric(f *cmdutil.Factory, opts *Options) error {

func runMetricInteractive(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down
12 changes: 10 additions & 2 deletions internal/cmd/service/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ package network
import (
"context"
"fmt"

"github.com/briandowns/spinner"
"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
"github.com/zeabur/cli/pkg/fill"
)

type Options struct {
Expand Down Expand Up @@ -43,7 +45,13 @@ func NewCmdPrivateNetwork(f *cmdutil.Factory) *cobra.Command {

func runInstruction(f *cmdutil.Factory, opts *Options) error {
zctx := f.Config.GetContext()
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(zctx, &opts.id, &opts.name, &opts.environmentID); err != nil {
if _, err := f.ParamFiller.ServiceByNameWithEnvironment(fill.ServiceByNameWithEnvironmentOptions{
ProjectCtx: zctx,
ServiceID: &opts.id,
ServiceName: &opts.name,
EnvironmentID: &opts.environmentID,
CreateNew: false,
}); err != nil {
return err
}

Expand Down Expand Up @@ -72,7 +80,7 @@ func runInstruction(f *cmdutil.Factory, opts *Options) error {
}

s.Stop()

f.Log.Infof("Private DNS name for %s: %s", opts.name, dnsName+".zeabur.internal")

return nil
Expand Down
Loading

0 comments on commit fe5708d

Please sign in to comment.