diff --git a/pkg/supply/env/config.go b/pkg/supply/env/config.go index c3cbbb4..001845a 100644 --- a/pkg/supply/env/config.go +++ b/pkg/supply/env/config.go @@ -21,23 +21,10 @@ type amsDataDeprecated struct { } type VcapApplication struct { - ApplicationID string `json:"application_id"` - ApplicationName string `json:"application_name"` - ApplicationUris []string `json:"application_uris"` - CfAPI string `json:"cf_api"` - Limits struct { - Fds int `json:"fds"` - } `json:"limits"` - Name string `json:"name"` - OrganizationID string `json:"organization_id"` - OrganizationName string `json:"organization_name"` - SpaceID string `json:"space_id"` - SpaceName string `json:"space_name"` - Uris []string `json:"uris"` - Users any `json:"users"` + ApplicationName string `json:"application_name"` } -func LoadVcapApplication(log *libbuildpack.Logger) (VcapApplication, error) { +func LoadVcapApplication(log *libbuildpack.Logger) VcapApplication { vcapStr, vcapSet := os.LookupEnv("VCAP_APPLICATION") var result VcapApplication if vcapSet { @@ -46,7 +33,7 @@ func LoadVcapApplication(log *libbuildpack.Logger) (VcapApplication, error) { log.Error("error parsing VCAP_APPLICATION value %s : %v", vcapStr, err) } } - return result, nil + return result } func LoadBuildpackConfig(log *libbuildpack.Logger) (Config, error) { diff --git a/pkg/supply/supply.go b/pkg/supply/supply.go index f839d03..c478e37 100644 --- a/pkg/supply/supply.go +++ b/pkg/supply/supply.go @@ -280,18 +280,16 @@ func (s *Supplier) upload(creds *services.IASCredentials, tlsCfg tlsConfig, root if err != nil { return fmt.Errorf("unable to create AMS client: %s", err) } - vcapApp, err := env.LoadVcapApplication(s.Log) - if err != nil { - return err - } + vcapApp := env.LoadVcapApplication(s.Log) + u := uploader.Uploader{ Log: s.Log, Root: path.Join(s.Stager.BuildDir(), rootDir), Client: client, AMSInstanceID: creds.AmsInstanceID, ExtraHeaders: map[string]string{ - "User-Agent": fmt.Sprintf("cloud-authorization-buildpack/%s", s.BuildpackVersion), - "X-Cf-Appname": vcapApp.ApplicationName, + "User-Agent": fmt.Sprintf("cloud-authorization-buildpack/%s", s.BuildpackVersion), + "X-Appname": vcapApp.ApplicationName, }, } return u.Do(context.Background(), creds.AmsServerURL) diff --git a/pkg/supply/supply_test.go b/pkg/supply/supply_test.go index 51790c3..2eddae6 100644 --- a/pkg/supply/supply_test.go +++ b/pkg/supply/supply_test.go @@ -179,7 +179,7 @@ var _ = Describe("Supply", func() { It("sets the cf app name as upload header", func() { Expect(supplier.Run()).To(Succeed()) expectedValue := []string{"unit-tests-appname"} - Expect(uploadReqSpy.Header).Should(HaveKeyWithValue("X-Cf-Appname", expectedValue)) + Expect(uploadReqSpy.Header).Should(HaveKeyWithValue("X-Appname", expectedValue)) }) It("creates a valid launch.yml", func() { Expect(supplier.Run()).To(Succeed())