Commit 31823694 authored by Marcel Nellesen's avatar Marcel Nellesen
Browse files

Merge branch 'Sprint/2020-22' into 'master'

Sprint/2020 22

See merge request coscine/cs/resourceconfiguration!9
parents f40190de 781b5259
Pipeline #399400 passed with stages
in 43 seconds
......@@ -5,12 +5,12 @@
//------------------------------------------------------------------------------
using System.Reflection;
[assembly: AssemblyTitle("ResourceConfiguration.Test")]
[assembly: AssemblyDescription("ResourceConfiguration.Test is a part of the CoScInE group.")]
[assembly: AssemblyTitle("ResourceConfiguration.Tests")]
[assembly: AssemblyDescription("ResourceConfiguration.Tests is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("ResourceConfiguration.Test")]
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyFileVersion("1.1.1")]
[assembly: AssemblyInformationalVersion("1.1.1-topic-1035-resou0002")]
[assembly: AssemblyProduct("ResourceConfiguration.Tests")]
[assembly: AssemblyVersion("1.3.0")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: AssemblyInformationalVersion("1.3.0-topic-1159-rtdap0009")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props')" />
<Import Project="..\packages\NUnit.3.12.0\build\NUnit.props" Condition="Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
......@@ -33,8 +35,24 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Coscine.ResourceTypeBase, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ResourceTypeBase.1.4.0\lib\net461\Coscine.ResourceTypeBase.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=3.12.0.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
<HintPath>..\packages\NUnit.3.12.0\lib\net45\nunit.framework.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -53,15 +71,14 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<PackageReference Include="NUnit">
<Version>3.12.0</Version>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter">
<Version>3.17.0</Version>
</PackageReference>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\NUnit.3.12.0\build\NUnit.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit.3.12.0\build\NUnit.props'))" />
<Error Condition="!Exists('..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NUnit3TestAdapter.3.17.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
</Project>
\ No newline at end of file
using NUnit.Framework;
using Coscine.ResourceTypeBase;
using NUnit.Framework;
namespace Coscine.ResourceConfiguration.Tests
{
......@@ -43,7 +44,7 @@ namespace Coscine.ResourceConfiguration.Tests
public void TestGetResourceType()
{
Coscine.ResourceConfiguration.ResourceConfiguration resourcenConfiguration = new Coscine.ResourceConfiguration.ResourceConfiguration();
Assert.True(resourcenConfiguration.GetResourceType(_resourceTypeValid).GetType() == new ResourceTypeObject().GetType());
Assert.True(resourcenConfiguration.GetResourceType(_resourceTypeValid).GetType() == new ResourceTypeConfigurationObject().GetType());
Assert.True(resourcenConfiguration.GetResourceType(_resourceTypeInvalid) == null);
}
......@@ -51,7 +52,7 @@ namespace Coscine.ResourceConfiguration.Tests
public void TestGetResourceTypes()
{
Coscine.ResourceConfiguration.ResourceConfiguration resourcenConfiguration = new Coscine.ResourceConfiguration.ResourceConfiguration();
Assert.IsTrue(resourcenConfiguration.GetResourceTypesByStatus("active").Length == resourcenConfiguration.GetAvailableResourceTypes().Length);
Assert.IsTrue(resourcenConfiguration.GetResourceTypesByStatus("active").Count == resourcenConfiguration.GetAvailableResourceTypes().Count);
}
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Coscine.ResourceTypeBase" version="1.4.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
<package id="NUnit" version="3.12.0" targetFramework="net461" />
<package id="NUnit3TestAdapter" version="3.17.0" targetFramework="net461" />
</packages>
\ No newline at end of file
......@@ -9,8 +9,8 @@ using System.Reflection;
[assembly: AssemblyDescription("ResourceConfiguration is a part of the CoScInE group.")]
[assembly: AssemblyCompany("IT Center, RWTH Aachen University")]
[assembly: AssemblyProduct("ResourceConfiguration")]
[assembly: AssemblyVersion("1.1.1")]
[assembly: AssemblyFileVersion("1.1.1")]
[assembly: AssemblyInformationalVersion("1.1.1-topic-1035-resou0002")]
[assembly: AssemblyVersion("1.3.0")]
[assembly: AssemblyFileVersion("1.3.0")]
[assembly: AssemblyInformationalVersion("1.3.0-topic-1159-rtdap0009")]
[assembly: AssemblyCopyright("2020 IT Center, RWTH Aachen University")]
using Newtonsoft.Json;
using Coscine.ResourceTypeBase;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.IO;
......@@ -8,14 +9,14 @@ namespace Coscine.ResourceConfiguration
{
public class ResourceConfiguration
{
private readonly Dictionary<string, ResourceTypeObject> _types = new Dictionary<string, ResourceTypeObject>();
private readonly Dictionary<string, ResourceTypeConfigurationObject> _types = new Dictionary<string, ResourceTypeConfigurationObject>();
public static string EmbeddedResourceTypesPath { get; } = "Coscine.ResourceConfiguration.ResourceTypes.json";
public ResourceConfiguration()
{
foreach (var kv in GetJSONFromAssembly(EmbeddedResourceTypesPath))
{
_types.Add(kv.Key, kv.Value.ToObject<ResourceTypeObject>());
_types.Add(kv.Key, kv.Value.ToObject<ResourceTypeConfigurationObject>());
}
}
......@@ -37,7 +38,7 @@ namespace Coscine.ResourceConfiguration
return _types.ContainsKey(resourceType);
}
public ResourceTypeObject GetResourceType(string type)
public ResourceTypeConfigurationObject GetResourceType(string type)
{
if (IsValidResource(type))
{
......@@ -46,7 +47,7 @@ namespace Coscine.ResourceConfiguration
return null;
}
public string[] GetResourceTypesByStatus(string status)
public List<string> GetResourceTypesByStatus(string status)
{
var list = new List<string>();
foreach (var key in _types.Keys)
......@@ -56,10 +57,10 @@ namespace Coscine.ResourceConfiguration
list.Add(key);
}
}
return list.ToArray();
return list;
}
public string[] GetAvailableResourceTypes()
public List<string> GetAvailableResourceTypes()
{
return GetResourceTypesByStatus("active");
}
......
......@@ -31,8 +31,21 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Consul, Version=0.7.2.6, Culture=neutral, PublicKeyToken=20a6ad9a81df1d95, processorArchitecture=MSIL">
<HintPath>..\packages\Consul.0.7.2.6\lib\net45\Consul.dll</HintPath>
</Reference>
<Reference Include="Coscine.Configuration, Version=1.5.0.0, Culture=neutral, PublicKeyToken=ce3d7a32d7dc1e5a, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.Configuration.1.5.0\lib\net461\Coscine.Configuration.dll</HintPath>
</Reference>
<Reference Include="Coscine.ResourceTypeBase, Version=1.4.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Coscine.ResourceTypeBase.1.4.0\lib\net461\Coscine.ResourceTypeBase.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net.Http.WebRequest" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -43,15 +56,12 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ResourceConfiguration.cs" />
<Compile Include="ResourceTypeObject.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="ResourceTypes.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.3</Version>
</PackageReference>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System.Collections.Generic;
namespace Coscine.ResourceConfiguration
{
public class ResourceTypeObject
{
public Dictionary<string, string> Name { get; set; }
public string Path { get; set; }
public string ClassName { get; set; }
public string Status { get; set; }
public Dictionary<string, string> Config { get; set; }
}
}
......@@ -4,49 +4,55 @@
"de": "Linked",
"en": "Linked"
},
"path": "",
"className": "Full class name in the DLL",
"path": "ResourceTypeLinked\\Coscine.ResourceTypeLinked.dll",
"className": "ResourceTypeLinked",
"status": "active",
"config": {}
"config": {},
"requiredFields": []
},
"rds": {
"name": {
"de": "FDS",
"en": "RDS"
},
"path": "",
"className": "Full class name in the DLL",
"path": "ResourceTypeWaterbutlerRDS\\Coscine.ResourceTypeWaterbutlerRDS.dll",
"className": "ResourceTypeWaterbutlerRDS",
"status": "active",
"config": {}
"config": {},
"requiredFields": [
"BucketName",
"Size"
]
},
"s3": {
"name": {
"de": "S3",
"en": "S3"
},
"path": "",
"className": "Full class name in the DLL",
"path": "ResourceTypeWaterbutlerS3\\Coscine.ResourceTypeWaterbutlerS3.dll",
"className": "ResourceTypeWaterbutlerS3",
"status": "hidden",
"config": {}
"config": {},
"requiredFields": [
"BucketName",
"AccessKey",
"SecretKey",
"ResourceUrl"
]
},
"gitlab": {
"name": {
"de": "Gitlab",
"en": "Gitlab"
},
"path": "",
"className": "Full class name in the DLL",
"path": "ResourceTypeWaterbutlerGitlab\\Coscine.ResourceTypeWaterbutlerGitlab.dll",
"className": "ResourceTypeWaterbutlerGitlab",
"status": "hidden",
"config": {}
},
"testResource": {
"name": {
"de": "Test Resource",
"en": "Test Resource"
},
"path": "Should not be needed",
"className": "ResourceTypeTest",
"status": "hidden",
"config": {}
"config": {},
"requiredFields": [
"RepositoryNumber",
"RepositoryUrl",
"Token"
]
}
}
\ No newline at end of file
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Consul" version="0.7.2.6" targetFramework="net461" />
<package id="Coscine.Configuration" version="1.5.0" targetFramework="net461" />
<package id="Coscine.ResourceTypeBase" version="1.4.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net461" />
</packages>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment