Skip to content
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
2 changes: 1 addition & 1 deletion internal/cmd/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func NewCmdAuth(f *cmdutil.Factory) *cobra.Command {
cmd.AddCommand(authLoginCmd.NewCmdLogin(f))
cmd.AddCommand(authLogoutCmd.NewCmdLogout(f))
cmd.AddCommand(authStatusCmd.NewCmdStatus(f))
//cmd.AddCommand(authTokenCmd.NewCmdToken(f, nil))
// cmd.AddCommand(authTokenCmd.NewCmdToken(f, nil))

return cmd
}
3 changes: 1 addition & 2 deletions internal/cmd/auth/logout/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"github.com/zeabur/cli/internal/cmdutil"
)

type logoutOptions struct {
}
type logoutOptions struct{}

func NewCmdLogout(f *cmdutil.Factory) *cobra.Command {
opts := &logoutOptions{}
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/context/clear/clear.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"github.com/zeabur/cli/internal/cmdutil"
)

type Options struct {
}
type Options struct{}

func NewCmdClear(f *cmdutil.Factory) *cobra.Command {
opts := &Options{}
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/context/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"github.com/zeabur/cli/internal/cmdutil"
)

type Options struct {
}
type Options struct{}

func NewCmdGet(f *cmdutil.Factory) *cobra.Command {
opts := &Options{}
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/deployment/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type Options struct {
//todo: support service name
// todo: support service name
serviceID string
serviceName string
environmentID string
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/project/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package get
import (
"context"
"fmt"

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

Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/project/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ package list

import (
"context"

"github.com/spf13/cobra"

"github.com/zeabur/cli/internal/cmdutil"
)

type Options struct {
}
type Options struct{}

func NewCmdList(f *cmdutil.Factory) *cobra.Command {
opts := Options{}
Expand Down
1 change: 1 addition & 0 deletions internal/cmd/service/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package list
import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/internal/util"
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/template/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func runDelete(f *cmdutil.Factory, opts Options) error {
return runDeleteInteractive(f, opts)
}
return runDeleteNonInteractive(f, opts)

}

func runDeleteInteractive(f *cmdutil.Factory, opts Options) error {
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/template/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func runGet(f *cmdutil.Factory, opts Options) error {
return runGetInteractive(f, opts)
}
return runGetNonInteractive(f, opts)

}

func runGetInteractive(f *cmdutil.Factory, opts Options) error {
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/template/list/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"github.com/zeabur/cli/internal/cmdutil"
)

type Options struct {
}
type Options struct{}

func NewCmdList(f *cmdutil.Factory) *cobra.Command {
opts := Options{}
Expand Down
3 changes: 1 addition & 2 deletions internal/cmd/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import (
"github.com/zeabur/cli/pkg/constant"
)

type Options struct {
}
type Options struct{}

func NewCmdUpload(f *cmdutil.Factory) *cobra.Command {
opts := &Options{}
Expand Down
3 changes: 2 additions & 1 deletion internal/cmdutil/constants.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package cmdutil

import (
"time"

"github.com/briandowns/spinner"
"github.com/fatih/color"
"time"
)

var (
Expand Down
1 change: 0 additions & 1 deletion internal/util/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func PackZipWithoutGitIgnoreFiles() ([]byte, error) {

return nil
})

if err != nil {
return nil, err
}
Expand Down
1 change: 1 addition & 0 deletions internal/util/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package util
import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/pkg/api"
"github.com/zeabur/cli/pkg/config"
Expand Down
1 change: 1 addition & 0 deletions internal/util/runE.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package util

import (
"errors"

"github.com/spf13/cobra"
"github.com/zeabur/cli/internal/cmdutil"
"github.com/zeabur/cli/pkg/zcontext"
Expand Down
1 change: 1 addition & 0 deletions internal/util/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package util
import (
"context"
"fmt"

"github.com/spf13/cobra"
"github.com/zeabur/cli/pkg/api"
"github.com/zeabur/cli/pkg/config"
Expand Down
25 changes: 15 additions & 10 deletions pkg/api/deploymrnt.go → pkg/api/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,22 @@ package api

import (
"context"

"github.com/zeabur/cli/pkg/model"
)

func (c *client) ListDeployments(ctx context.Context, serviceID string, environmentID string, skip, limit int) (*model.Connection[model.Deployment], error) {
skip, limit = normalizePagination(skip, limit)
func (c *client) ListDeployments(ctx context.Context, serviceID string, environmentID string, perPage int) (*model.DeploymentConnection, error) {
_, perPage = normalizePagination(0, perPage)

var query struct {
Deployments model.Connection[model.Deployment] `graphql:"deployments(serviceID: $serviceID, environmentID: $environmentID, skip: $skip, limit: $limit)"`
Deployments model.DeploymentConnection `graphql:"deployments(serviceID: $serviceID, environmentID: $environmentID, perPage: $perPage)"`
}

err := c.Query(ctx, &query, V{
"serviceID": ObjectID(serviceID),
"environmentID": ObjectID(environmentID),
"skip": skip,
"limit": limit,
"perPage": perPage,
})

if err != nil {
return nil, err
}
Expand All @@ -27,11 +26,17 @@ func (c *client) ListDeployments(ctx context.Context, serviceID string, environm
}

func (c *client) ListAllDeployments(ctx context.Context, serviceID string, environmentID string) (model.Deployments, error) {
query := func(skip, limit int) (*model.Connection[model.Deployment], error) {
return c.ListDeployments(ctx, serviceID, environmentID, skip, limit)
conn, err := c.ListDeployments(ctx, serviceID, environmentID, 5)
if err != nil {
return nil, err
}

deployments := make(model.Deployments, 0, len(conn.Edges))
for _, edge := range conn.Edges {
deployments = append(deployments, edge.Node)
}

return listAll(query)
return deployments, nil
}

func (c *client) GetDeployment(ctx context.Context, id string) (*model.Deployment, error) {
Expand All @@ -48,7 +53,7 @@ func (c *client) GetDeployment(ctx context.Context, id string) (*model.Deploymen
}

func (c *client) GetLatestDeployment(ctx context.Context, serviceID string, environmentID string) (*model.Deployment, bool, error) {
deployments, err := c.ListDeployments(ctx, serviceID, environmentID, 0, 1)
deployments, err := c.ListDeployments(ctx, serviceID, environmentID, 1)
if err != nil {
return nil, false, err
}
Expand Down
5 changes: 0 additions & 5 deletions pkg/api/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func (c *client) AddDomain(ctx context.Context, serviceID string, environmentID
"domain": domain,
"redirectTo": options[0],
})

if err != nil {
return nil, err
}
Expand All @@ -43,7 +42,6 @@ func (c *client) AddDomain(ctx context.Context, serviceID string, environmentID
"isGenerated": isGenerated,
"domain": domain,
})

if err != nil {
return nil, err
}
Expand All @@ -62,7 +60,6 @@ func (c *client) ListDomains(ctx context.Context, serviceID string, environmentI
"environmentID": ObjectID(environmentID),
"id": ObjectID(serviceID),
})

if err != nil {
return nil, err
}
Expand All @@ -78,7 +75,6 @@ func (c *client) RemoveDomain(ctx context.Context, domain string) (bool, error)
err := c.Mutate(ctx, &mutation, V{
"domain": domain,
})

if err != nil {
return false, err
}
Expand All @@ -99,7 +95,6 @@ func (c *client) CheckDomainAvailable(ctx context.Context, domain string, isGene
"isGenerated": isGenerated,
"region": region,
})

if err != nil {
return false, "", err
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ func (c *client) ListEnvironments(ctx context.Context, projectID string) (model.
err := c.Query(ctx, &query, V{
"projectID": ObjectID(projectID),
})

if err != nil {
return nil, err
}
Expand All @@ -30,7 +29,6 @@ func (c *client) GetEnvironment(ctx context.Context, id string) (*model.Environm
err := c.Query(ctx, &query, V{
"id": ObjectID(id),
})

if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (c *client) GetRepoBranches(ctx context.Context, repoOwner string, repoName
}

func (c *client) GetRepoID(repoOwner string, repoName string) (int, error) {
//TODO: Deal with GitHub Auth, reading token env and set HTTP client header
// TODO: Deal with GitHub Auth, reading token env and set HTTP client header
client := github.NewClient(nil)

repo, _, err := client.Repositories.Get(context.Background(), repoOwner, repoName)
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ type (
}

DeploymentAPI interface {
ListDeployments(ctx context.Context, serviceID string, environmentID string, skip, limit int) (*model.Connection[model.Deployment], error)
ListDeployments(ctx context.Context, serviceID string, environmentID string, perPage int) (*model.DeploymentConnection, error)
ListAllDeployments(ctx context.Context, serviceID string, environmentID string) (model.Deployments, error)
GetDeployment(ctx context.Context, id string) (*model.Deployment, error)
GetLatestDeployment(ctx context.Context, serviceID string, environmentID string) (*model.Deployment, bool, error)
Expand Down
2 changes: 0 additions & 2 deletions pkg/api/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ func (c *client) getRuntimeLogsByServiceIDAndEnvironmentID(ctx context.Context,
"serviceID": ObjectID(serviceID),
"environmentID": ObjectID(environmentID),
})

if err != nil {
return nil, err
}
Expand All @@ -63,7 +62,6 @@ func (c *client) GetBuildLogs(ctx context.Context, deploymentID string) (model.L
err := c.Query(ctx, &query, V{
"deploymentID": ObjectID(deploymentID),
})

if err != nil {
return nil, err
}
Expand Down
6 changes: 2 additions & 4 deletions pkg/api/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func (c *client) getProjectByID(ctx context.Context, id string) (*model.Project,
err := c.Query(ctx, &query, V{
"id": ObjectID(id),
})

if err != nil {
return nil, err
}
Expand All @@ -94,7 +93,8 @@ func (c *client) getProjectByID(ctx context.Context, id string) (*model.Project,
}

func (c *client) getProjectByOwnerUsernameAndProject(ctx context.Context,
ownerUsername string, projectName string) (*model.Project, error) {
ownerUsername string, projectName string,
) (*model.Project, error) {
var query struct {
Project model.Project `graphql:"project(owner: $owner, name: $name)"`
}
Expand All @@ -103,7 +103,6 @@ func (c *client) getProjectByOwnerUsernameAndProject(ctx context.Context,
"owner": ownerUsername,
"name": projectName,
})

if err != nil {
return nil, err
}
Expand Down Expand Up @@ -137,7 +136,6 @@ func (c *client) DeleteProject(ctx context.Context, id string) error {
err := c.Mutate(ctx, &mutation, V{
"id": ObjectID(id),
})

if err != nil {
return err
}
Expand Down
Loading
Loading