当前位置: 首页>>代码示例>>Golang>>正文


Golang models.DomainFields类代码示例

本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/models.DomainFields的典型用法代码示例。如果您正苦于以下问题:Golang DomainFields类的具体用法?Golang DomainFields怎么用?Golang DomainFields使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DomainFields类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: CreateRoute

func (cmd *CreateRoute) CreateRoute(hostName string, path string, domain models.DomainFields, space models.SpaceFields) (models.Route, error) {
	cmd.ui.Say(T("Creating route {{.URL}} for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
		map[string]interface{}{
			"URL":       terminal.EntityNameColor(domain.UrlForHostAndPath(hostName, path)),
			"OrgName":   terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
			"SpaceName": terminal.EntityNameColor(space.Name),
			"Username":  terminal.EntityNameColor(cmd.config.Username())}))

	route, err := cmd.routeRepo.CreateInSpace(hostName, path, domain.Guid, space.Guid)
	if err != nil {
		var findErr error
		route, findErr = cmd.routeRepo.Find(hostName, domain, path)
		if findErr != nil {
			return models.Route{}, err
		}

		if route.Space.Guid != space.Guid || route.Domain.Guid != domain.Guid {
			return models.Route{}, err
		}

		cmd.ui.Ok()
		cmd.ui.Warn(T("Route {{.URL}} already exists",
			map[string]interface{}{"URL": route.URL()}))

		return route, nil
	}

	cmd.ui.Ok()

	return route, nil
}
开发者ID:vframbach,项目名称:cli,代码行数:31,代码来源:create_route.go

示例2: FindOrCreateRoute

func (routeActor routeActor) FindOrCreateRoute(hostname string, domain models.DomainFields, path string, useRandomPort bool) (models.Route, error) {
	var port int
	route, err := routeActor.routeRepo.Find(hostname, domain, path, port)

	switch err.(type) {
	case nil:
		routeActor.ui.Say(
			T("Using route {{.RouteURL}}",
				map[string]interface{}{
					"RouteURL": terminal.EntityNameColor(route.URL()),
				}),
		)
	case *errors.ModelNotFoundError:
		if useRandomPort {
			route, err = routeActor.CreateRandomTCPRoute(domain)
		} else {
			routeActor.ui.Say(
				T("Creating route {{.Hostname}}...",
					map[string]interface{}{
						"Hostname": terminal.EntityNameColor(domain.URLForHostAndPath(hostname, path, port)),
					}),
			)

			route, err = routeActor.routeRepo.Create(hostname, domain, path, useRandomPort)
		}

		routeActor.ui.Ok()
		routeActor.ui.Say("")
	}

	return route, err
}
开发者ID:Reejoshi,项目名称:cli,代码行数:32,代码来源:routes.go

示例3: CreateRoute

func (cmd *CreateRoute) CreateRoute(hostName string, domain models.DomainFields, space models.SpaceFields) (route models.Route, apiErr error) {
	cmd.ui.Say(T("Creating route {{.Hostname}} for org {{.OrgName}} / space {{.SpaceName}} as {{.Username}}...",
		map[string]interface{}{
			"Hostname":  terminal.EntityNameColor(domain.UrlForHost(hostName)),
			"OrgName":   terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
			"SpaceName": terminal.EntityNameColor(space.Name),
			"Username":  terminal.EntityNameColor(cmd.config.Username())}))

	route, apiErr = cmd.routeRepo.CreateInSpace(hostName, domain.Guid, space.Guid)
	if apiErr != nil {
		var findApiResponse error
		route, findApiResponse = cmd.routeRepo.FindByHostAndDomain(hostName, domain)

		if findApiResponse != nil ||
			route.Space.Guid != space.Guid ||
			route.Domain.Guid != domain.Guid {
			return
		}

		apiErr = nil
		cmd.ui.Ok()
		cmd.ui.Warn(T("Route {{.URL}} already exists",
			map[string]interface{}{"URL": route.URL()}))
		return
	}

	cmd.ui.Ok()
	return
}
开发者ID:rakutentech,项目名称:cli,代码行数:29,代码来源:create_route.go

示例4: CreateRoute

func (cmd *CreateRoute) CreateRoute(hostName string, domain models.DomainFields, space models.SpaceFields) (route models.Route, apiErr error) {
	cmd.ui.Say("Creating route %s for org %s / space %s as %s...",
		terminal.EntityNameColor(domain.UrlForHost(hostName)),
		terminal.EntityNameColor(cmd.config.OrganizationFields().Name),
		terminal.EntityNameColor(space.Name),
		terminal.EntityNameColor(cmd.config.Username()),
	)

	route, apiErr = cmd.routeRepo.CreateInSpace(hostName, domain.Guid, space.Guid)
	if apiErr != nil {
		var findApiResponse error
		route, findApiResponse = cmd.routeRepo.FindByHostAndDomain(hostName, domain)

		if findApiResponse != nil ||
			route.Space.Guid != space.Guid ||
			route.Domain.Guid != domain.Guid {
			return
		}

		apiErr = nil
		cmd.ui.Ok()
		cmd.ui.Warn("Route %s already exists", route.URL())
		return
	}

	cmd.ui.Ok()
	return
}
开发者ID:palakmathur,项目名称:cli,代码行数:28,代码来源:create_route.go

示例5: makeAppWithRoute

func makeAppWithRoute(appName string) models.Application {
	application := models.Application{}
	application.Name = appName
	application.Guid = "app-guid"

	domain := models.DomainFields{}
	domain.Name = "example.com"

	route := models.RouteSummary{Host: "foo", Domain: domain}
	secondRoute := models.RouteSummary{Host: appName, Domain: domain}
	packgeUpdatedAt, _ := time.Parse("2006-01-02T15:04:05Z07:00", "2012-10-24T19:54:00Z")

	application.State = "started"
	application.InstanceCount = 2
	application.RunningInstances = 2
	application.Memory = 256
	application.Stack = &models.Stack{
		Name: "fake_stack",
		Guid: "123-123-123",
	}
	application.Routes = []models.RouteSummary{route, secondRoute}
	application.PackageUpdatedAt = &packgeUpdatedAt

	return application
}
开发者ID:raghulsid,项目名称:cli,代码行数:25,代码来源:app_test.go

示例6: makeAppWithOptions

func makeAppWithOptions(appName string) models.Application {
	application := models.Application{}
	application.Name = appName
	application.Guid = "app-guid"
	application.Command = "run main.go"
	application.BuildpackUrl = "go-buildpack"

	domain := models.DomainFields{}
	domain.Name = "example.com"

	route := models.RouteSummary{Host: "foo", Domain: domain}
	secondRoute := models.RouteSummary{Host: appName, Domain: domain}
	packgeUpdatedAt, _ := time.Parse("2006-01-02T15:04:05Z07:00", "2012-10-24T19:54:00Z")

	application.State = "started"
	application.InstanceCount = 2
	application.RunningInstances = 2
	application.Memory = 256
	application.HealthCheckTimeout = 100
	application.Routes = []models.RouteSummary{route, secondRoute}
	application.PackageUpdatedAt = &packgeUpdatedAt

	envMap := make(map[string]interface{})
	envMap["foo"] = "bar"
	application.EnvironmentVars = envMap

	application.Services = append(application.Services, models.ServicePlanSummary{
		Guid: "",
		Name: "server1",
	})

	return application
}
开发者ID:rcreddy06,项目名称:cli,代码行数:33,代码来源:create_app_manifest_test.go

示例7: fakeDomainRepo

func fakeDomainRepo() *testapi.FakeDomainRepository {
	domain := models.DomainFields{}
	domain.Name = "foo.com"
	domain.Guid = "foo-guid"
	domain.Shared = true

	return &testapi.FakeDomainRepository{
		FindByNameInOrgDomain: domain,
	}
}
开发者ID:GABONIA,项目名称:cli,代码行数:10,代码来源:delete_shared_domain_test.go

