本文整理匯總了Golang中github.com/nttlabs/cli/cf/configuration/core_config.ReadWriter類的典型用法代碼示例。如果您正苦於以下問題:Golang ReadWriter類的具體用法?Golang ReadWriter怎麽用?Golang ReadWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ReadWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func Init(config core_config.ReadWriter) go_i18n.TranslateFunc {
var T go_i18n.TranslateFunc
var err error
locale := config.Locale()
if locale != "" {
pieces := strings.Split(locale, "_")
err = loadFromAsset(locale, pieces[1])
if err == nil {
T, err = go_i18n.Tfunc(config.Locale(), DEFAULT_LOCALE)
}
} else {
var userLocale string
userLocale, err = initWithUserLocale()
if err != nil {
userLocale = mustLoadDefaultLocale()
}
T, err = go_i18n.Tfunc(userLocale, DEFAULT_LOCALE)
}
if err != nil {
panic(err)
}
return T
}
示例2: NewRepositoryLocator
func NewRepositoryLocator(config core_config.ReadWriter, gatewaysByName map[string]net.Gateway) (loc RepositoryLocator) {
strategy := strategy.NewEndpointStrategy(config.ApiVersion())
authGateway := gatewaysByName["auth"]
cloudControllerGateway := gatewaysByName["cloud-controller"]
uaaGateway := gatewaysByName["uaa"]
loc.authRepo = authentication.NewUAAAuthenticationRepository(authGateway, config)
// ensure gateway refreshers are set before passing them by value to repositories
cloudControllerGateway.SetTokenRefresher(loc.authRepo)
uaaGateway.SetTokenRefresher(loc.authRepo)
tlsConfig := net.NewTLSConfig([]tls.Certificate{}, config.IsSSLDisabled())
loggregatorConsumer := consumer.New(config.LoggregatorEndpoint(), tlsConfig, http.ProxyFromEnvironment)
loggregatorConsumer.SetDebugPrinter(terminal.DebugPrinter{})
loc.appBitsRepo = application_bits.NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway)
loc.appEventsRepo = app_events.NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy)
loc.appFilesRepo = api_app_files.NewCloudControllerAppFilesRepository(config, cloudControllerGateway)
loc.appRepo = applications.NewCloudControllerApplicationRepository(config, cloudControllerGateway)
loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway)
loc.appInstancesRepo = app_instances.NewCloudControllerAppInstancesRepository(config, cloudControllerGateway)
loc.authTokenRepo = NewCloudControllerServiceAuthTokenRepository(config, cloudControllerGateway)
loc.curlRepo = NewCloudControllerCurlRepository(config, cloudControllerGateway)
loc.domainRepo = NewCloudControllerDomainRepository(config, cloudControllerGateway, strategy)
loc.endpointRepo = NewEndpointRepository(config, cloudControllerGateway)
loc.logsRepo = NewLoggregatorLogsRepository(config, loggregatorConsumer, loc.authRepo)
loc.organizationRepo = organizations.NewCloudControllerOrganizationRepository(config, cloudControllerGateway)
loc.passwordRepo = password.NewCloudControllerPasswordRepository(config, uaaGateway)
loc.quotaRepo = quotas.NewCloudControllerQuotaRepository(config, cloudControllerGateway)
loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway)
loc.stackRepo = stacks.NewCloudControllerStackRepository(config, cloudControllerGateway)
loc.serviceRepo = NewCloudControllerServiceRepository(config, cloudControllerGateway)
loc.serviceBindingRepo = NewCloudControllerServiceBindingRepository(config, cloudControllerGateway)
loc.serviceBrokerRepo = NewCloudControllerServiceBrokerRepository(config, cloudControllerGateway)
loc.servicePlanRepo = NewCloudControllerServicePlanRepository(config, cloudControllerGateway)
loc.servicePlanVisibilityRepo = NewCloudControllerServicePlanVisibilityRepository(config, cloudControllerGateway)
loc.serviceSummaryRepo = NewCloudControllerServiceSummaryRepository(config, cloudControllerGateway)
loc.spaceRepo = spaces.NewCloudControllerSpaceRepository(config, cloudControllerGateway)
loc.userProvidedServiceInstanceRepo = NewCCUserProvidedServiceInstanceRepository(config, cloudControllerGateway)
loc.userRepo = NewCloudControllerUserRepository(config, uaaGateway, cloudControllerGateway)
loc.buildpackRepo = NewCloudControllerBuildpackRepository(config, cloudControllerGateway)
loc.buildpackBitsRepo = NewCloudControllerBuildpackBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{})
loc.securityGroupRepo = security_groups.NewSecurityGroupRepo(config, cloudControllerGateway)
loc.stagingSecurityGroupRepo = staging.NewStagingSecurityGroupsRepo(config, cloudControllerGateway)
loc.runningSecurityGroupRepo = running.NewRunningSecurityGroupsRepo(config, cloudControllerGateway)
loc.securityGroupSpaceBinder = securitygroupspaces.NewSecurityGroupSpaceBinder(config, cloudControllerGateway)
loc.spaceQuotaRepo = space_quotas.NewCloudControllerSpaceQuotaRepository(config, cloudControllerGateway)
loc.featureFlagRepo = feature_flags.NewCloudControllerFeatureFlagRepository(config, cloudControllerGateway)
loc.environmentVariableGroupRepo = environment_variable_groups.NewCloudControllerEnvironmentVariableGroupsRepository(config, cloudControllerGateway)
loc.copyAppSourceRepo = copy_application_source.NewCloudControllerCopyApplicationSourceRepository(config, cloudControllerGateway)
loc.zoneRepo = NewCloudControllerZoneRepository(config, cloudControllerGateway)
return
}
示例3:
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("auth command", func() {
var (
ui *testterm.FakeUI
cmd Authenticate
config core_config.ReadWriter
repo *testapi.FakeAuthenticationRepository
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{}
repo = &testapi.FakeAuthenticationRepository{
Config: config,
AccessToken: "my-access-token",
RefreshToken: "my-refresh-token",
}
cmd = NewAuthenticate(ui, config, repo)
})
示例4:
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("set-space-role command", func() {
var (
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
spaceRepo *testapi.FakeSpaceRepository
userRepo *testapi.FakeUserRepository
configRepo core_config.ReadWriter
)
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
accessToken, err := testconfig.EncodeAccessToken(core_config.TokenInfo{Username: "current-user"})
Expect(err).NotTo(HaveOccurred())
configRepo.SetAccessToken(accessToken)
ui = &testterm.FakeUI{}
requirementsFactory = &testreq.FakeReqFactory{}
spaceRepo = &testapi.FakeSpaceRepository{}
userRepo = &testapi.FakeUserRepository{}
})
示例5:
"github.com/nttlabs/cli/cf/models"
"github.com/nttlabs/cli/cf/net"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testnet "github.com/nttlabs/cli/testhelpers/net"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/nttlabs/cli/cf/api/security_groups/defaults/running"
. "github.com/nttlabs/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("RunningSecurityGroupsRepo", func() {
var (
testServer *httptest.Server
testHandler *testnet.TestHandler
configRepo core_config.ReadWriter
repo RunningSecurityGroupsRepo
)
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
repo = NewRunningSecurityGroupsRepo(configRepo, gateway)
})
AfterEach(func() {
testServer.Close()
})
setupTestServer := func(reqs ...testnet.TestRequest) {
testServer, testHandler = testnet.NewServer(reqs)
示例6:
testapi "github.com/nttlabs/cli/cf/api/fakes"
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/errors"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
"time"
. "github.com/nttlabs/cli/cf/api"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("loggregator logs repository", func() {
var (
fakeConsumer *testapi.FakeLoggregatorConsumer
logsRepo LogsRepository
configRepo core_config.ReadWriter
fakeTokenRefresher *testapi.FakeAuthenticationRepository
)
BeforeEach(func() {
BufferTime = 1 * time.Millisecond
fakeConsumer = testapi.NewFakeLoggregatorConsumer()
configRepo = testconfig.NewRepositoryWithDefaults()
configRepo.SetLoggregatorEndpoint("loggregator-server.test.com")
configRepo.SetAccessToken("the-access-token")
fakeTokenRefresher = &testapi.FakeAuthenticationRepository{}
})
JustBeforeEach(func() {
logsRepo = NewLoggregatorLogsRepository(configRepo, fakeConsumer, fakeTokenRefresher)
})
示例7:
"github.com/nttlabs/cli/cf/net"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testnet "github.com/nttlabs/cli/testhelpers/net"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/nttlabs/cli/cf/api"
. "github.com/nttlabs/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("User Repository", func() {
var (
ccServer *httptest.Server
ccHandler *testnet.TestHandler
uaaServer *httptest.Server
uaaHandler *testnet.TestHandler
repo UserRepository
config core_config.ReadWriter
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
ccGateway := net.NewCloudControllerGateway((config), time.Now, &testterm.FakeUI{})
uaaGateway := net.NewUAAGateway(config, &testterm.FakeUI{})
repo = NewCloudControllerUserRepository(config, uaaGateway, ccGateway)
})
AfterEach(func() {
if uaaServer != nil {
uaaServer.Close()
}
示例8:
"github.com/nttlabs/cli/cf/net"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
"github.com/nttlabs/cli/testhelpers/maker"
testnet "github.com/nttlabs/cli/testhelpers/net"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/nttlabs/cli/cf/api"
. "github.com/nttlabs/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Services Repo", func() {
var (
testServer *httptest.Server
testHandler *testnet.TestHandler
configRepo core_config.ReadWriter
repo ServiceRepository
)
setupTestServer := func(reqs ...testnet.TestRequest) {
testServer, testHandler = testnet.NewServer(reqs)
configRepo.SetApiEndpoint(testServer.URL)
}
BeforeEach(func() {
configRepo = testconfig.NewRepositoryWithDefaults()
configRepo.SetAccessToken("BEARER my_access_token")
gateway := net.NewCloudControllerGateway(configRepo, time.Now, &testterm.FakeUI{})
repo = NewCloudControllerServiceRepository(configRepo, gateway)
})
示例9:
import (
testapi "github.com/nttlabs/cli/cf/api/fakes"
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/errors"
"github.com/nttlabs/cli/cf/models"
. "github.com/nttlabs/cli/cf/requirements"
testassert "github.com/nttlabs/cli/testhelpers/assert"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("DomainRequirement", func() {
var config core_config.ReadWriter
var ui *testterm.FakeUI
BeforeEach(func() {
ui = new(testterm.FakeUI)
config = testconfig.NewRepository()
config.SetOrganizationFields(models.OrganizationFields{Guid: "the-org-guid"})
})
It("succeeds when the domain is found", func() {
domain := models.DomainFields{Name: "example.com", Guid: "domain-guid"}
domainRepo := &testapi.FakeDomainRepository{FindByNameInOrgDomain: domain}
domainReq := NewDomainRequirement("example.com", ui, config, domainRepo)
success := domainReq.Execute()
Expect(success).To(BeTrue())
示例10:
{
"name": "vcap",
"build": "2222",
"support": "http://support.cloudfoundry.com",
"version": 2,
"description": "Cloud Foundry sponsored by Pivotal",
"authorization_endpoint": "https://login.example.com",
"api_version": "42.0.0"
}`)
}
var _ = Describe("Endpoints Repository", func() {
var (
config core_config.ReadWriter
gateway net.Gateway
testServer *httptest.Server
repo EndpointRepository
testServerFn func(w http.ResponseWriter, r *http.Request)
)
BeforeEach(func() {
config = testconfig.NewRepository()
testServer = httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
testServerFn(w, r)
}))
gateway = net.NewCloudControllerGateway((config), time.Now, &testterm.FakeUI{})
gateway.SetTrustedCerts(testServer.TLS.Certificates)
repo = NewEndpointRepository(config, gateway)
})
AfterEach(func() {
示例11:
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/models"
testassert "github.com/nttlabs/cli/testhelpers/assert"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/nttlabs/cli/cf/requirements"
. "github.com/nttlabs/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("TargetedOrganizationRequirement", func() {
var (
ui *testterm.FakeUI
config core_config.ReadWriter
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
config = testconfig.NewRepositoryWithDefaults()
})
Context("when the user has an org targeted", func() {
It("succeeds", func() {
req := NewTargetedOrgRequirement(ui, config)
success := req.Execute()
Expect(success).To(BeTrue())
})
})
示例12:
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/models"
testcmd "github.com/nttlabs/cli/testhelpers/commands"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testreq "github.com/nttlabs/cli/testhelpers/requirements"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("rename-org command", func() {
var (
requirementsFactory *testreq.FakeReqFactory
orgRepo *test_org.FakeOrganizationRepository
ui *testterm.FakeUI
configRepo core_config.ReadWriter
)
BeforeEach(func() {
requirementsFactory = &testreq.FakeReqFactory{}
orgRepo = &test_org.FakeOrganizationRepository{}
ui = new(testterm.FakeUI)
configRepo = testconfig.NewRepositoryWithDefaults()
})
var callRenameOrg = func(args []string) {
cmd := organization.NewRenameOrg(ui, configRepo, orgRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
}
示例13:
import (
"github.com/nttlabs/cli/cf/configuration/core_config"
"github.com/nttlabs/cli/cf/models"
. "github.com/nttlabs/cli/cf/requirements"
testassert "github.com/nttlabs/cli/testhelpers/assert"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/nttlabs/cli/testhelpers/matchers"
)
var _ = Describe("TargetedSpaceRequirement", func() {
var (
ui *testterm.FakeUI
config core_config.ReadWriter
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
config = testconfig.NewRepositoryWithDefaults()
})
Context("when the user has targeted a space", func() {
It("succeeds", func() {
req := NewTargetedSpaceRequirement(ui, config)
Expect(req.Execute()).To(BeTrue())
})
})
Context("when the user does not have a space targeted", func() {
示例14:
config = testconfig.NewRepository()
})
It("prompts the user to login", func() {
output := io_helpers.CaptureOutput(func() {
ui := NewUI(os.Stdin, NewTeePrinter())
ui.ShowConfiguration(config)
})
Expect(output).ToNot(ContainSubstrings([]string{"API endpoint:"}))
Expect(output).To(ContainSubstrings([]string{"Not logged in", "Use", "log in"}))
})
})
Context("when an api endpoint is set and the user logged in", func() {
var config core_config.ReadWriter
BeforeEach(func() {
accessToken := core_config.TokenInfo{
UserGuid: "my-user-guid",
Username: "my-user",
Email: "my-user-email",
}
config = testconfig.NewRepositoryWithAccessToken(accessToken)
config.SetApiEndpoint("https://test.example.org")
config.SetApiVersion("☃☃☃")
})
Describe("tells the user what is set in the config", func() {
var output []string
示例15:
"github.com/nttlabs/cli/cf/models"
"github.com/nttlabs/cli/cf/net"
testconfig "github.com/nttlabs/cli/testhelpers/configuration"
testnet "github.com/nttlabs/cli/testhelpers/net"
testterm "github.com/nttlabs/cli/testhelpers/terminal"
. "github.com/nttlabs/cli/cf/api"
. "github.com/nttlabs/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Buildpacks repo", func() {
var (
ts *httptest.Server
handler *testnet.TestHandler
config core_config.ReadWriter
repo BuildpackRepository
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
gateway := net.NewCloudControllerGateway((config), time.Now, &testterm.FakeUI{})
repo = NewCloudControllerBuildpackRepository(config, gateway)
})
AfterEach(func() {
ts.Close()
})
var setupTestServer = func(requests ...testnet.TestRequest) {
ts, handler = testnet.NewServer(requests)