Skip to content

Set buildpack version as header on dcl upload#93

Merged
f-blass merged 4 commits intomainfrom
version-header
Aug 14, 2024
Merged

Set buildpack version as header on dcl upload#93
f-blass merged 4 commits intomainfrom
version-header

Conversation

@f-blass
Copy link
Copy Markdown
Member

@f-blass f-blass commented Aug 14, 2024

better traceability which versions are used.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't fully understand the approach here. There is a setter, that is always called und gets the value from the manifest. It does not look clean to me. I see better ways to achieve that. I did not think it trough yet but. I have two ideas:

  1. Let the uploader read the version from the manifest directly
  2. Or better: parameterize the User-Agent Header value for the uploader (for example add it to the Uploader struct type)

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reason: see last comment

@f-blass
Copy link
Copy Markdown
Member Author

f-blass commented Aug 14, 2024

Originally I wanted to use build flags, which however is not possible with the buildpack packager.

I thought about adding it to the Uploader struct aswell. I didn't like it either, because you would need to pass it also to all other structs if required somewhere else. Adding the whole manifest to the uploader seems even worse, because the uploader should not even need to know that it is running in the context of a buildpack.

Since the project is rather small and we do not have HTTP calls anywhere else outside of the uploader, I'll add it to the Uploader struct for now.

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a little beautification.

Root: path.Join(s.Stager.BuildDir(), rootDir),
Client: client,
AMSInstanceID: creds.AmsInstanceID,
UserAgent: fmt.Sprintf("cloud-authorization-buildpack/%s", buildpackVersion),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserAgent: fmt.Sprintf("cloud-authorization-buildpack/%s", buildpackVersion),
UserAgent: fmt.Sprintf("cloud-authorization-buildpack/%s", s.BuildpackVersion),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need to make to provide an attribute as a parameter to a private funtion.

}

func (s *Supplier) upload(creds *services.IASCredentials, tlsCfg tlsConfig, rootDir string) error {
func (s *Supplier) upload(creds *services.IASCredentials, tlsCfg tlsConfig, rootDir, buildpackVersion string) error {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
func (s *Supplier) upload(creds *services.IASCredentials, tlsCfg tlsConfig, rootDir, buildpackVersion string) error {
func (s *Supplier) upload(creds *services.IASCredentials, tlsCfg tlsConfig, rootDir) error {

}
if cfg.ShouldUpload {
if err := s.upload(identityCreds, tlsCfg, cfg.Root); err != nil {
if err := s.upload(identityCreds, tlsCfg, cfg.Root, s.BuildpackVersion); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if err := s.upload(identityCreds, tlsCfg, cfg.Root, s.BuildpackVersion); err != nil {
if err := s.upload(identityCreds, tlsCfg, cfg.Root); err != nil {

Copy link
Copy Markdown

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good now :-)

@f-blass f-blass merged commit 94b9c67 into main Aug 14, 2024
@f-blass f-blass deleted the version-header branch August 14, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants