Skip to content

Commit

Permalink
feat(core): Change Execution & Stage IDs to use ULIDs (#2189)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert committed May 6, 2018
1 parent 04b0659 commit 36b9419
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions orca-core/orca-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ dependencies {
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:${spinnaker.version('jackson')}"
compile "com.fasterxml.jackson.module:jackson-module-kotlin:${spinnaker.version('jackson')}"
compile "org.apache.commons:commons-lang3:3.7"
compile "de.huxhorn.sulky:de.huxhorn.sulky.ulid:8.1.1"

compileOnly spinnaker.dependency("lombok")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import com.netflix.spinnaker.security.User;
import de.huxhorn.sulky.ulid.ULID;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -40,9 +41,10 @@
public class Execution implements Serializable {

public static final DefaultTrigger NO_TRIGGER = new DefaultTrigger("none");
private static final ULID ID_GENERATOR = new ULID();

public Execution(ExecutionType type, String application) {
this(type, UUID.randomUUID().toString(), application);
this(type, ID_GENERATOR.nextULID(), application);
}

@JsonCreator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.netflix.spinnaker.orca.ExecutionStatus;
import com.netflix.spinnaker.orca.jackson.OrcaObjectMapper;
import com.netflix.spinnaker.orca.pipeline.model.support.RequisiteStageRefIdDeserializer;
import de.huxhorn.sulky.ulid.ULID;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand All @@ -45,6 +46,8 @@

public class Stage implements Serializable {

private static final ULID ID_GENERATOR = new ULID();

/**
* Sorts stages into order according to their refIds / requisiteStageRefIds.
*/
Expand Down Expand Up @@ -104,7 +107,7 @@ public Stage(Execution execution, String type) {
/**
* A stage's unique identifier
*/
private String id = UUID.randomUUID().toString();
private String id = ID_GENERATOR.nextULID();

public @Nonnull String getId() {
return id;
Expand Down

0 comments on commit 36b9419

Please sign in to comment.