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

feat: project create #115

Merged
merged 29 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f3e7fca
basic working project create
benPearce1 Oct 7, 2022
c283bde
project create with lifecycle and group prompts
benPearce1 Oct 10, 2022
9653db3
project create initial integration tests
benPearce1 Oct 10, 2022
88b416b
skip select if there is only one option
benPearce1 Oct 10, 2022
98d10ca
feat: nested commands (#109)
domenicsim1 Oct 11, 2022
f0a5a76
Merge branch 'bp/project-create' of https://github.com/OctopusDeploy/…
benPearce1 Oct 11, 2022
5f50b52
working project vcs config
benPearce1 Oct 11, 2022
d55ff9b
cac support with project stored credentials
benPearce1 Oct 13, 2022
16acf77
chore: code refactor and testing changes
domenicsim1 Oct 13, 2022
5a94d1f
prompt ordering
benPearce1 Oct 13, 2022
4d79676
Merge from 'main'
benPearce1 Oct 14, 2022
4085d57
fix/check-remaining-for-mock-asker (#114)
domenicsim1 Oct 14, 2022
b0311f2
move common ask name function
benPearce1 Oct 14, 2022
15f4428
tests for CaC questions
benPearce1 Oct 14, 2022
86c5baa
move funcs closer to where they are being used
benPearce1 Oct 14, 2022
c86ad72
use the helper method
benPearce1 Oct 14, 2022
5d97470
accident
benPearce1 Oct 14, 2022
b00c777
Add support for reference git credentials
benPearce1 Oct 17, 2022
086a0aa
missed automation on git base path
benPearce1 Oct 17, 2022
cf38f22
rename cac
benPearce1 Oct 17, 2022
a69591d
fixed up examples in doc
benPearce1 Oct 18, 2022
f79b8f7
update client reference
benPearce1 Oct 18, 2022
2c0d949
update indirect package references
benPearce1 Oct 18, 2022
57d6f46
missed flag
benPearce1 Oct 18, 2022
487aaa7
fixed up commit structure for no-prompt scenario
benPearce1 Oct 18, 2022
91a4f0c
use formatting commands rather than concatenation
benPearce1 Oct 18, 2022
3b5aa46
fix up tests
benPearce1 Oct 18, 2022
ec7cbd3
another test fix
benPearce1 Oct 18, 2022
2f2b6d2
remove redundant input constraint
benPearce1 Oct 19, 2022
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
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.19
require (
github.com/AlecAivazis/survey/v2 v2.3.5
github.com/MakeNowJust/heredoc/v2 v2.0.1
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.9.1
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.10.0
github.com/briandowns/spinner v1.19.0
github.com/google/uuid v1.3.0
github.com/hashicorp/go-multierror v1.1.1
Expand All @@ -28,7 +28,7 @@ require (
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
Expand All @@ -47,9 +47,9 @@ require (
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/subosito/gotenv v1.3.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/sys v0.0.0-20220731174439-a90be440212d // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/text v0.4.0 // indirect
gopkg.in/ini.v1 v1.66.4 // 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 @@ -48,6 +48,8 @@ github.com/OctopusDeploy/go-octopusdeploy/v2 v2.8.1 h1:jaMlQAeI93w/BlwUf5LNXXlm0
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.8.1/go.mod h1:XWqxyDUVElUlTaPqyCBblukpsHSnPcAKkAHgJgbsIAs=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.9.1 h1:rnG8B0t759J3en86aTSi9nZ/dv8VcNIz3s+iKWQxVrI=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.9.1/go.mod h1:XWqxyDUVElUlTaPqyCBblukpsHSnPcAKkAHgJgbsIAs=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.10.0 h1:DdKeV+JYaF5Z5fl+P1LTByuZXBj+tKy+1xEuiADs/JM=
github.com/OctopusDeploy/go-octopusdeploy/v2 v2.10.0/go.mod h1:l8uu7lnA1mz/JwW3pXflKqzxTrIDfl/0r5jWBjzywTs=
github.com/briandowns/spinner v1.19.0 h1:s8aq38H+Qju89yhp89b4iIiMzMm8YN3p6vGpwyh/a8E=
github.com/briandowns/spinner v1.19.0/go.mod h1:mQak9GHqbspjC/5iUx3qMlIho8xBS/ppAL/hX5SmPJU=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -90,6 +92,8 @@ github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/j
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw=
github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/go-playground/validator/v10 v10.11.1 h1:prmOlTVv+YjZjmRmNSF3VmspqJIxJWXmqUsHwfTRRkQ=
github.com/go-playground/validator/v10 v10.11.1/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -268,6 +272,8 @@ golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5y
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a h1:NmSIgad6KjE6VvHciPZuNRTKxGhlPfD6OA87W/PLkqg=
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
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 @@ -397,6 +403,8 @@ golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220731174439-a90be440212d h1:Sv5ogFZatcgIMMtBSTTAgMYsicp25MXBubjXNDKwm80=
golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
Expand All @@ -410,6 +418,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
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
57 changes: 57 additions & 0 deletions pkg/cmd/dependencies.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package cmd
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q for @domenicsim1
Given that this isn't a command itself, should it go under the cmd directory structure, or should it go under just pkg or pkg/somethingelse?

Copy link
Collaborator

@domenicsim1 domenicsim1 Oct 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe, although it is suppose to be the basis of cmds. Not sure yet, happy to leave it for now.


import (
"io"

"github.com/OctopusDeploy/cli/pkg/factory"
"github.com/OctopusDeploy/cli/pkg/question"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/spaces"
"github.com/spf13/cobra"
)

type Dependable interface {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely understand we're trying to fit within the patterns and idioms of golang... but Dependable is perhaps too vague. Does this mean it's never going to let us down? 🤣

Commit() error
GenerateAutomationCmd()
}

type Dependencies struct {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps Dependencies might be a bit of a vague name here? My immediate thought is "which dependencies does this struct represent? who depends on them and why?"

From a quick look, it appears as though this struct is meant to carry services (client, asker) and options (space, noprompt) that are commonly used across many commands? If so, some possible naming suggestions?

  • ServicesAndOptions
  • CommandContext
  • CliCommandContext
  • CommandCommonData
  • StandardCommandProperties
  • CommonCommandProperties
  • GeneralCommandProps

... something to think about anyway

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag @slewis74

Out io.Writer
Client *client.Client
Host string
Space *spaces.Space
NoPrompt bool
Ask question.Asker
CmdPath string
ShowMessagePrefix bool
}

func NewDependencies(f factory.Factory, cmd *cobra.Command) *Dependencies {
client, err := f.GetSpacedClient()
if err != nil {
panic(err)
}

return &Dependencies{
Ask: f.Ask,
CmdPath: cmd.CommandPath(),
Out: cmd.OutOrStdout(),
Client: client,
Host: f.GetCurrentHost(),
NoPrompt: !f.IsPromptEnabled(),
Space: f.GetCurrentSpace(),
}
}

func NewDependenciesFromExisting(opts *Dependencies, cmdPath string) *Dependencies {
return &Dependencies{
Ask: opts.Ask,
CmdPath: cmdPath,
Out: opts.Out,
Client: opts.Client,
Host: opts.Host,
NoPrompt: opts.NoPrompt,
Space: opts.Space,
ShowMessagePrefix: true,
}
}
Loading