Skip to content

Commit

Permalink
feat(orca-bakery/manfests): add helmfile support
Browse files Browse the repository at this point in the history
  • Loading branch information
thameezb committed Jun 5, 2023
1 parent 1c3e0dc commit 9db2d36
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2023 DoubleCloud, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.netflix.spinnaker.orca.bakery.api.manifests.helmfile;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.netflix.spinnaker.kork.artifacts.model.Artifact;
import com.netflix.spinnaker.orca.bakery.api.manifests.BakeManifestRequest;
import com.netflix.spinnaker.orca.bakery.tasks.manifests.BakeManifestContext;
import java.util.List;
import java.util.Map;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@EqualsAndHashCode(callSuper = true)
public class HelmfileBakeManifestRequest extends BakeManifestRequest {

@JsonProperty("environment")
private String environment;

@JsonProperty("namespace")
private String namespace;

@JsonProperty("overrides")
private Map<String, Object> overrides;

@JsonProperty("inputArtifacts")
private List<Artifact> inputArtifacts;

private List<Artifact> values;

@JsonProperty("includeCRDs")
private Boolean includeCRDs;

@JsonProperty("helmfileFilePath")
private String helmfileFilePath;

public HelmfileBakeManifestRequest(
BakeManifestContext bakeManifestContext,
List<Artifact> inputArtifacts,
String outputArtifactName,
Map<String, Object> overrides) {
super(
bakeManifestContext.getTemplateRenderer(),
outputArtifactName,
bakeManifestContext.getOutputName());
this.setEnvironment(bakeManifestContext.getEnvironment());
this.setNamespace(bakeManifestContext.getNamespace());
this.setOverrides(overrides);
this.setInputArtifacts(inputArtifacts);
this.setIncludeCRDs(bakeManifestContext.getIncludeCRDs());
this.setHelmfileFilePath(bakeManifestContext.getHelmfileFilePath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,15 @@ public class BakeManifestContext {
private final String templateRenderer;
private final String outputName;
private final String namespace;
private final String environment;
private final Boolean rawOverrides;
private final Boolean includeCRDs;
@Nullable private final String kustomizeFilePath;
@Nullable private final String helmChartFilePath;
// There does not seem to be a way to auto-generate a constructor using our current version of
@Nullable private final String helmfileFilePath;

// There does not seem to be a way to auto-generate a constructor using our
// current version of
// Lombok (1.16.20) that
// Jackson can use to deserialize.
public BakeManifestContext(
Expand All @@ -50,9 +54,11 @@ public BakeManifestContext(
@JsonProperty("templateRenderer") String templateRenderer,
@JsonProperty("outputName") String outputName,
@JsonProperty("namespace") String namespace,
@Nullable @JsonProperty("environment") String environment,
@Nullable @JsonProperty("inputArtifact") CreateBakeManifestTask.InputArtifact inputArtifact,
@Nullable @JsonProperty("kustomizeFilePath") String kustomizeFilePath,
@Nullable @JsonProperty("helmChartFilePath") String helmChartFilePath,
@Nullable @JsonProperty("helmfileFilePath") String helmfileFilePath,
@JsonProperty("rawOverrides") Boolean rawOverrides,
@JsonProperty("includeCRDs") Boolean includeCRDs) {
this.inputArtifacts = Optional.ofNullable(inputArtifacts).orElse(new ArrayList<>());
Expand All @@ -66,8 +72,10 @@ public BakeManifestContext(
this.templateRenderer = templateRenderer;
this.outputName = outputName;
this.namespace = namespace;
this.environment = environment;
this.kustomizeFilePath = kustomizeFilePath;
this.helmChartFilePath = helmChartFilePath;
this.helmfileFilePath = helmfileFilePath;
this.rawOverrides = rawOverrides;
this.includeCRDs = includeCRDs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.netflix.spinnaker.orca.bakery.api.BakeryService;
import com.netflix.spinnaker.orca.bakery.api.manifests.BakeManifestRequest;
import com.netflix.spinnaker.orca.bakery.api.manifests.helm.HelmBakeManifestRequest;
import com.netflix.spinnaker.orca.bakery.api.manifests.helmfile.HelmfileBakeManifestRequest;
import com.netflix.spinnaker.orca.bakery.api.manifests.kustomize.KustomizeBakeManifestRequest;
import com.netflix.spinnaker.orca.pipeline.util.ArtifactUtils;
import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor;
Expand Down Expand Up @@ -130,6 +131,11 @@ public TaskResult execute(@Nonnull StageExecution stage) {
new HelmBakeManifestRequest(
context, resolvedInputArtifacts, outputArtifactName, overrides);
break;
case "HELMFILE":
request =
new HelmfileBakeManifestRequest(
context, resolvedInputArtifacts, outputArtifactName, overrides);
break;
case "KUSTOMIZE":
case "KUSTOMIZE4":
Artifact inputArtifact = resolvedInputArtifacts.get(0);
Expand Down

0 comments on commit 9db2d36

Please sign in to comment.