當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Domain.Spaces方法代碼示例

本文整理匯總了Golang中cf.Domain.Spaces方法的典型用法代碼示例。如果您正苦於以下問題:Golang Domain.Spaces方法的具體用法?Golang Domain.Spaces怎麽用?Golang Domain.Spaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cf.Domain的用法示例。


在下文中一共展示了Domain.Spaces方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: findAllWithPath

func (repo CloudControllerDomainRepository) findAllWithPath(path string) (domains []cf.Domain, apiResponse net.ApiResponse) {
	domainResources := new(PaginatedDomainResources)
	apiResponse = repo.gateway.GetResource(path, repo.config.AccessToken, domainResources)
	if apiResponse.IsNotSuccessful() {
		return
	}

	for _, r := range domainResources.Resources {
		domain := cf.Domain{
			Name: r.Entity.Name,
			Guid: r.Metadata.Guid,
		}
		domain.Shared = r.Entity.OwningOrganizationGuid == ""

		for _, space := range r.Entity.Spaces {
			domain.Spaces = append(domain.Spaces, cf.Space{
				Name: space.Entity.Name,
				Guid: space.Metadata.Guid,
			})
		}
		domains = append(domains, domain)
	}

	return
}
開發者ID:jalateras,項目名稱:cli,代碼行數:25,代碼來源:domains.go

示例2: TestListDomains

func TestListDomains(t *testing.T) {
	orgFields := cf.OrganizationFields{}
	orgFields.Name = "my-org"
	orgFields.Guid = "my-org-guid"

	reqFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true, OrganizationFields: orgFields}
	domain1 := cf.Domain{}
	domain1.Shared = true
	domain1.Name = "Domain1"

	domain2 := cf.Domain{}
	domain2.Shared = false
	domain2.Name = "Domain2"

	space1 := cf.SpaceFields{}
	space1.Name = "my-space"

	space2 := cf.SpaceFields{}
	space2.Name = "my-space-2"

	domain2.Spaces = []cf.SpaceFields{space1, space2}

	domain3 := cf.Domain{}
	domain3.Shared = false
	domain3.Name = "Domain3"

	domainRepo := &testapi.FakeDomainRepository{
		ListDomainsForOrgDomains: []cf.Domain{domain1, domain2, domain3},
	}
	ui := callListDomains(t, []string{}, reqFactory, domainRepo)

	assert.Equal(t, domainRepo.ListDomainsForOrgDomainsGuid, "my-org-guid")
	testassert.SliceContains(t, ui.Outputs, testassert.Lines{
		{"Getting domains in org", "my-org", "my-user"},
		{"name", "status", "spaces"},
		{"Domain1", "shared"},
		{"Domain2", "owned", "my-space", "my-space-2"},
		{"Domain3", "reserved"},
	})
}
開發者ID:pmuellr,項目名稱:cli,代碼行數:40,代碼來源:list_domains_test.go


注:本文中的cf.Domain.Spaces方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。