Skip to content

Conversation

@kneekey23
Copy link
Contributor

@kneekey23 kneekey23 commented Jan 13, 2022

Description of changes

This PR fixes S3 compiler errors with decoding non optional associated values on enums. This additionally changes our decoding of enums with associated values from needing return statemetns everywhere to one switch statement based on the key in the container.

init(from decoder: Decoder) throws {
    let containerValues = try decoder.container(keyedBy: CodingKeys.self)
    let key = containerValues.allKeys.first
    
    switch key {
    case .empty:
        self = .empty
    case .domain:
        let domain = try container.decode(
            String.self,
            forKey: .editing
        )
        self = .domain(domain)
    case .port:
        let port = try container.decode(
            Int.self,
            forKey: .port
        )
        self = .port(port)
    default:
        self = .sdkUnknown("")
    }
}

Scope

  • [ x] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@kneekey23 kneekey23 requested a review from a team as a code owner January 13, 2022 05:59
@kneekey23 kneekey23 requested a review from wooj2 January 13, 2022 06:01
Copy link
Contributor

@wooj2 wooj2 left a comment

Choose a reason for hiding this comment

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

Chatted offline - approving assuming that changes are made and unit tests do not need to be updated.

Thanks so much for handling this!

@kneekey23 kneekey23 merged commit 6d90db5 into main Jan 15, 2022
@kneekey23 kneekey23 deleted the fix/s3decode branch January 15, 2022 18:34
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