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(orca-bakery/manfests): add helmfile support #4460

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
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
Loading