示例8: ToModel

func (resource RouteSummary) ToModel() (route models.RouteSummary) {
	domain := models.DomainFields{}
	domain.Guid = resource.Domain.Guid
	domain.Name = resource.Domain.Name
	domain.Shared = resource.Domain.OwningOrganizationGuid != ""

	route.Guid = resource.Guid
	route.Host = resource.Host
	route.Domain = domain
	return
}
开发者ID:cloudfoundry-incubator,项目名称:Diego-Enabler,代码行数:11,代码来源:app_summary.go

示例9: ToModel

func (resource RouteSummary) ToModel() (route models.RouteSummary) {
	domain := models.DomainFields{}
	domain.GUID = resource.Domain.GUID
	domain.Name = resource.Domain.Name
	domain.Shared = resource.Domain.OwningOrganizationGUID != ""

	route.GUID = resource.GUID
	route.Host = resource.Host
	route.Path = resource.Path
	route.Port = resource.Port
	route.Domain = domain
	return
}
开发者ID:Reejoshi,项目名称:cli,代码行数:13,代码来源:app_summary.go

示例10: makeAppWithRoute

func makeAppWithRoute(appName string) models.Application {
	application := models.Application{}
	application.Name = appName
	application.Guid = "app-guid"

	domain := models.DomainFields{}
	domain.Name = "example.com"

	route := models.RouteSummary{Host: "foo", Domain: domain}
	secondRoute := models.RouteSummary{Host: appName, Domain: domain}

	application.State = "started"
	application.InstanceCount = 2
	application.RunningInstances = 2
	application.Memory = 256
	application.Routes = []models.RouteSummary{route, secondRoute}

	return application
}
开发者ID:jacopen,项目名称:cli,代码行数:19,代码来源:app_test.go

示例11: FindOrCreateRoute

func (routeActor RouteActor) FindOrCreateRoute(hostname string, domain models.DomainFields) (route models.Route) {
	route, apiErr := routeActor.routeRepo.FindByHostAndDomain(hostname, domain)

	switch apiErr.(type) {
	case nil:
		routeActor.ui.Say("Using route %s", terminal.EntityNameColor(route.URL()))
	case *errors.ModelNotFoundError:
		routeActor.ui.Say("Creating route %s...", terminal.EntityNameColor(domain.UrlForHost(hostname)))

		route, apiErr = routeActor.routeRepo.Create(hostname, domain)
		if apiErr != nil {
			routeActor.ui.Failed(apiErr.Error())
		}

		routeActor.ui.Ok()
		routeActor.ui.Say("")
	default:
		routeActor.ui.Failed(apiErr.Error())
	}

	return
}
开发者ID:palakmathur,项目名称:cli,代码行数:22,代码来源:routes.go

示例12: FindOrCreateRoute

func (routeActor routeActor) FindOrCreateRoute(hostname string, domain models.DomainFields, path string, port int, useRandomPort bool) (models.Route, error) {
	var route models.Route
	var err error
	//if tcp route use random port should skip route lookup
	if useRandomPort && domain.RouterGroupType == tcp {
		err = new(errors.ModelNotFoundError)
	} else {
		route, err = routeActor.routeRepo.Find(hostname, domain, path, port)
	}

	switch err.(type) {
	case nil:
		routeActor.ui.Say(
			T("Using route {{.RouteURL}}",
				map[string]interface{}{
					"RouteURL": terminal.EntityNameColor(route.URL()),
				}),
		)
	case *errors.ModelNotFoundError:
		if useRandomPort && domain.RouterGroupType == tcp {
			route, err = routeActor.CreateRandomTCPRoute(domain)
		} else {
			routeActor.ui.Say(
				T("Creating route {{.Hostname}}...",
					map[string]interface{}{
						"Hostname": terminal.EntityNameColor(domain.URLForHostAndPath(hostname, path, port)),
					}),
			)

			route, err = routeActor.routeRepo.Create(hostname, domain, path, port, false)
		}

		routeActor.ui.Ok()
		routeActor.ui.Say("")
	}

	return route, err
}
开发者ID:jasonkeene,项目名称:cli,代码行数:38,代码来源:routes.go

