-
Notifications
You must be signed in to change notification settings - Fork 397
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
Add apps detect command #1227
base: main
Are you sure you want to change the base?
Add apps detect command #1227
Conversation
85e768c
to
367baac
Compare
367baac
to
8bdde7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good so far, left a first round of comments inline. We don't have to do it as part of this PR but we should consider integrating with the new commands/charm
library for interactive elements
|
||
appSpec.Name = name | ||
var funcSpecArray []*godo.AppFunctionsSpec | ||
for _, component := range resp.Components { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should add a warning message stating other component types are not yet supported if we encounter them in the spec.
// output is global flag | ||
detect := CmdBuilder(cmd, | ||
RunAppsDetect, "detect", "Detect functions", "Detect functions project and convert it into apps project by adding the AppSpec.", Writer, aliasOpt("dt")) | ||
AddStringFlag(detect, doctl.ArgProjectSource, "", "", `Project source.`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should check if we are currently in a git project directory and attempt to default to that source repo.
@@ -119,6 +121,86 @@ func (s *appsService) Delete(appID string) error { | |||
return err | |||
} | |||
|
|||
func (s *appsService) Detect(source string, sha string, name string, branch string, autoDeploy bool) (*godo.AppSpec, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should consider changing this signature to only inline required parameters and put the rest in an options struct. e.g.:
type DetectOpts struct {
Name string // random name generated by default
Sha string // latest sha in branch by default
AutoDeploy bool // False by default
}
func (s *appsService) Detect(source, branch string, opts DetectOpts) (*godo.AppSpec, error) {
if err != nil { | ||
return err | ||
} | ||
if len(c.Args) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need argument parsing here if we are including auto-deploy
as a flag as well.
} | ||
|
||
switch Output { | ||
case "json": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should support YAML here as well
e.SetIndent("", " ") | ||
return e.Encode(spec) | ||
case "text": | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(assuming this is just not implemented yet) just a reminder to either error out if not supported or implemented output support
Co-authored-by: Nick Tate <[email protected]>
Co-authored-by: Nick Tate <[email protected]>
Co-authored-by: Nick Tate <[email protected]>
This PR has been de-prioritized and will receive the necessary attention when capacity is allotted. |
The PR adds a sub-command
Detect
under apps. The command allows to import of a functions project and returns the AppSpec for that project.Later then AppSpec can be used to create an Apps project.