Browse Source

Add minio port to appsettings

master
Daniel Gyulai 4 years ago
parent
commit
fbdb7c0ebe
  1. 115
      CoviDok/Data/StorageProviders/MinioProvider.cs
  2. 34
      helm/covidok/templates/appsettings.yaml

115
CoviDok/Data/StorageProviders/MinioProvider.cs

@ -1,56 +1,59 @@
using CoviDok.BLL.Storage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Minio;
using Microsoft.Extensions.Options;
namespace CoviDok.Data.StorageProviders
{
public class MinioProvider : IStorageProvider
{
private readonly MinioClient Client = null;
public static MinioSettings _settings;
public MinioProvider()
{
//var _settings = options.Value;
Client = new MinioClient(_settings.HostName, _settings.AccessKey, _settings.SecretKey);
}
public async Task CreateNamespace(string ns)
{
await Client.MakeBucketAsync(ns);
}
public async Task Download(string ns, string objectname, Action<Stream> callback)
{
await Client.GetObjectAsync(ns, objectname, callback);
}
public async Task<bool> NamespaceExists(string ns)
{
return await Client.BucketExistsAsync(ns);
}
public async Task Upload(string ns, string objectname, Stream data, long size)
{
await Client.PutObjectAsync(ns, objectname, data, size);
}
public async Task<bool> ObjectExists(string ns, string objectname)
{
try {
await Client.StatObjectAsync(ns, objectname);
return true;
}
catch (Exception)
{
return false;
}
}
}
}
using CoviDok.BLL.Storage;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Minio;
using Microsoft.Extensions.Options;
namespace CoviDok.Data.StorageProviders
{
public class MinioProvider : IStorageProvider
{
private readonly MinioClient Client = null;
public static MinioSettings _settings;
public MinioProvider()
{
//var _settings = options.Value;
Client = new MinioClient(_settings.HostName, _settings.AccessKey, _settings.SecretKey);
}
public async Task CreateNamespace(string ns)
{
await Client.MakeBucketAsync(ns);
}
public async Task Download(string ns, string objectname, Action<Stream> callback)
{
await Client.GetObjectAsync(ns, objectname, callback);
}
public async Task<bool> NamespaceExists(string ns)
{
Console.WriteLine("MinioProvider:NamespaceExists - Checking " + ns);
bool exists = await Client.BucketExistsAsync(ns);
Console.WriteLine("MinioProvider:NamespaceExists - " + ns + " exists" );
return exists;
}
public async Task Upload(string ns, string objectname, Stream data, long size)
{
await Client.PutObjectAsync(ns, objectname, data, size);
}
public async Task<bool> ObjectExists(string ns, string objectname)
{
try {
await Client.StatObjectAsync(ns, objectname);
return true;
}
catch (Exception)
{
return false;
}
}
}
}

34
helm/covidok/templates/appsettings.yaml

@ -1,17 +1,17 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "covidok.appsettings" . }}
data:
appsettings.k8s.json: |
{
"ConnectionStrings": {
"MySQLDatabase": "server={{- include "covidok.mysql" . -}};database={{ .Values.config.mysql.database }};user={{ .Values.config.mysql.user }};password={{ .Values.config.mysql.password }}",
"RedisHost": "{{ include "covidok.redis" . }}:{{ .Values.config.redis.port }}"
},
"MinioSettings": {
"HostName": "{{ include "covidok.minio" . }}",
"AccessKey": "{{ .Values.config.minio.accesskey }}",
"SecretKey": "{{ .Values.config.minio.secretkey }}"
}
}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "covidok.appsettings" . }}
data:
appsettings.k8s.json: |
{
"ConnectionStrings": {
"MySQLDatabase": "server={{- include "covidok.mysql" . -}};database={{ .Values.config.mysql.database }};user={{ .Values.config.mysql.user }};password={{ .Values.config.mysql.password }}",
"RedisHost": "{{ include "covidok.redis" . }}:{{ .Values.config.redis.port }}"
},
"MinioSettings": {
"HostName": "{{ include "covidok.minio" . }}:9000",
"AccessKey": "{{ .Values.config.minio.accesskey }}",
"SecretKey": "{{ .Values.config.minio.secretkey }}"
}
}

Loading…
Cancel
Save