github.com/sleungcy-sap/cli@v7.1.0+incompatible/integration/assets/configurable_plugin_fails_uninstall/test_plugin_fails_uninstall.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"path/filepath"
     7  	"strings"
     8  
     9  	"code.cloudfoundry.org/cli/plugin"
    10  	"github.com/blang/semver"
    11  )
    12  
    13  var (
    14  	pluginName     string
    15  	commands       string
    16  	commandHelps   string
    17  	commandAliases string
    18  	version        string
    19  )
    20  
    21  type ConfigurablePluginFailsUninstall struct{}
    22  
    23  func (_ *ConfigurablePluginFailsUninstall) Run(cliConnection plugin.CliConnection, args []string) {
    24  	fmt.Fprintf(os.Stderr, "I'm failing...I'm failing...\n")
    25  	os.Exit(1)
    26  }
    27  
    28  func (_ *ConfigurablePluginFailsUninstall) GetMetadata() plugin.PluginMetadata {
    29  	v1, _ := semver.Make(version)
    30  	metadata := plugin.PluginMetadata{
    31  		Name: pluginName,
    32  		Version: plugin.VersionType{
    33  			Major: int(v1.Major),
    34  			Minor: int(v1.Minor),
    35  			Build: int(v1.Patch),
    36  		},
    37  	}
    38  
    39  	pluginCommandsList := strings.Split(commands, ",")
    40  	pluginHelpsList := strings.Split(commandHelps, ",")
    41  	pluginAliasesList := strings.Split(commandAliases, ",")
    42  	for i, _ := range pluginCommandsList {
    43  		metadata.Commands = append(metadata.Commands, plugin.Command{
    44  			Alias:    pluginAliasesList[i],
    45  			Name:     pluginCommandsList[i],
    46  			HelpText: pluginHelpsList[i],
    47  		})
    48  	}
    49  
    50  	return metadata
    51  }
    52  
    53  func uninstalling() {
    54  	os.Remove(filepath.Join(os.TempDir(), "uninstall-test-file-for-test_1.exe"))
    55  }
    56  
    57  func main() {
    58  	plugin.Start(new(ConfigurablePluginFailsUninstall))
    59  }