Skip to content

Commit

Permalink
chore(bakery): remove baseOs and baseLabel enums (#2003)
Browse files Browse the repository at this point in the history
  • Loading branch information
asher committed Feb 19, 2018
1 parent f5d3390 commit 7e15dff
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BakeRequest {

static final Default = new BakeRequest(user: System.getProperty("user.name"),
cloudProviderType: CloudProviderType.aws,
baseLabel: Label.release,
baseLabel: "release",
baseOs: "ubuntu")

String user
Expand All @@ -48,7 +48,7 @@ class BakeRequest {
String commitHash
String buildInfoUrl
CloudProviderType cloudProviderType
Label baseLabel
String baseLabel
String baseOs
String baseName
String baseAmi
Expand Down Expand Up @@ -77,10 +77,6 @@ class BakeRequest {
aws, azure, docker, gce, openstack, titus
}

static enum Label {
release, candidate, previous, unstable, foundation
}

static enum VmType {
pv, hvm
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ class CreateBakeTask implements RetryableTask {
stage.context.baseOs as String).toBlocking().single()
packageType = baseImage.packageType as PackageType
} else {
OperatingSystem operatingSystem = OperatingSystem.valueOf(stage.context.baseOs as String)
packageType = operatingSystem.packageType
packageType = new OperatingSystem(stage.context.baseOs as String).getPackageType()
}

PackageInfo packageInfo = new PackageInfo(stage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CreateBakeTaskSpec extends Specification {
package : "hodor",
user : "bran",
baseOs : "ubuntu",
baseLabel: BakeRequest.Label.release.name()
baseLabel: "release"
]

Execution pipeline = pipeline {
Expand All @@ -75,7 +75,7 @@ class CreateBakeTaskSpec extends Specification {
user : "bran",
cloudProviderType: "aws",
baseOs : "ubuntu",
baseLabel : BakeRequest.Label.release.name()
baseLabel : "release"
]

@Shared
Expand All @@ -85,7 +85,7 @@ class CreateBakeTaskSpec extends Specification {
user : "bran",
cloudProviderType: "aws",
baseOs : "ubuntu",
baseLabel : BakeRequest.Label.release.name(),
baseLabel : "release",
rebake : true
]

Expand Down Expand Up @@ -229,7 +229,7 @@ class CreateBakeTaskSpec extends Specification {
bake.user == bakeConfig.user
bake.packageName == bakeConfig.package
bake.baseOs == bakeConfig.baseOs
bake.baseLabel.name() == bakeConfig.baseLabel
bake.baseLabel == bakeConfig.baseLabel
}
@Unroll
Expand Down Expand Up @@ -569,7 +569,7 @@ class CreateBakeTaskSpec extends Specification {
{
it.user == "bran" &&
it.packageName == "hodor_1.1_all" &&
it.baseLabel == BakeRequest.Label.release &&
it.baseLabel == "release" &&
it.baseOs == "ubuntu" &&
it.buildHost == "http://spinnaker.builds.test.netflix.net/" &&
it.job == "SPINNAKER-package-echo" &&
Expand Down Expand Up @@ -609,7 +609,7 @@ class CreateBakeTaskSpec extends Specification {
{
it.user == "bran" &&
it.packageName == "hodor_1.1_all" &&
it.baseLabel == BakeRequest.Label.release &&
it.baseLabel == "release" &&
it.baseOs == "ubuntu" &&
it.buildHost == null &&
it.job == null &&
Expand Down Expand Up @@ -649,7 +649,7 @@ class CreateBakeTaskSpec extends Specification {
{
it.user == "bran" &&
it.packageName == "hodor_1.1_all" &&
it.baseLabel == BakeRequest.Label.release &&
it.baseLabel == "release" &&
it.baseOs == "ubuntu" &&
it.buildHost == null &&
it.job == null &&
Expand Down Expand Up @@ -688,7 +688,7 @@ class CreateBakeTaskSpec extends Specification {
bake.user == bakeConfigWithCloudProviderType.user
bake.packageName == bakeConfigWithCloudProviderType.package
bake.baseOs == bakeConfigWithCloudProviderType.baseOs
bake.baseLabel.name() == bakeConfigWithCloudProviderType.baseLabel
bake.baseLabel == bakeConfigWithCloudProviderType.baseLabel
}

@Unroll
Expand Down Expand Up @@ -727,7 +727,7 @@ class CreateBakeTaskSpec extends Specification {
{
it.user == "bran" &&
it.packageName == "hodor" &&
it.baseLabel == BakeRequest.Label.release &&
it.baseLabel == "release" &&
it.baseOs == "ubuntu"
} as BakeRequest,
"1") >> Observable.from(runningStatus)
Expand All @@ -754,7 +754,7 @@ class CreateBakeTaskSpec extends Specification {
{
it.user == "bran" &&
it.packageName == "hodor" &&
it.baseLabel == BakeRequest.Label.release &&
it.baseLabel == "release" &&
it.baseOs == "ubuntu"
} as BakeRequest,
queryParameter) >> Observable.from(runningStatus)
Expand All @@ -771,7 +771,7 @@ class CreateBakeTaskSpec extends Specification {
{
it.user == "bran" &&
it.packageName == "hodor" &&
it.baseLabel == BakeRequest.Label.release &&
it.baseLabel == "release" &&
it.baseOs == "ubuntu"
} as BakeRequest,
null) >> Observable.from(runningStatus)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ class ResolveQuipVersionTask implements RetryableTask {
stage.context.baseOs as String).toBlocking().single()
packageType = baseImage.packageType
} else {
OperatingSystem operatingSystem = OperatingSystem.valueOf(stage.context.baseOs as String)
packageType = operatingSystem.packageType
packageType = new OperatingSystem(stage.context.baseOs as String).getPackageType()
}
PackageInfo packageInfo = new PackageInfo(stage,
packageType.packageType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package com.netflix.spinnaker.orca.pipeline.util;

@Deprecated public enum OperatingSystem {
centos(PackageType.RPM),
ubuntu(PackageType.DEB),
trusty(PackageType.DEB),
xenial(PackageType.DEB);
@Deprecated
public class OperatingSystem {
private final PackageType packageType;

OperatingSystem(PackageType packageType) {
this.packageType = packageType;
public OperatingSystem(String os) {
this.packageType = os.toLowerCase().matches("centos|rhel|redhat") ? PackageType.RPM : PackageType.DEB;
}

public PackageType getPackageType() {
return packageType;
}

private final PackageType packageType;
}

0 comments on commit 7e15dff

Please sign in to comment.