Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Write dateTime server-side
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Galic committed Sep 8, 2018
1 parent 77bfbf6 commit 64a22cf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 33 deletions.
8 changes: 1 addition & 7 deletions README.md
Expand Up @@ -30,18 +30,12 @@ How to verify the most important user journeys are not broken without writing a
@Provides
@Singleton
def getTip(config: Config): Tip = {
val now = DateTimeFormat
.forPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
.withZone(DateTimeZone.UTC)
.print(DateTime.now())

val tipConfig = TipConfig(
owner = "guardian",
repo = "identity",
personalAccessToken = config.Tip.personalAccessToken, // set to empty string "" if you do not need GitHub label functionality
label = "Verified in PROD",
boardSha = BuildInfo.GitHeadSha,
deployTime = now
boardSha = BuildInfo.GitHeadSha
)

if (config.App.stage == "PROD")
Expand Down
7 changes: 3 additions & 4 deletions cloud/tip-create-board.js
Expand Up @@ -2,15 +2,15 @@ const AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'});
const ddb = new AWS.DynamoDB.DocumentClient();

function registerBoard(sha, board, repo, deployTime) {
function registerBoard(sha, board, repo) {
return ddb.put(
{
TableName: 'TipCloud-PROD',
Item: {
sha: sha,
board: board,
repo: repo,
deployTime: deployTime
deployTime: (new Date()).toISOString()
}
}
).promise();
Expand All @@ -22,8 +22,7 @@ exports.handler = (event, context, callback) => {
const board = body.board;
const sha = body.sha;
const repo = body.repo;
const deployTime = body.deployTime;

registerBoard(sha, board, repo, deployTime)
registerBoard(sha, board, repo)
.then(() => callback(null, {statusCode: 200, body: `{"field": "value"}`}));
};
13 changes: 5 additions & 8 deletions src/main/scala/com/gu/tip/Configuration.scala
Expand Up @@ -12,14 +12,11 @@ import scala.io.Source

// $COVERAGE-OFF$

case class TipConfig(
owner: String,
repo: String,
personalAccessToken: String,
label: String,
boardSha: String = "",
deployTime: String = ""
)
case class TipConfig(owner: String,
repo: String,
personalAccessToken: String,
label: String,
boardSha: String = "")

class TipConfigurationException(
msg: String = "Missing TiP config. Please refer to README.")
Expand Down
9 changes: 3 additions & 6 deletions src/main/scala/com/gu/tip/Tip.scala
Expand Up @@ -123,8 +123,7 @@ object Tip
val sha = configuration.tipConfig.boardSha
val repo =
s"${configuration.tipConfig.owner}/${configuration.tipConfig.repo}"
val deployTime = configuration.tipConfig.deployTime
createBoard(sha, repo, deployTime).run.attempt
createBoard(sha, repo).run.attempt
.unsafeRunSync()
}
}
Expand All @@ -139,8 +138,7 @@ object TipFactory {
val sha = configuration.tipConfig.boardSha
val repo =
s"${configuration.tipConfig.owner}/${configuration.tipConfig.repo}"
val deployTime = configuration.tipConfig.deployTime
createBoard(sha, repo, deployTime).run.attempt
createBoard(sha, repo).run.attempt
.unsafeRunSync()
}
}
Expand All @@ -155,8 +153,7 @@ object TipFactory {
val sha = configuration.tipConfig.boardSha
val repo =
s"${configuration.tipConfig.owner}/${configuration.tipConfig.repo}"
val deployTime = configuration.tipConfig.deployTime
createBoard(sha, repo, deployTime).run.attempt
createBoard(sha, repo).run.attempt
.unsafeRunSync()
}
}
Expand Down
11 changes: 3 additions & 8 deletions src/main/scala/com/gu/tip/cloud/TipCloudApi.scala
Expand Up @@ -8,9 +8,7 @@ import com.typesafe.scalalogging.LazyLogging
import net.liftweb.json._

trait TipCloudApiIf { this: HttpClientIf with ConfigurationIf =>
def createBoard(sha: String,
repo: String,
deployTime: String): WriterT[IO, List[Log], String]
def createBoard(sha: String, repo: String): WriterT[IO, List[Log], String]
def verifyPath(sha: String, name: String): WriterT[IO, List[Log], String]
def getBoard(sha: String): WriterT[IO, List[Log], String]
}
Expand All @@ -21,10 +19,8 @@ trait TipCloudApi extends TipCloudApiIf with LazyLogging {
val tipCloudApiRoot =
"https://i2i2l4x9kl.execute-api.eu-west-1.amazonaws.com/PROD"

override def createBoard(
sha: String,
repo: String,
deployTime: String): WriterT[IO, List[Log], String] = {
override def createBoard(sha: String,
repo: String): WriterT[IO, List[Log], String] = {
val paths = configuration.readPaths("tip.yaml")

val board = paths.map { path =>
Expand All @@ -41,7 +37,6 @@ trait TipCloudApi extends TipCloudApiIf with LazyLogging {
|{
| "sha": "$sha",
| "repo": "$repo",
| "deployTime": "$deployTime",
| "board": [
| ${board.mkString(",")}
| ]
Expand Down

0 comments on commit 64a22cf

Please sign in to comment.