MCPcopy Index your code
hub / github.com/cloudfoundry/cli / getServiceKeyByServiceInstanceAndName

Method getServiceKeyByServiceInstanceAndName

actor/v7action/service_key.go:143–173  ·  view source on GitHub ↗
(serviceInstanceName, serviceKeyName, spaceGUID string)

Source from the content-addressed store, hash-verified

141}
142
143func (actor Actor) getServiceKeyByServiceInstanceAndName(serviceInstanceName, serviceKeyName, spaceGUID string) (resources.ServiceCredentialBinding, ccv3.Warnings, error) {
144 var (
145 serviceInstance resources.ServiceInstance
146 keys []resources.ServiceCredentialBinding
147 )
148
149 warnings, err := railway.Sequentially(
150 func() (warnings ccv3.Warnings, err error) {
151 serviceInstance, _, warnings, err = actor.getServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
152 return
153 },
154 func() (warnings ccv3.Warnings, err error) {
155 keys, warnings, err = actor.CloudControllerClient.GetServiceCredentialBindings(
156 ccv3.Query{Key: ccv3.ServiceInstanceGUIDFilter, Values: []string{serviceInstance.GUID}},
157 ccv3.Query{Key: ccv3.TypeFilter, Values: []string{"key"}},
158 ccv3.Query{Key: ccv3.NameFilter, Values: []string{serviceKeyName}},
159 ccv3.Query{Key: ccv3.PerPage, Values: []string{"1"}},
160 ccv3.Query{Key: ccv3.Page, Values: []string{"1"}},
161 )
162 return
163 },
164 )
165 switch {
166 case err != nil:
167 return resources.ServiceCredentialBinding{}, warnings, err
168 case len(keys) == 0:
169 return resources.ServiceCredentialBinding{}, warnings, actionerror.NewServiceKeyNotFoundError(serviceKeyName, serviceInstanceName)
170 default:
171 return keys[0], warnings, nil
172 }
173}

Implementers 1

FakeActorcommand/v7/v7fakes/fake_actor.go

Calls 4

SequentiallyFunction · 0.92

Tested by

no test coverage detected