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
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/OctopusDeploy/cli

go 1.23.12
go 1.25.4

require (
github.com/AlecAivazis/survey/v2 v2.3.7
Expand All @@ -21,7 +21,7 @@ require (
github.com/spf13/viper v1.14.0
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20230129154200-a960b3787bd2
golang.org/x/term v0.34.0
golang.org/x/term v0.37.0
)

require (
Expand Down Expand Up @@ -53,10 +53,10 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.4.1 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/net v0.43.0 // indirect
golang.org/x/sys v0.35.0 // indirect
golang.org/x/text v0.28.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -349,6 +351,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -413,10 +417,14 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand All @@ -427,6 +435,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
Expand Down
6 changes: 2 additions & 4 deletions pkg/apiclient/client_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,11 @@ func ValidateMandatoryEnvironment(host string, apiKey string, accessToken string

if isInteractive {
err := GetInteractiveMandatoryEnvironmentErrorMessage()

return fmt.Errorf(err)
return errors.New(err)
}

err := GetNonInteractiveMandatoryEnvironmentErrorMessage()

return fmt.Errorf(err)
return errors.New(err)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/project/variables/exclude/exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ func excludeRun(opts *ExcludeOptions) error {
}

if !util.SliceContainsAny(project.IncludedLibraryVariableSets, func(item string) bool { return item == targetVariableSet[0].ID }) {
fmt.Fprintf(opts.Out, output.Yellowf("'%s' is not currently included, skipping\n", targetVariableSet[0].Name))
fmt.Fprint(opts.Out, output.Yellowf("'%s' is not currently included, skipping\n", targetVariableSet[0].Name))
} else {
project.IncludedLibraryVariableSets = util.SliceFilter(project.IncludedLibraryVariableSets, func(id string) bool { return id != targetVariableSet[0].ID })
projectModified = true
fmt.Fprintf(opts.Out, output.Cyanf("Removing '%s' library variable set\n", targetVariableSet[0].Name))
fmt.Fprint(opts.Out, output.Cyanf("Removing '%s' library variable set\n", targetVariableSet[0].Name))
}
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/project/variables/include/include.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ func includeRun(opts *IncludeOptions) error {
}

if util.SliceContainsAny(project.IncludedLibraryVariableSets, func(item string) bool { return item == targetVariableSet[0].ID }) {
fmt.Fprintf(opts.Out, output.Yellowf("'%s' is already included, skipping\n", targetVariableSet[0].Name))
fmt.Fprint(opts.Out, output.Yellowf("'%s' is already included, skipping\n", targetVariableSet[0].Name))
} else {
project.IncludedLibraryVariableSets = append(project.IncludedLibraryVariableSets, targetVariableSet[0].ID)
projectModified = true
fmt.Fprintf(opts.Out, output.Cyanf("Including '%s' library variable set\n", targetVariableSet[0].Name))
fmt.Fprint(opts.Out, output.Cyanf("Including '%s' library variable set\n", targetVariableSet[0].Name))
}
}

Expand Down
23 changes: 12 additions & 11 deletions pkg/cmd/projectgroup/view/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package view

import (
"fmt"
"github.com/OctopusDeploy/cli/pkg/apiclient"
"io"
"strings"

"github.com/OctopusDeploy/cli/pkg/apiclient"

"github.com/MakeNowJust/heredoc/v2"
"github.com/OctopusDeploy/cli/pkg/constants"
"github.com/OctopusDeploy/cli/pkg/factory"
Expand Down Expand Up @@ -100,7 +101,7 @@ func viewRun(opts *ViewOptions) error {
Slug: project.Slug,
})
}

return ProjectGroupAsJson{
Id: pg.GetID(),
Name: pg.GetName(),
Expand All @@ -116,9 +117,9 @@ func viewRun(opts *ViewOptions) error {
if description == "" {
description = constants.NoDescription
}

url := util.GenerateWebURL(opts.Host, pg.SpaceID, fmt.Sprintf("projects?projectGroupId=%s", pg.GetID()))

return []string{
output.Bold(pg.GetName()),
description,
Expand Down Expand Up @@ -149,30 +150,30 @@ type ProjectGroupAsJson struct {

func formatProjectGroupForBasic(opts *ViewOptions, projectGroup *projectgroups.ProjectGroup, projects []*projects.Project) string {
var result strings.Builder

// header
result.WriteString(fmt.Sprintf("%s %s\n", output.Bold(projectGroup.GetName()), output.Dimf("(%s)", projectGroup.GetID())))

// description
if projectGroup.Description == "" {
result.WriteString(fmt.Sprintln(output.Dim(constants.NoDescription)))
} else {
result.WriteString(fmt.Sprintln(output.Dim(projectGroup.Description)))
}

// projects
result.WriteString(fmt.Sprintf(output.Cyan("\nProjects:\n")))
result.WriteString(fmt.Sprint(output.Cyan("\nProjects:\n")))
for _, project := range projects {
result.WriteString(fmt.Sprintf("%s (%s)\n", output.Bold(project.GetName()), project.Slug))
}

// footer with web URL
url := util.GenerateWebURL(opts.Host, projectGroup.SpaceID, fmt.Sprintf("projects?projectGroupId=%s", projectGroup.GetID()))
result.WriteString(fmt.Sprintf("\nView this project group in Octopus Deploy: %s\n", output.Blue(url)))

if opts.flags.Web.Value {
browser.OpenURL(url)
}

return result.String()
}
5 changes: 3 additions & 2 deletions pkg/cmd/runbook/snapshot/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/json"
"errors"
"fmt"
"os"

"github.com/AlecAivazis/survey/v2"
"github.com/MakeNowJust/heredoc/v2"
"github.com/OctopusDeploy/cli/pkg/cmd"
Expand All @@ -24,7 +26,6 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/releases"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/runbooks"
"github.com/spf13/cobra"
"os"
)

const (
Expand Down Expand Up @@ -253,7 +254,7 @@ func createRun(opts *CreateOptions, outputFormat string) error {
if err != nil {
return err
}
fmt.Fprintf(opts.Out, string(data))
fmt.Fprint(opts.Out, string(data))
default:
if opts.Publish.Value {
_, _ = fmt.Fprintf(opts.Out, "\nSuccessfully created and published runbook snapshot '%s' (%s) for runbook '%s'\n", snapshot.Name, snapshot.GetID(), runbook.Name)
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/space/create/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package create_test

import (
"fmt"
"testing"

"github.com/OctopusDeploy/cli/pkg/cmd"
"github.com/OctopusDeploy/cli/pkg/cmd/space/create"
"github.com/OctopusDeploy/cli/pkg/output"
Expand All @@ -10,7 +12,6 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/teams"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/users"
"github.com/stretchr/testify/assert"
"testing"
)

func TestPromptMissing_AllOptionsSupplied(t *testing.T) {
Expand Down Expand Up @@ -80,7 +81,7 @@ func TestPromptMissing_NoOptionsSupplied(t *testing.T) {
}

func formatUser(user *users.User) string {
return fmt.Sprintf("%s (%s)", user.DisplayName, output.Dimf(user.Username))
return fmt.Sprintf("%s (%s)", user.DisplayName, output.Dim(user.Username))
}

func formatTeam(team *teams.Team) string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/gitresources/gitResources.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ outerLoop:
case "y": // YES these are the git resources they want
break outerLoop
case "?": // help text
_, _ = fmt.Fprintf(stdout, output.FormatDoc(gitResourceGitRefLoopHelpText))
_, _ = fmt.Fprint(stdout, output.FormatDoc(gitResourceGitRefLoopHelpText))
case "u": // undo!
if len(overriddenGitResourceGitRefs) > 0 {
//strip the last override from the list
Expand Down
5 changes: 3 additions & 2 deletions pkg/machinescommon/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package machinescommon

import (
"fmt"
"io"

"github.com/OctopusDeploy/cli/pkg/cmd"
"github.com/OctopusDeploy/cli/pkg/output"
"github.com/OctopusDeploy/cli/pkg/util"
Expand All @@ -10,7 +12,6 @@ import (
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/workerpools"
"github.com/pkg/browser"
"github.com/spf13/cobra"
"io"
)

const (
Expand Down Expand Up @@ -47,7 +48,7 @@ func DoWebForWorkerPools(workerPool workerpools.IWorkerPool, dependencies *cmd.D
}

func doWeb(url string, description string, out io.Writer, flags *WebFlags) {
link := output.Bluef(url)
link := output.Blue(url)
fmt.Fprintf(out, "View this %s on Octopus Deploy: %s\n", description, link)
if flags.Web.Value {
browser.OpenURL(url)
Expand Down
2 changes: 1 addition & 1 deletion pkg/packages/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ outerLoop:
case "y": // YES these are the packages they want
break outerLoop
case "?": // help text
_, _ = fmt.Fprintf(stdout, output.FormatDoc(packageOverrideLoopHelpText))
_, _ = fmt.Fprint(stdout, output.FormatDoc(packageOverrideLoopHelpText))
case "u": // undo!
if len(packageVersionOverrides) > 0 {
packageVersionOverrides = packageVersionOverrides[:len(packageVersionOverrides)-1]
Expand Down
3 changes: 2 additions & 1 deletion test/integration/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package integration_test

import (
"encoding/json"
"testing"

"github.com/MakeNowJust/heredoc/v2"
"github.com/stretchr/testify/require"
"testing"

"github.com/OctopusDeploy/cli/test/integration"
"github.com/OctopusDeploy/cli/test/testutil"
Expand Down
4 changes: 2 additions & 2 deletions test/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func AssertSuccess(t *testing.T, err error, args ...any) bool {
for _, arg := range args {
t.Log(arg)
}
t.Errorf(err.Error())
t.Error(err.Error())
debug.PrintStack()

return false
Expand All @@ -34,7 +34,7 @@ func RequireSuccess(t *testing.T, err error, args ...any) bool {
t.Log(arg)
}
debug.PrintStack()
t.Fatalf(err.Error())
t.Fatal(err.Error())
return false
}
return true
Expand Down