Beispiel #1
0
func main() {
	log.SetOutput(os.Stderr)

	httpClient := &http.Client{}
	client := rc.NewWithHTTP(httpClient)
	recorder := httprecorder.NewWithClient(httpClient)

	e := &generator{
		client: client,
	}

	examples := []g.Example{
		{"route_create", e.createRoute},
		{"route_update", e.updateRoute},
		{"route_list", e.listRoutes},
		{"route_get", e.getRoute},
		{"route_delete", e.deleteRoute},
	}

	var out io.Writer
	if len(os.Args) > 1 {
		var err error
		out, err = os.Create(os.Args[1])
		if err != nil {
			log.Fatal(err)
		}
	} else {
		out = os.Stdout
	}
	if err := g.WriteOutput(recorder, examples, out); err != nil {
		log.Fatal(err)
	}
}
Beispiel #2
0
func main() {
	conf, err := loadConfigFromEnv()
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(conf.logOut)

	httpClient := &http.Client{}
	client, err := cc.NewClientWithHTTP("", conf.controllerKey, httpClient)
	if err != nil {
		log.Fatal(err)
	}
	recorder := httprecorder.NewWithClient(httpClient)

	e := &generator{
		conf:        conf,
		client:      client,
		recorder:    recorder,
		resourceIds: make(map[string]string),
	}

	providerLog := log.New(conf.logOut, "provider: ", 1)
	go e.listenAndServe(providerLog)

	examples := []g.Example{
		// Run provider_create first so that discoverd service has time to
		// propagate
		{"provider_create", e.createProvider},
		{"app_create_error", e.createAppError},
		{"app_create", e.createApp},
		{"app_initial_release_get", e.getInitialAppRelease},
		{"app_get", e.getApp},
		{"app_list", e.listApps},
		{"app_log", e.getAppLog},
		{"app_log_stream", e.streamAppLog},
		{"app_update", e.updateApp},
		{"route_create", e.createRoute},
		{"route_get", e.getRoute},
		{"route_update", e.updateRoute},
		{"route_list", e.listRoutes},
		{"route_delete", e.deleteRoute},
		{"artifact_create", e.createArtifact},
		{"release_create", e.createRelease},
		{"artifact_list", e.listArtifacts},
		{"release_list", e.listReleases},
		{"app_release_set", e.setAppRelease},
		{"app_release_get", e.getAppRelease},
		{"app_release_list", e.listAppReleases},
		{"formation_put", e.putFormation},
		{"formation_get", e.getFormation},
		{"formation_get_expanded", e.getExpandedFormation},
		{"formation_list", e.listFormations},
		{"formations_list_active", e.listActiveFormations},
		{"formations_stream", e.streamFormations},
		{"release_create2", e.createRelease},
		{"deployment_create", e.createDeployment},
		{"deployment_get", e.getDeployment},
		{"deployment_list", e.listDeployments},
		{"formation_delete", e.deleteFormation},
		{"job_run", e.runJob},
		{"job_list", e.listJobs},
		{"job_update", e.updateJob},
		{"job_get", e.getJob},
		{"job_delete", e.deleteJob},
		{"provider_get", e.getProvider},
		{"provider_list", e.listProviders},
		{"provider_resource_create", e.createProviderResource},
		{"provider_resource_put", e.putProviderResource},
		{"app_resource_list", e.listAppResources},
		{"provider_resource_get", e.getProviderResource},
		{"provider_resource_list", e.listProviderResources},
		{"provider_resource_delete", e.deleteProviderResource},
		{"app_delete", e.deleteApp},
		{"events_list", e.eventsList},
		{"events_stream", e.eventsStream},
		{"event_get", e.eventGet},
		{"ca_cert", e.getCACert},
		{"cluster_backup", e.clusterBackup},
	}

	if os.Getenv("SKIP_MIGRATE_DOMAIN") != "true" {
		examples = append(examples, g.Example{"migrate_cluster_domain", e.migrateClusterDomain})
	}

	var out io.Writer
	if len(os.Args) > 1 {
		var err error
		out, err = os.Create(os.Args[1])
		if err != nil {
			log.Fatal(err)
		}
	} else {
		out = os.Stdout
	}
	if err := g.WriteOutput(recorder, examples, out); err != nil {
		log.Fatal(err)
	}
}
Beispiel #3
0
func main() {
	conf, err := loadConfigFromEnv()
	if err != nil {
		log.Fatal(err)
	}
	log.SetOutput(conf.logOut)

	httpClient := &http.Client{}
	client, err := cc.NewClientWithHTTP("", conf.controllerKey, httpClient)
	if err != nil {
		log.Fatal(err)
	}
	recorder := httprecorder.NewWithClient(httpClient)

	e := &generator{
		conf:        conf,
		client:      client,
		resourceIds: make(map[string]string),
	}

	providerLog := log.New(conf.logOut, "provider: ", 1)
	go e.listenAndServe(providerLog)

	examples := []g.Example{
		// Run provider_create first so that discoverd service has time to
		// propagate
		{"provider_create", e.createProvider},
		{"app_create_error", e.createAppError},
		{"app_create", e.createApp},
		{"app_initial_release_get", e.getInitialAppRelease},
		{"app_get", e.getApp},
		{"app_list", e.listApps},
		{"app_log", e.getAppLog},
		{"app_update", e.updateApp},
		{"app_resource_list", e.listAppResources},
		{"route_create", e.createRoute},
		{"route_get", e.getRoute},
		{"route_list", e.listRoutes},
		{"route_delete", e.deleteRoute},
		{"artifact_create", e.createArtifact},
		{"release_create", e.createRelease},
		{"artifact_list", e.listArtifacts},
		{"release_list", e.listReleases},
		{"app_release_set", e.setAppRelease},
		{"app_release_get", e.getAppRelease},
		{"formation_put", e.putFormation},
		{"formation_get", e.getFormation},
		{"formation_list", e.listFormations},
		{"release_create2", e.createRelease},
		{"deployment_create", e.createDeployment},
		{"formation_delete", e.deleteFormation},
		{"job_run", e.runJob},
		{"job_list", e.listJobs},
		{"job_update", e.updateJob},
		{"job_delete", e.deleteJob},
		{"provider_get", e.getProvider},
		{"provider_list", e.listProviders},
		{"provider_resource_create", e.createProviderResource},
		{"provider_resource_get", e.getProviderResource},
		{"provider_resource_list", e.listProviderResources},
		{"app_delete", e.deleteApp},
	}

	// TODO: GET /apps/:app_id/jobs/:job_id/log (event-stream)

	var out io.Writer
	if len(os.Args) > 1 {
		var err error
		out, err = os.Create(os.Args[1])
		if err != nil {
			log.Fatal(err)
		}
	} else {
		out = os.Stdout
	}
	if err := g.WriteOutput(recorder, examples, out); err != nil {
		log.Fatal(err)
	}
}