-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from rasmus/chartmuseum
ChartMuseum
- Loading branch information
Showing
14 changed files
with
435 additions
and
9 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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# 0.16-beta | ||
|
||
* *Nothing yet...* | ||
* New: Ability to upload Helm charts to ChartMuseum | ||
|
||
# 0.15-beta | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2021 Rasmus Mikkelsen | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Bake.Services; | ||
using Bake.ValueObjects.Artifacts; | ||
using Bake.ValueObjects.Destinations; | ||
using Bake.ValueObjects.Recipes; | ||
using Bake.ValueObjects.Recipes.ChartMuseum; | ||
using Bake.ValueObjects.Recipes.OctopusDeploy; | ||
|
||
namespace Bake.Cooking.Composers | ||
{ | ||
public class ChartMuseumComposer : Composer | ||
{ | ||
private readonly IConventionInterpreter _conventionInterpreter; | ||
|
||
public override IReadOnlyCollection<ArtifactType> Consumes { get; } = new[] | ||
{ | ||
ArtifactType.HelmChart, | ||
}; | ||
|
||
public ChartMuseumComposer( | ||
IConventionInterpreter conventionInterpreter) | ||
{ | ||
_conventionInterpreter = conventionInterpreter; | ||
} | ||
|
||
public override Task<IReadOnlyCollection<Recipe>> ComposeAsync( | ||
IContext context, | ||
CancellationToken cancellationToken) | ||
{ | ||
if (!_conventionInterpreter.ShouldArtifactsBePublished(context.Ingredients.Convention)) | ||
{ | ||
return Task.FromResult(EmptyRecipes); | ||
} | ||
|
||
var chartMuseumDestination = context.Ingredients.Destinations | ||
.OfType<ChartMuseumDestination>() | ||
.SingleOrDefault(); | ||
|
||
if (chartMuseumDestination == null) | ||
{ | ||
return Task.FromResult(EmptyRecipes); | ||
} | ||
|
||
var packages = Enumerable.Empty<string>() | ||
.Concat(context.GetArtifacts<HelmChartArtifact>().Select(a => a.Path)) | ||
.ToArray(); | ||
|
||
if (!packages.Any()) | ||
{ | ||
return Task.FromResult(EmptyRecipes); | ||
} | ||
|
||
return Task.FromResult<IReadOnlyCollection<Recipe>>(new Recipe[] | ||
{ | ||
new ChartMuseumUploadRecipe( | ||
new Uri(chartMuseumDestination.Url, UriKind.Absolute), | ||
packages) | ||
}); | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Source/Bake/Cooking/Cooks/ChartMuseum/ChartMuseumUploadCook.cs
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,63 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2021 Rasmus Mikkelsen | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Bake.Services; | ||
using Bake.ValueObjects.Recipes.ChartMuseum; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Bake.Cooking.Cooks.ChartMuseum | ||
{ | ||
public class ChartMuseumUploadCook : Cook<ChartMuseumUploadRecipe> | ||
{ | ||
private readonly ILogger<ChartMuseumUploadCook> _logger; | ||
private readonly IUploader _uploader; | ||
|
||
public ChartMuseumUploadCook( | ||
ILogger<ChartMuseumUploadCook> logger, | ||
IUploader uploader) | ||
{ | ||
_logger = logger; | ||
_uploader = uploader; | ||
} | ||
|
||
protected override async Task<bool> CookAsync( | ||
IContext context, | ||
ChartMuseumUploadRecipe recipe, | ||
CancellationToken cancellationToken) | ||
{ | ||
var url = new Uri(recipe.Url, "/api/charts"); | ||
|
||
foreach (var packagePath in recipe.Packages) | ||
{ | ||
await _uploader.UploadAsync( | ||
packagePath, | ||
url, | ||
cancellationToken); | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// MIT License | ||
// | ||
// Copyright (c) 2021-2022 Rasmus Mikkelsen | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Bake.Services | ||
{ | ||
public interface IUploader | ||
{ | ||
Task UploadAsync( | ||
string filePath, | ||
Uri url, | ||
CancellationToken cancellationToken); | ||
} | ||
} |
Oops, something went wrong.