func main() {
	args, err := parseArgs(os.Args)
	if err != nil {
		log.Fatal(err)
	}
	director := director.NewDirector(args.Target, args.RootCAPath, args.ClientName, args.ClientSecret)

	ticker := time.NewTicker(30 * time.Second)
	quitChannel := make(chan struct{})
	defer close(quitChannel)

	for {
		fmt.Println("Waiting for a channel signal...")
		select {
		case <-ticker.C:
			fmt.Println("received ticker signal")
			deployments := director.Deployments()
			mongo.PushData(args.MongoDBAddress, args.MongoDBUser, args.MongoDBPassword, args.MongoDBName, &mongo.DeploymentInfo{director.Status().UUID, deployments})
			fmt.Printf("Here is the current list of deployments: '%s'", deployments)
		case <-quitChannel:
			fmt.Println("received quit signal")
			ticker.Stop()
			return
		}
	}

}
Exemple #2
0
func main() {
	args, err := parseArgs(os.Args)
	if err != nil {
		log.Fatal(err)
	}
	director := director.NewDirector(args.Target, args.RootCAPath, args.ClientName, args.ClientSecret)

	prettyStatus, _ := json.MarshalIndent(director.Status(), "", "  ")
	fmt.Printf("The director status: '%s'\n", prettyStatus)

	prettyLogin, _ := json.MarshalIndent(director.Login(), "", "  ")
	fmt.Printf("The director login: '******'\n", prettyLogin)

	prettyDeployments, _ := json.MarshalIndent(director.Deployments(), "", "  ")
	fmt.Printf("The director deployments: '%s'\n", prettyDeployments)

	prettyTasks, _ := json.MarshalIndent(director.Tasks(), "", "  ")
	fmt.Printf("The director tasks: '%s'\n", prettyTasks)

}
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/voelzmo/bosh-director-client/director"
)

var dir director.Director

var _ = Describe("Director", func() {
	Context("When initialized with a target", func() {

		BeforeEach(func() {
			target := os.Getenv("BDC_ITEST_TARGET")
			rootCAPath := os.Getenv("BDC_ITEST_ROOT_CA_PATH")
			clientName := os.Getenv("BDC_ITEST_CLIENT_NAME")
			clientSecret := os.Getenv("BDC_ITEST_CLIENT_SECRET")
			dir = director.NewDirector(target, rootCAPath, clientName, clientSecret)
		})

		It("#status gets the director's status ", func() {
			status := dir.Status()
			Expect(status.Name).To(Equal("my-bosh"))
		})

		It("#login returns a token and not an error", func() {
			login := dir.Login()
			Expect(login.Error).To(BeEmpty())
			Expect(login.AccessToken).NotTo(BeEmpty())
		})

		It("#deployments return a list of deployments with their stemcells", func() {
			deployments := dir.Deployments()