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

Infer XML namespace using connectHost #96

Merged
merged 2 commits into from
Jun 8, 2018
Merged

Conversation

krisis
Copy link
Member

@krisis krisis commented Jun 7, 2018

While GCS is S3 v4 compatible, it uses a different xml namespace url
than AWS (and Minio).

, connectAccessKey = ""
, connectSecretKey = ""
, connectIsSecure = True
, connectSvcNamespace = "http://doc.s3.amazonaws.com/2006-03-01"
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a bug in GCS, why do you need to enforce namespace? @krisis can we not unmarshal/marshal without it?

Copy link
Member

Choose a reason for hiding this comment

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

Even if we have no way to avoid it, I would prefer to avoid providing this as part of connectInfo since this is clearly a bug in GCS and they should fix it. So for such a reason we could simply handle this internally based on the connectHost variable pointing to GCS.

Copy link
Member Author

Choose a reason for hiding this comment

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

@donatello @harshavardhana so, should I check if `connectHost == "storage.googleapis.com" and use a different xml namespace?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this seems to be a good way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

, connectAccessKey = ""
, connectSecretKey = ""
, connectIsSecure = True
, connectSvcNamespace = "http://doc.s3.amazonaws.com/2006-03-01"
Copy link
Member

Choose a reason for hiding this comment

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

Yes, this seems to be a good way.

While GCS is S3 v4 compatible, it uses a different xml namespace url
than AWS (and Minio).
@krisis krisis changed the title Take xml namespace as part of ConnectInfo Infer XML namespace using connectHost Jun 8, 2018
@donatello
Copy link
Member

There are some buidl warnings:

/home/travis/build/minio/minio-hs/src/Network/Minio/JsonParser.hs:30:36: warning: [-Wunused-top-binds]
    Defined but not used: ‘aeCode’
   |
30 | data AdminErrJSON = AdminErrJSON { aeCode    :: Text
   |                                    ^^^^^^
/home/travis/build/minio/minio-hs/src/Network/Minio/JsonParser.hs:31:36: warning: [-Wunused-top-binds]
    Defined but not used: ‘aeMessage’
   |
31 |                                  , aeMessage :: Text
   |                                    ^^^^^^^^^

@harshavardhana
Copy link
Member

/home/travis/build/minio/minio-hs/src/Network/Minio/JsonParser.hs:30:36: warning: [-Wunused-top-binds]
Defined but not used: ‘aeCode’
|
30 | data AdminErrJSON = AdminErrJSON { aeCode :: Text
| ^^^^^^
/home/travis/build/minio/minio-hs/src/Network/Minio/JsonParser.hs:31:36: warning: [-Wunused-top-binds]
Defined but not used: ‘aeMessage’
|
31 | , aeMessage :: Text
| ^^^^^^^^^

That would be my mistake

data AdminErrJSON = AdminErrJSON { aeCode    :: Text
                                 , aeMessage :: Text
                                 } deriving (Eq, Show)
instance FromJSON AdminErrJSON where
  parseJSON = withObject "AdminErrJSON" $ \v -> AdminErrJSON
    <$> v .: "Code"
    <*> v .: "Message"

parseErrResponseJSON :: (MonadIO m) => LByteString -> m ServiceErr
parseErrResponseJSON jsondata =
  case eitherDecode jsondata of
    Right (AdminErrJSON code message) -> return $ toServiceErr code message
    Left err                          -> throwIO $ MErrVJsonParse $ T.pack err

Since we didn't use the aeCode it complains, is there a way to turn this off?

@harshavardhana harshavardhana merged commit 7564cbd into minio:master Jun 8, 2018
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.

3 participants