Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add FileWithMetadata type to the core #110

Merged
merged 1 commit into from
Apr 23, 2021
Merged

Conversation

dpopp07
Copy link
Member

@dpopp07 dpopp07 commented Apr 21, 2021

FileWithMetadata is a struct that contains the binary data within a file, along
with specific metadata: the filename and the content type. This is a type that
the generated code occasionally uses. Currently, we generate this type as a
model on a specific service but because it is service-independent, we want to
move it to the core. This adds it as a supported type within the core. Although
the generator won't be able to change this type in options models until the next
major relase, it will use this type in the generated unmarshall functions, which
are currently broken. This will be fixed in the generator after this feature is
released.

The new "unmarshaler" in the core includes code to parse the JSON
string and read the data from the file while creating the struct. Generated
unmarshaller on service structs will invoke this new, working unmarshaller.

I have verified that this works and this PR will be a necessary dependency of my upcoming generator PR.

@padamstx
Copy link
Member

@dpopp07 Just noticed the builds for this PR failed due to the use of the testing.T.TempDir() function. That was apparently introduced in Go 1.15 and the minimum version of Go that we currently support in the core and SDKs is 1.12. Is there an alternative that you can use instead???

Copy link
Member

@padamstx padamstx 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 except for the TempDir() issue :)

var err error

// setup the test by creating a temp file for the unmarshaler to read
tempdir := t.TempDir() // this is automatically cleaned up
Copy link
Member

Choose a reason for hiding this comment

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

Need to code around the fact that TempDir() is not present until Go 1.15, but we currently support Go 1.12+

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah rats, I didn't notice that. I didn't realize I had Go 1.15 locally either but I guess I do. I can go back to what I was doing before I found that function and create my own temp dir

@dpopp07 dpopp07 force-pushed the dp/file-with-metadata branch 2 times, most recently from 7a2a858 to b990571 Compare April 22, 2021 21:50
FileWithMetadata is a struct that contains the binary data within a file, along
with specific metadata: the filename and the content type. This is a type that
the generated code occasionally uses. Currently, we generate this type as a
model on a specific service but because it is service-independent, we want to
move it to the core. This adds it as a supported type within the core. Although
the generator won't be able to change this type in options models until the next
major relase, it will use this type in the generated unmarshall functions, which
are currently broken. This will be fixed in the generator after this feature is
released.

The new "unmarshaler" in the core includes code to parse the JSON
string and read the data from the file while creating the struct. Generated
unmarshaller on service structs will invoke this new, working unmarshaller.
Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

LGTM

@dpopp07 dpopp07 merged commit c1a4884 into main Apr 23, 2021
@dpopp07 dpopp07 deleted the dp/file-with-metadata branch April 23, 2021 14:30
ibm-devx-sdk pushed a commit that referenced this pull request Apr 23, 2021
# [5.4.0](v5.3.0...v5.4.0) (2021-04-23)

### Bug Fixes

* eliminate goroutine leak in the authenticators ([#109](#109)) ([e5d921a](e5d921a))

### Features

* add FileWithMetadata type to the core ([#110](#110)) ([c1a4884](c1a4884))
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 5.4.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants