Skip to content

Commit

Permalink
release 1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenchristopher-zip committed Sep 25, 2022
1 parent 163d6c0 commit 4c2f449
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 56 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ spinnakerBundle {
pluginId = "zip.deployboard"
description = "Customization for Zip deploys"
provider = "https://github.com/Greenbax/zip-spinnaker-deployboard"
version = "1.0.4"
version = "1.0.5"
}
8 changes: 4 additions & 4 deletions plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"provider": "https://github.com/Greenbax/zip-spinnaker-deployboard",
"releases": [
{
"version": "1.0.4",
"date": "2022-09-25T04:44:21.010550Z",
"version": "1.0.5",
"date": "2022-09-25T05:17:26.384791Z",
"requires": "gate>=0.0.0,orca>=0.0.0,deck>=0.0.0",
"sha512sum": "42bb9770ca483305eb45bcb5ff5c5f35c6aeb4f2f19de1cfc8e7a0184e8c84e5c24b1745fa646471876f1e1420bebb4d179023a6468a9c05b47b9604ccc0b798",
"sha512sum": "ab06c9830d7ddfb84a8b832ea814abe8714343ad0f8c55ef04cdcab2fc9a9ad37df6927addeb820215adbd5a6d5b086161d67ca979657dd1a8a3cac41f6b830f",
"state": "",
"url": "https://github.com/Greenbax/zip-spinnaker-deployboard/releases/download/v1.0.4/zip-spinnaker-deployboard.zip"
"url": "https://github.com/Greenbax/zip-spinnaker-deployboard/releases/download/v1.0.5/zip-spinnaker-deployboard.zip"
}
]
}
Expand Down
1 change: 1 addition & 0 deletions zip-deployboard-gate/zip-deployboard-gate.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
compileOnly "io.spinnaker.gate:gate-api:$gateVersion"

implementation 'com.amazonaws:aws-java-sdk-dynamodb'
implementation 'com.amazonaws:aws-java-sdk-sts'
}

compileJava {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
package io.ziphq.deployboard;

import com.amazonaws.auth.WebIdentityTokenCredentialsProvider;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.netflix.spinnaker.orca.api.pipeline.Task;
import com.netflix.spinnaker.orca.api.pipeline.TaskResult;
import com.netflix.spinnaker.orca.api.pipeline.graph.StageDefinitionBuilder;
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution;
import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode.Builder;

import com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Item;
import com.amazonaws.services.dynamodbv2.document.Table;

public class DynamoStatusPlugin extends Plugin {

Expand All @@ -38,40 +24,3 @@ public void stop() {
}
}

@Extension
class DynamoStatusStage implements StageDefinitionBuilder {
public void taskGraph(StageExecution stage, Builder builder) {
builder.withTask("dynamoStatus", DynamoStatusTask.class);
}
}

@Extension
class DynamoStatusTask implements Task {
private String dynamoTableName = "zip-spinnaker-ci-deploys";

public TaskResult execute(StageExecution stage) {
DynamoStatusContext context = stage.mapTo(DynamoStatusContext.class);
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withRegion("us-east-2").withCredentials(WebIdentityTokenCredentialsProvider.create()).build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable(dynamoTableName);

// On successful build, update deployed field in dynamo.
if (context.getSuccess()) {
Item item = new Item()
.withPrimaryKey("branch", context.getBranch(), "status", "DEPLOYED")
.withString("image", context.getImage());
table.putItem(item);
DeleteItemSpec deleteSpec = new DeleteItemSpec()
.withPrimaryKey("branch", context.getBranch(), "status", "DEPLOYING");
table.deleteItem(deleteSpec);
} else {
// Otherwise, update deploying field and add 10 min TTL.
Item item = new Item()
.withPrimaryKey("branch", context.getBranch(), "status", "DEPLOYING")
.withString("image", context.getImage())
.withLong("ttl", (System.currentTimeMillis() / 1000L + 10 * 60 * 60));
table.putItem(item);
}
return TaskResult.SUCCEEDED;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package io.ziphq.deployboard;

import com.netflix.spinnaker.orca.api.pipeline.graph.StageDefinitionBuilder;
import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode;
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution;
import org.pf4j.Extension;

@Extension
public class DynamoStatusStage implements StageDefinitionBuilder {
public void taskGraph(StageExecution stage, TaskNode.Builder builder) {
builder.withTask("dynamoStatus", DynamoStatusTask.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.ziphq.deployboard;

import com.amazonaws.auth.WebIdentityTokenCredentialsProvider;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClientBuilder;
import com.amazonaws.services.dynamodbv2.document.DynamoDB;
import com.amazonaws.services.dynamodbv2.document.Item;
import com.amazonaws.services.dynamodbv2.document.Table;
import com.amazonaws.services.dynamodbv2.document.spec.DeleteItemSpec;
import com.netflix.spinnaker.orca.api.pipeline.Task;
import com.netflix.spinnaker.orca.api.pipeline.TaskResult;
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution;
import org.pf4j.Extension;

@Extension
public class DynamoStatusTask implements Task {
private String dynamoTableName = "zip-spinnaker-ci-deploys";

public TaskResult execute(StageExecution stage) {
DynamoStatusContext context = stage.mapTo(DynamoStatusContext.class);
AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withRegion("us-east-2").withCredentials(WebIdentityTokenCredentialsProvider.create()).build();
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.getTable(dynamoTableName);

// On successful build, update deployed field in dynamo.
if (context.getSuccess()) {
Item item = new Item()
.withPrimaryKey("branch", context.getBranch(), "status", "DEPLOYED")
.withString("image", context.getImage());
table.putItem(item);
DeleteItemSpec deleteSpec = new DeleteItemSpec()
.withPrimaryKey("branch", context.getBranch(), "status", "DEPLOYING");
table.deleteItem(deleteSpec);
} else {
// Otherwise, update deploying field and add 10 min TTL.
Item item = new Item()
.withPrimaryKey("branch", context.getBranch(), "status", "DEPLOYING")
.withString("image", context.getImage())
.withLong("ttl", (System.currentTimeMillis() / 1000L + 10 * 60 * 60));
table.putItem(item);
}
return TaskResult.SUCCEEDED;
}
}
1 change: 1 addition & 0 deletions zip-deployboard-orca/zip-deployboard-orca.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
compileOnly "io.spinnaker.orca:orca-api:$orcaVersion"

implementation 'com.amazonaws:aws-java-sdk-dynamodb'
implementation 'com.amazonaws:aws-java-sdk-sts'
}

compileJava {
Expand Down

0 comments on commit 4c2f449

Please sign in to comment.