Skip to content

Commit

Permalink
fix: hide custom ddev pull and ddev push commands from Amplitude, fixes
Browse files Browse the repository at this point in the history
#6128 (#6152) [skip ci]
  • Loading branch information
stasadev committed May 15, 2024
1 parent 7607d85 commit 6264493
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmd/ddev/cmd/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ ddev pull %s --skip-files -y`, subCommandName, subCommandName, subCommandName),
appPull(providerName, app, flags["skip-confirmation"], flags["skip-import"], flags["skip-db"], flags["skip-files"], environment)
},
}
// Mark custom command
if !ddevapp.IsBundledCustomProvider(subCommandName) {
if subCommand.Annotations == nil {
subCommand.Annotations = map[string]string{}
}
subCommand.Annotations[CustomCommand] = "true"
}
PullCmd.AddCommand(subCommand)
subCommand.Flags().BoolP("skip-confirmation", "y", false, "Skip confirmation step")
subCommand.Flags().Bool("skip-db", false, "Skip pulling database archive")
Expand Down
7 changes: 7 additions & 0 deletions cmd/ddev/cmd/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,13 @@ ddev push %s --skip-files -y`, subCommandName, subCommandName, subCommandName),
apppush(providerName, app, flags["skip-confirmation"], flags["skip-import"], flags["skip-db"], flags["skip-files"], environment)
},
}
// Mark custom command
if !ddevapp.IsBundledCustomProvider(subCommandName) {
if subCommand.Annotations == nil {
subCommand.Annotations = map[string]string{}
}
subCommand.Annotations[CustomCommand] = "true"
}
PushCmd.AddCommand(subCommand)
subCommand.Flags().BoolP("skip-confirmation", "y", false, "Skip confirmation step")
subCommand.Flags().Bool("skip-db", false, "Skip pushing database archive")
Expand Down
2 changes: 1 addition & 1 deletion cmd/ddev/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Support: https://ddev.readthedocs.io/en/stable/users/support/`,
cmdCopy := *cmd
argsCopy := args
if IsUserDefinedCustomCommand(&cmdCopy) {
cmdCopy.Use = "custom-command"
cmdCopy = cobra.Command{Use: "custom-command"}
argsCopy = []string{}
}

Expand Down
13 changes: 13 additions & 0 deletions pkg/ddevapp/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,16 @@ func IsBundledCustomCommand(globalCommand bool, service, command string) bool {

return err == nil
}

func IsBundledCustomProvider(provider string) bool {
paths := []string{
filepath.Join("dotddev_assets", "providers", provider) + ".yaml",
filepath.Join("dotddev_assets", "providers", provider) + ".yaml.example",
}
for _, path := range paths {
if _, err := bundledAssets.ReadFile(path); err == nil {
return true
}
}
return false
}

0 comments on commit 6264493

Please sign in to comment.