示例13:

			runCommand("some-space")
			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
		})
	})

	Context("when logged in and an org is targeted", func() {
		BeforeEach(func() {
			org := models.OrganizationFields{}
			org.Name = "my-org"

			app := models.ApplicationFields{}
			app.Name = "app1"
			app.Guid = "app1-guid"
			apps := []models.ApplicationFields{app}

			domain := models.DomainFields{}
			domain.Name = "domain1"
			domain.Guid = "domain1-guid"
			domains := []models.DomainFields{domain}

			serviceInstance := models.ServiceInstanceFields{}
			serviceInstance.Name = "service1"
			serviceInstance.Guid = "service1-guid"
			services := []models.ServiceInstanceFields{serviceInstance}

			securityGroup1 := models.SecurityGroupFields{Name: "Nacho Security"}
			securityGroup2 := models.SecurityGroupFields{Name: "Nacho Prime"}
			securityGroups := []models.SecurityGroupFields{securityGroup1, securityGroup2}

			space := models.Space{}
			space.Name = "whose-space-is-it-anyway"
开发者ID:matanzit,项目名称:cli,代码行数:31,代码来源:space_test.go

示例14:

			Expect(routes[1].Guid).To(Equal("route-2-guid"))
			Expect(handler).To(HaveAllRequestsCalled())
			Expect(apiErr).NotTo(HaveOccurred())
		})

		It("finds a route by host and domain", func() {
			ts, handler = testnet.NewServer([]testnet.TestRequest{
				testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "GET",
					Path:     "/v2/routes?q=host%3Amy-cool-app%3Bdomain_guid%3Amy-domain-guid",
					Response: findRouteByHostResponse,
				}),
			})
			configRepo.SetApiEndpoint(ts.URL)

			domain := models.DomainFields{}
			domain.Guid = "my-domain-guid"

			route, apiErr := repo.FindByHostAndDomain("my-cool-app", domain)

			Expect(apiErr).NotTo(HaveOccurred())
			Expect(handler).To(HaveAllRequestsCalled())
			Expect(route.Host).To(Equal("my-cool-app"))
			Expect(route.Guid).To(Equal("my-route-guid"))
			Expect(route.Domain.Guid).To(Equal(domain.Guid))
		})

		It("returns 'not found' response when there is no route w/ the given domain and host", func() {
			ts, handler = testnet.NewServer([]testnet.TestRequest{
				testapi.NewCloudControllerTestRequest(testnet.TestRequest{
					Method:   "GET",
开发者ID:Jack1996,项目名称:cli,代码行数:31,代码来源:routes_test.go

示例15:

		appRepo = &testApplication.FakeApplicationRepository{}

		displayApp = &appCmdFakes.FakeAppDisplayer{}

		//save original command dependency and restore later
		OriginalAppCommand = command_registry.Commands.FindCommand("app")

		defaultInstanceErrorCodes = []string{"", ""}

		defaultAppForStart = models.Application{}
		defaultAppForStart.Name = "my-app"
		defaultAppForStart.Guid = "my-app-guid"
		defaultAppForStart.InstanceCount = 2
		defaultAppForStart.PackageState = "STAGED"

		domain := models.DomainFields{}
		domain.Name = "example.com"

		route := models.RouteSummary{}
		route.Host = "my-app"
		route.Domain = domain

		defaultAppForStart.Routes = []models.RouteSummary{route}

		instance1 := models.AppInstanceFields{}
		instance1.State = models.InstanceStarting

		instance2 := models.AppInstanceFields{}
		instance2.State = models.InstanceStarting

		instance3 := models.AppInstanceFields{}
开发者ID:rbramwell,项目名称:cli,代码行数:31,代码来源:start_test.go


注:本文中的github.com/cloudfoundry/cli/cf/models.DomainFields类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。