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

Method Update

cf/api/buildpacks.go:134–160  ·  view source on GitHub ↗
(buildpack models.Buildpack)

Source from the content-addressed store, hash-verified

132}
133
134func (repo CloudControllerBuildpackRepository) Update(buildpack models.Buildpack) (updatedBuildpack models.Buildpack, apiErr error) {
135 path := fmt.Sprintf("%s/%s", buildpacksPath, buildpack.GUID)
136
137 entity := resources.BuildpackEntity{
138 Name: buildpack.Name,
139 Position: buildpack.Position,
140 Enabled: buildpack.Enabled,
141 Key: "",
142 Filename: "",
143 Locked: buildpack.Locked,
144 }
145
146 body, err := json.Marshal(entity)
147 if err != nil {
148 apiErr = fmt.Errorf("%s: %s", T("Could not serialize updates."), err.Error())
149 return
150 }
151
152 resource := new(resources.BuildpackResource)
153 apiErr = repo.gateway.UpdateResource(repo.config.APIEndpoint(), path, bytes.NewReader(body), resource)
154 if apiErr != nil {
155 return
156 }
157
158 updatedBuildpack = resource.ToFields()
159 return
160}
161
162const buildpacksPath = "/v2/buildpacks"

Callers

nothing calls this directly

Calls 4

UpdateResourceMethod · 0.80
ErrorMethod · 0.65
APIEndpointMethod · 0.65
ToFieldsMethod · 0.65

Tested by

no test coverage detected