Skip to content

Commit

Permalink
Allow the container.image to be empty (#2235)
Browse files Browse the repository at this point in the history
* Allow container.image to be null/empty

* Remove unnecessary workflow type

* Update src/Sdk/DTPipelines/Pipelines/ObjectTemplating/PipelineTemplateConverter.cs

Co-authored-by: Ferenc Hammerl <[email protected]>

* Rename ConvertToJobContainer to ConvertToContainer
It converts serviceContainers too

* Remove unused parameter
AllowExpressions was always false

* Allow service in yaml with empty string for value

* Don't attempt to start services without an image

* Improve error messages

* Revert "Remove unused parameter"

This reverts commit f4ab2d5.

* Revert "Rename ConvertToJobContainer to ConvertToContainer"

This reverts commit ffc62f8.

* Fix revert merge conflict

* Removed info logs

* Added info log for services without container images

Co-authored-by: moonblade <[email protected]>
Co-authored-by: Ferenc Hammerl <[email protected]>
Co-authored-by: Ava Stancu <[email protected]>
  • Loading branch information
4 people authored Nov 2, 2022
1 parent dad7ad0 commit 3e19635
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/Runner.Worker/JobExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ public async Task<List<IStep>> InitializeJob(IExecutionContext jobContext, Pipel
{
var networkAlias = pair.Key;
var serviceContainer = pair.Value;
if (serviceContainer == null)
{
context.Output($"The service '{networkAlias}' will not be started because the container definition has an empty image.");
continue;
}
jobContext.Global.ServiceContainers.Add(new Container.ContainerInfo(HostContext, serviceContainer, false, networkAlias));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ internal static JobContainer ConvertToJobContainer(

if (String.IsNullOrEmpty(result.Image))
{
context.Error(value, "Container image cannot be empty");
return null;
}

return result;
Expand Down
4 changes: 2 additions & 2 deletions src/Sdk/DTPipelines/workflow-v1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
"container-mapping": {
"mapping": {
"properties": {
"image": "non-empty-string",
"image": "string",
"options": "non-empty-string",
"env": "container-env",
"ports": "sequence-of-non-empty-string",
Expand Down Expand Up @@ -414,7 +414,7 @@
"vars"
],
"one-of": [
"non-empty-string",
"string",
"container-mapping"
]
},
Expand Down

0 comments on commit 3e19635

Please sign in to comment.