-
Notifications
You must be signed in to change notification settings - Fork 640
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(helm): Fix baking of helm artifacts (#442)
We currently throw an exception if a helm artifact doesn't have a reference. We're only using that reference to generate a file name to use when downloading the artifact; helm artifacts don't actually need a reference. Fix this by just falling back to the name-version if there is no reference defined.
- Loading branch information
Showing
3 changed files
with
76 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...sts/src/test/groovy/com/netflix/spinnaker/rosco/manifests/helm/HelmTemplateUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2019 Google, LLC | ||
* | ||
* 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.rosco.manifests.helm; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import com.netflix.spinnaker.kork.artifacts.model.Artifact; | ||
import com.netflix.spinnaker.rosco.jobs.BakeRecipe; | ||
import com.netflix.spinnaker.rosco.manifests.BakeManifestEnvironment; | ||
import com.netflix.spinnaker.rosco.services.ClouddriverService; | ||
import java.io.IOException; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.platform.runner.JUnitPlatform; | ||
import org.junit.runner.RunWith; | ||
import retrofit.client.Response; | ||
import retrofit.mime.TypedByteArray; | ||
|
||
@RunWith(JUnitPlatform.class) | ||
final class HelmTemplateUtilsTest { | ||
@Test | ||
public void nullReferenceTest() throws IOException { | ||
ClouddriverService clouddriverService = mock(ClouddriverService.class); | ||
HelmTemplateUtils helmTemplateUtils = new HelmTemplateUtils(clouddriverService); | ||
Artifact chartArtifact = Artifact.builder().name("test-artifact").version("3").build(); | ||
|
||
HelmBakeManifestRequest bakeManifestRequest = new HelmBakeManifestRequest(); | ||
bakeManifestRequest.setInputArtifacts(ImmutableList.of(chartArtifact)); | ||
bakeManifestRequest.setOverrides(ImmutableMap.of()); | ||
|
||
when(clouddriverService.fetchArtifact(chartArtifact)).thenReturn(emptyRepsonse()); | ||
try (BakeManifestEnvironment env = BakeManifestEnvironment.create()) { | ||
BakeRecipe recipe = helmTemplateUtils.buildBakeRecipe(env, bakeManifestRequest); | ||
} | ||
} | ||
|
||
private Response emptyRepsonse() { | ||
return new Response("", 200, "", ImmutableList.of(), new TypedByteArray(null, new byte[0])); | ||
} | ||
} |