本文整理匯總了Golang中github.com/cloudfoundry/cli/cf/configuration.ReadWriter類的典型用法代碼示例。如果您正苦於以下問題:Golang ReadWriter類的具體用法?Golang ReadWriter怎麽用?Golang ReadWriter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了ReadWriter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Init
func Init(config configuration.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 configuration.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 = NewCloudControllerAppFilesRepository(config, cloudControllerGateway)
loc.appRepo = NewCloudControllerApplicationRepository(config, cloudControllerGateway)
loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway)
loc.appInstancesRepo = 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 = NewCloudControllerPasswordRepository(config, uaaGateway)
loc.quotaRepo = quotas.NewCloudControllerQuotaRepository(config, cloudControllerGateway)
loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway)
loc.stackRepo = 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)
return
}
示例3: NewRepositoryLocator
func NewRepositoryLocator(config configuration.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 = 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, nil)
loc.appBitsRepo = NewCloudControllerApplicationBitsRepository(config, cloudControllerGateway, app_files.ApplicationZipper{})
loc.appEventsRepo = NewCloudControllerAppEventsRepository(config, cloudControllerGateway, strategy)
loc.appFilesRepo = NewCloudControllerAppFilesRepository(config, cloudControllerGateway)
loc.appRepo = NewCloudControllerApplicationRepository(config, cloudControllerGateway)
loc.appSummaryRepo = NewCloudControllerAppSummaryRepository(config, cloudControllerGateway)
loc.appInstancesRepo = 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 = NewCloudControllerOrganizationRepository(config, cloudControllerGateway)
loc.passwordRepo = NewCloudControllerPasswordRepository(config, uaaGateway)
loc.quotaRepo = NewCloudControllerQuotaRepository(config, cloudControllerGateway)
loc.routeRepo = NewCloudControllerRouteRepository(config, cloudControllerGateway)
loc.stackRepo = NewCloudControllerStackRepository(config, cloudControllerGateway)
loc.serviceRepo = NewCloudControllerServiceRepository(config, cloudControllerGateway)
loc.serviceBindingRepo = NewCloudControllerServiceBindingRepository(config, cloudControllerGateway)
loc.serviceBrokerRepo = NewCloudControllerServiceBrokerRepository(config, cloudControllerGateway)
loc.serviceSummaryRepo = NewCloudControllerServiceSummaryRepository(config, cloudControllerGateway)
loc.spaceRepo = 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.appSecurityGroupRepo = NewSecurityGroupRepo(config, cloudControllerGateway)
loc.stagingSecurityGroupRepo = NewStagingSecurityGroupsRepo(config, cloudControllerGateway)
return
}
示例4:
testapi "github.com/cloudfoundry/cli/testhelpers/api"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testnet "github.com/cloudfoundry/cli/testhelpers/net"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"net/http"
"net/http/httptest"
"net/url"
"time"
)
var _ = Describe("User Repository", func() {
var (
ccServer *httptest.Server
ccHandler *testnet.TestHandler
uaaServer *httptest.Server
uaaHandler *testnet.TestHandler
repo UserRepository
config configuration.ReadWriter
)
BeforeEach(func() {
config = testconfig.NewRepositoryWithDefaults()
ccGateway := net.NewCloudControllerGateway((config), time.Now)
uaaGateway := net.NewUAAGateway(config)
repo = NewCloudControllerUserRepository(config, uaaGateway, ccGateway)
})
AfterEach(func() {
if uaaServer != nil {
uaaServer.Close()
}
示例5:
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("target command", func() {
var (
orgRepo *testapi.FakeOrgRepository
spaceRepo *testapi.FakeSpaceRepository
requirementsFactory *testreq.FakeReqFactory
config configuration.ReadWriter
ui *testterm.FakeUI
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
orgRepo = new(testapi.FakeOrgRepository)
spaceRepo = new(testapi.FakeSpaceRepository)
requirementsFactory = new(testreq.FakeReqFactory)
config = testconfig.NewRepositoryWithDefaults()
})
var callTarget = func(args []string) {
cmd := NewTarget(ui, config, orgRepo, spaceRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
示例6:
config = testconfig.NewRepository()
})
It("prompts the user to login", func() {
output := io_helpers.CaptureOutput(func() {
ui := NewUI((os.Stdin))
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 configuration.ReadWriter
BeforeEach(func() {
accessToken := configuration.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
示例7:
import (
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/models"
. "github.com/cloudfoundry/cli/cf/requirements"
testassert "github.com/cloudfoundry/cli/testhelpers/assert"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("TargetedSpaceRequirement", func() {
var (
ui *testterm.FakeUI
config configuration.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() {
示例8: callApi
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
func callApi(args []string, config configuration.ReadWriter, endpointRepo *testapi.FakeEndpointRepo) (ui *testterm.FakeUI) {
ui = new(testterm.FakeUI)
cmd := NewApi(ui, config, endpointRepo)
requirementsFactory := &testreq.FakeReqFactory{}
testcmd.RunCommand(cmd, args, requirementsFactory)
return
}
var _ = Describe("api command", func() {
var (
config configuration.ReadWriter
endpointRepo *testapi.FakeEndpointRepo
)
BeforeEach(func() {
config = testconfig.NewRepository()
endpointRepo = &testapi.FakeEndpointRepo{}
})
Context("when the api endpoint's ssl certificate is invalid", func() {
It("warns the user and prints out a tip", func() {
endpointRepo.UpdateEndpointError = errors.NewInvalidSSLCert("https://buttontomatoes.org", "why? no. go away")
ui := callApi([]string{"https://buttontomatoes.org"}, config, endpointRepo)
Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"SSL Cert", "https://buttontomatoes.org"},
示例9:
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/models"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("rename-space command", func() {
var (
ui *testterm.FakeUI
configRepo configuration.ReadWriter
requirementsFactory *testreq.FakeReqFactory
spaceRepo *testapi.FakeSpaceRepository
)
BeforeEach(func() {
ui = new(testterm.FakeUI)
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedOrgSuccess: true}
spaceRepo = &testapi.FakeSpaceRepository{}
})
var callRenameSpace = func(args []string) {
cmd := NewRenameSpace(ui, configRepo, spaceRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
}
示例10:
import (
"os"
"path/filepath"
"github.com/cloudfoundry/cli/cf/configuration"
"github.com/cloudfoundry/cli/cf/i18n"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
"github.com/pivotal-cf-experimental/jibber_jabber"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("i18n.Init() function", func() {
var (
configRepo configuration.ReadWriter
)
BeforeEach(func() {
i18n.Resources_path = filepath.Join("cf", "i18n", "test_fixtures")
configRepo = testconfig.NewRepositoryWithDefaults()
})
Describe("When a user has a locale configuration set", func() {
Context("creates a valid T function", func() {
BeforeEach(func() {
configRepo.SetLocale("en_US")
})
It("returns a usable T function for simple strings", func() {
T := i18n.Init(configRepo)
示例11:
"github.com/cloudfoundry/cli/cf/models"
"github.com/cloudfoundry/cli/cf/net"
testapi "github.com/cloudfoundry/cli/testhelpers/api"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
"github.com/cloudfoundry/cli/testhelpers/maker"
testnet "github.com/cloudfoundry/cli/testhelpers/net"
. "github.com/cloudfoundry/cli/cf/api"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Services Repo", func() {
var (
testServer *httptest.Server
testHandler *testnet.TestHandler
configRepo configuration.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)
repo = NewCloudControllerServiceRepository(configRepo, gateway)
})
示例12:
"github.com/cloudfoundry/cli/cf/configuration"
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/cf/commands"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("config command", func() {
var (
ui *testterm.FakeUI
configRepo configuration.ReadWriter
requirementsFactory *testreq.FakeReqFactory
)
BeforeEach(func() {
ui = &testterm.FakeUI{}
configRepo = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{}
})
runCommand := func(args ...string) {
cmd := NewConfig(ui, configRepo)
testcmd.RunCommand(cmd, args, requirementsFactory)
}
It("fails requirements when no flags are provided", func() {
runCommand()
示例13:
{
"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 configuration.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)
gateway.SetTrustedCerts(testServer.TLS.Certificates)
repo = NewEndpointRepository(config, gateway)
})
AfterEach(func() {
示例14:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testreq "github.com/cloudfoundry/cli/testhelpers/requirements"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/cloudfoundry/cli/cf/commands/organization"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("delete-org command", func() {
var (
config configuration.ReadWriter
ui *testterm.FakeUI
requirementsFactory *testreq.FakeReqFactory
orgRepo *test_org.FakeOrganizationRepository
org models.Organization
)
BeforeEach(func() {
ui = &testterm.FakeUI{
Inputs: []string{"y"},
}
config = testconfig.NewRepositoryWithDefaults()
requirementsFactory = &testreq.FakeReqFactory{}
org = models.Organization{}
org.Name = "org-to-delete"
org.Guid = "org-to-delete-guid"
orgRepo = &test_org.FakeOrganizationRepository{}
示例15:
testcmd "github.com/cloudfoundry/cli/testhelpers/commands"
testconfig "github.com/cloudfoundry/cli/testhelpers/configuration"
testterm "github.com/cloudfoundry/cli/testhelpers/terminal"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/cloudfoundry/cli/testhelpers/matchers"
)
var _ = Describe("Login Command", func() {
var (
Flags []string
Config configuration.ReadWriter
ui *testterm.FakeUI
authRepo *testapi.FakeAuthenticationRepository
endpointRepo *testapi.FakeEndpointRepo
orgRepo *fake_organizations.FakeOrganizationRepository
spaceRepo *testapi.FakeSpaceRepository
org models.Organization
)
BeforeEach(func() {
Flags = []string{}
Config = testconfig.NewRepository()
ui = &testterm.FakeUI{}
authRepo = &testapi.FakeAuthenticationRepository{
AccessToken: "my_access_token",
RefreshToken: "my_refresh_token",
Config: Config,
}