Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

[CO-388] Pull out cardano-x509-certificates internals as a library #3610

Merged
merged 3 commits into from
Sep 18, 2018

Conversation

KtorZ
Copy link
Contributor

@KtorZ KtorZ commented Sep 17, 2018

Description

This module was currently defined as a binary executable for
cardano-sl-tools which makes it impossible to require it from any other
library. Ideally, we would like to keep the executable as it is but have
the library exposed somewhere else. That will come in handy for
integration tests and also in the launcher code.

Doing so, I've also removed the {#- RecordWildCards -#} extension
and turned non specific imports to specific ones. Apart from that, there's no
real logical change, just a bit of reshuffling.

Linked issue

[CO-387]

Type of change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🛠 New feature (non-breaking change which adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
  • 🏭 Refactoring that does not change existing functionality but does improve things like code readability, structure etc
  • 🔨 New or improved tests for existing code
  • ⛑ git-flow chore (backport, hotfix, etc)

Developer checklist

  • I have read the style guide document, and my code follows the code style of this project.
  • If my code deals with exceptions, it follows the guidelines.
  • I have updated any documentation accordingly, if needed. Documentation changes can be reflected in opening a PR on cardanodocs.com, amending the inline Haddock comments, any relevant README file or one of the document listed in the docs directory.
  • CHANGELOG entry has been added and is linked to the correct PR on GitHub.

Testing checklist

  • [ ] I have added tests to cover my changes.
  • All new and existing tests passed.

QA Steps

Screenshots (if available)

This module was currently defined as a binary executable for
cardano-sl-tools which makes it impossible to require it from any other
library. Ideally, we would like to keep the executable as it is but have
the library exposed somewhere else. That will come in handy for
integration tests and also in the launcher code.

Doing so, I've also removed the {#- RecordWildCards -#} extension
and turned non specific imports to specific ones.
@KtorZ KtorZ requested a review from erikd September 17, 2018 10:05
@KtorZ KtorZ force-pushed the KtorZ/CO-388/cardano-sl-x509-as-library branch from d5cc158 to 8f20d8e Compare September 17, 2018 10:06
@KtorZ
Copy link
Contributor Author

KtorZ commented Sep 17, 2018

@disassembler @cleverca22
After this, there's work that can be done to simplify a bit the Launcher and installers. There's no need to have the cardano-x509-certificate executable available; functions can directly be called from Haskell 👍

(serverHost, serverPort)
cert
writeCredentials (certOutDir desc </> certFilename desc) (key, cert)
writeCertificate (certOutDir desc </> caName) caCert
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removing {-# RecordWildCards #-} extension and defining cmdParser at a higher level for readability. All indentation has therefore shifted.

-- * Effectful Functions
, ConfigurationKey(..)
, decodeConfigFile
, genCertificate
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Re-organizing the exports to be clearer since this is now a library.


addMinutes :: Int -> DateTime -> DateTime
addMinutes n time =
timeAdd time (Minutes $ fromIntegral n)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

genCertificate used to be defined in gencerts/Main.hs, I pulled it into the library since it's quite a re-usable piece.

@KtorZ
Copy link
Contributor Author

KtorZ commented Sep 17, 2018

One possible addition after this (or part of this) could be to have a simple tests, generating certificates and verifying that they're all valid. That could easily be done with a quickcheck properties generating random TLSConfiguration and DirConfiguration

Basically, moving the following into a property-test:

https://github.com/input-output-hk/cardano-sl/pull/3610/files#diff-9b47b231386b7696c4cb3f91a7929b9fR82

Copy link
Member

@erikd erikd left a comment

Choose a reason for hiding this comment

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

There is a property test upcoming, so lets go with this.

@KtorZ KtorZ merged commit 7ebfe13 into develop Sep 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants