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

Add retrieve types only command #4555

Merged
merged 3 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion apps/cli/pkg/cmd/workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func init() {
Long: "Retrieves all metadata from a remote workspace to the local directory",
Run: workspaceRetrieve,
}
workspaceRetrieveCmd.Flags().BoolP("onlyTypes", "t", false, "Only retrieve types")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we drop the shorthand t for now or at least until we know this is going to stick. Thinking t might be common for other types of things down the road and onlyTypes is more than likely a less commonly used flag. Thoughts?


workspaceDeployCmd := &cobra.Command{
Use: "deploy",
Expand Down Expand Up @@ -72,13 +73,17 @@ func init() {
Short: "uesio retrieve",
Run: workspaceRetrieve,
}
oldRetrieveCommand.Flags().BoolP("onlyTypes", "t", false, "Only retrieve types")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above regarding t


rootCmd.AddCommand(workspaceCommand, oldDeployCommand, oldRetrieveCommand)

}

func workspaceRetrieve(cmd *cobra.Command, args []string) {
err := workspace.Retrieve()
onlyTypes, _ := cmd.Flags().GetBool("onlyTypes")
err := workspace.Retrieve(&workspace.RetrieveOptions{
OnlyTypes: onlyTypes,
})
if err != nil {
fmt.Println("Error: " + err.Error())
os.Exit(1)
Expand Down
27 changes: 26 additions & 1 deletion apps/cli/pkg/command/workspace/retrieve.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ import (

"github.com/thecloudmasters/cli/pkg/auth"
"github.com/thecloudmasters/cli/pkg/call"
"github.com/thecloudmasters/cli/pkg/command"
"github.com/thecloudmasters/cli/pkg/config"
"github.com/thecloudmasters/cli/pkg/config/ws"
"github.com/thecloudmasters/cli/pkg/context"
"github.com/thecloudmasters/cli/pkg/zip"
"github.com/thecloudmasters/uesio/pkg/meta"
)

func Retrieve() error {
type RetrieveOptions struct {
OnlyTypes bool
}

func Retrieve(options *RetrieveOptions) error {

if options == nil {
options = &RetrieveOptions{}
}

_, err := auth.Login()
if err != nil {
Expand All @@ -37,6 +46,22 @@ func Retrieve() error {
return errors.New("No active workspace is set. Use \"uesio work\" to set one.")
}

if options.OnlyTypes {
appContext := context.NewWorkspaceContext(appName, workspace)

sessionId, err := config.GetSessionID()
if err != nil {
return err
}

if err = command.GenerateAppTypeDefinitions(appName, workspace, sessionId, appContext); err != nil {
return err
}

fmt.Println("Type definitions successfully updated.")
return nil
}

err = RetrieveBundleForAppWorkspace(appName, workspace, "")
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion apps/platform/pkg/meta/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ const NEWLINE = `
`

func (b *Bot) GenerateTypeDefinitions() (string, error) {
if b.Type != "ROUTE" && b.Type != "LISTENER" && b.Type != "RUNACTION" {
if b.Type != "ROUTE" && b.Type != "LISTENER" && b.Type != "RUNACTION" && b.Type != "GENERATOR" {
return "", nil
}
if b.Name == "" || b.Namespace == "" {
Expand Down
1 change: 1 addition & 0 deletions apps/platform/pkg/meta/botcollection.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func init() {
"LISTENER",
"ROUTE",
"RUNACTION",
"GENERATOR",
},
}
}
Expand Down
Loading