func uninstall()

in main/cmds.go [178:201]


func uninstall(lg ExtensionLogger, hEnv vmextension.HandlerEnvironment, seqNum int) error {
	// parse the extension handler settings
	cfg, err := parseAndValidateSettings(hEnv.HandlerEnvironment.ConfigFolder)
	if err != nil {
		return errors.Wrap(err, "failed to get configuration")
	}

	// run uninstall.sh to uninstall the agent
	lg.event("uninstalling agent")
	unzipDir, agentDirectory := getAgentPaths()
	_, runErr := runCmd(lg, "bash ./uninstall.sh", agentDirectory, cfg)
	if runErr != nil {
		lg.eventError("agent uninstall failed", runErr)
		telemetry(TelemetryScenario, "agent uninstall failed: "+runErr.Error(), false, 0)
	} else {
		lg.event("agent uninstall succeeded")
		telemetry(TelemetryScenario, "agent uninstall succeeded", true, 0)
	}

	// collect the logs if available and send telemetry updates
	getStdPipesAndTelemetry(lg, unzipDir, runErr)

	return nil
}