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

feat(core): Change Execution & Stage IDs to use ULIDs #2189

Merged
merged 3 commits into from
May 6, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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