Esempio n. 1
0
func (c *AppLister) Run(cliConnection plugin.CliConnection, args []string) {
	orgs, err := cliConnection.GetOrgs()
	if err != nil {
		fmt.Println("Error getting orgs:", err)
		os.Exit(1)
	}

	for _, org := range orgs {
		_, err := cliConnection.CliCommandWithoutTerminalOutput("t", "-o", org.Name)
		if err != nil {
			fmt.Println("Error targeting org: ", org.Name)
			os.Exit(1)
		}

		apps, err := cliConnection.GetApps()
		if err != nil {
			fmt.Println("Error getting applications from org: ", org.Name)
			os.Exit(1)
		}

		for _, app := range apps {
			fmt.Println(app.Name)
		}
	}
}
Esempio n. 2
0
func (c *Test1) Run(cliConnection plugin.CliConnection, args []string) {
	if args[0] == "new-api" {
		token, _ := cliConnection.AccessToken()
		fmt.Println("Access Token:", token)
		fmt.Println("")

		app, err := cliConnection.GetApp("test_app")
		fmt.Println("err for test_app", err)
		fmt.Println("test_app is: ", app)

		hasOrg, _ := cliConnection.HasOrganization()
		fmt.Println("Has Organization Targeted:", hasOrg)
		currentOrg, _ := cliConnection.GetCurrentOrg()
		fmt.Println("Current Org:", currentOrg)
		org, _ := cliConnection.GetOrg(currentOrg.Name)
		fmt.Println(currentOrg.Name, " Org:", org)
		orgs, _ := cliConnection.GetOrgs()
		fmt.Println("Orgs:", orgs)
		hasSpace, _ := cliConnection.HasSpace()
		fmt.Println("Has Space Targeted:", hasSpace)
		currentSpace, _ := cliConnection.GetCurrentSpace()
		fmt.Println("Current space:", currentSpace)
		space, _ := cliConnection.GetSpace(currentSpace.Name)
		fmt.Println("Space:", space)
		spaces, _ := cliConnection.GetSpaces()
		fmt.Println("Spaces:", spaces)
		loggregator, _ := cliConnection.LoggregatorEndpoint()
		fmt.Println("Loggregator Endpoint:", loggregator)
		dopplerEndpoint, _ := cliConnection.DopplerEndpoint()
		fmt.Println("Doppler Endpoint:", dopplerEndpoint)

		user, _ := cliConnection.Username()
		fmt.Println("Current user:"******"Current user guid:", userGUID)
		email, _ := cliConnection.UserEmail()
		fmt.Println("Current user email:", email)

		hasAPI, _ := cliConnection.HasAPIEndpoint()
		fmt.Println("Has API Endpoint:", hasAPI)
		api, _ := cliConnection.ApiEndpoint()
		fmt.Println("Current api:", api)
		version, _ := cliConnection.ApiVersion()
		fmt.Println("Current api version:", version)

		loggedIn, _ := cliConnection.IsLoggedIn()
		fmt.Println("Is Logged In:", loggedIn)
		isSSLDisabled, _ := cliConnection.IsSSLDisabled()
		fmt.Println("Is SSL Disabled:", isSSLDisabled)
	} else if args[0] == "test_1_cmd1" {
		theFirstCmd()
	} else if args[0] == "test_1_cmd2" {
		theSecondCmd()
	} else if args[0] == "CLI-MESSAGE-UNINSTALL" {
		uninstalling()
	}
}
func ListAllApps(cliConnection plugin.CliConnection) error {
	orgs, err := cliConnection.GetOrgs()
	if err != nil {
		return errors.New("Error getting list of organizations: " + err.Error())
	}

	for _, org := range orgs {
		apps, err := GetAppsInOneOrg(cliConnection, org.Name)
		if err != nil {
			fmt.Println("Warning: Failed to get apps in organization '" + org.Name + "'")
			continue
		}

		PrintAppsName(org.Name, apps)
	}

	return nil
}
func DisableAppsInAllOrg(cliConnection plugin.CliConnection) error {
	orgs, err := cliConnection.GetOrgs()
	if err != nil {
		return errors.New("Error getting list of organizations: " + err.Error())
	}

	for _, org := range orgs {
		apps, err := GetAppsInOneOrg(cliConnection, org.Name)
		if err != nil {
			fmt.Println("Failed to get apps in organization '" + org.Name + "'")
			continue
		}

		for _, app := range apps {
			err = appsRepository.DisableAppSSH(cliConnection, app.Guid)
			if err != nil {
				fmt.Println(err.Error())
			}
		}
	}
	return nil
}