geeklearningio / gl-dotnet-storage

.NET Core Storage abstractions with FileSystem and Azure providers
MIT License
52 stars 13 forks source link

Enhanced configuration #44

Closed asiffermann closed 7 years ago

asiffermann commented 7 years ago

Disclaimer: This PR introduces several breaking changes!

New Configuration

{
  "ConnectionStrings": {
    "ConnectionStringFromAppSettings": "DefaultEndpointsProtocol=https;AccountName=<YourAccount>;AccountKey=<YourKey>;EndpointSuffix=core.windows.net"
  },

  "Storage": {

    "Providers": {
      "FirstAzure": {
        "Type": "Azure",
        "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=<YourAccount>;AccountKey=<YourKey>;EndpointSuffix=core.windows.net"
      },
      "AnotherAzure": {
        "Type": "Azure",
        "ConnectionStringName": "ConnectionStringFromAppSettings"
      },
      "FirstFileSystem": {
        "Type": "FileSystem"
      },
      "AnotherFileSystem": {
        "Type": "FileSystem",
        "RootPath": "../FileVault2"
      }
    },

    "Stores": {
      "Store1": {
        "ProviderName": "FirstFileSystem"
      },
      "Store2": {
        "ProviderName": "FirstFileSystem",
        "AccessLevel": "Public",
        "FolderName": "AnotherPath"
      },
      "Store3": {
        "ProviderName": "FirstAzure",
        "AccessLevel": "Private"
      },
      "Store4": {
        "ProviderType": "Azure",
        "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=<YourAccount>;AccountKey=<YourKey>;EndpointSuffix=core.windows.net"
      },
      "Store5": {
        "ProviderName": "AnotherAzure"
      },
      "Store6": {
        "ProviderType": "Azure",
        "ConnectionStringName": "ConnectionStringFromAppSettings"
      }
    },

    "ScopedStores": {
      "ScopedStore1": {
        "ProviderName": "AnotherFileSystem",
        "FolderNameFormat": "AnotherPath-{0}"
      },
      "ScopedStore2": {
        "ProviderName": "AnotherAzure",
        "AccessLevel": "Confidential",
        "FolderNameFormat": "AnotherPath-{0}"
      }
    }
  }
}

Global:

ScopeStores:

FileSystem:

Azure:

asiffermann commented 7 years ago

Here is the configuration we have today:

"Storage": {
  "Stores": {
    "Youpi1": {
      "Provider": "FileSystem",
      "Parameters": {
        "Path": "Youpi1"
      }
    },
    "Youpi2": {
      "Provider": "FileSystem",
      "Parameters": {
        "Path": "AnotherPath",
        "Access": "Public"
      }
    },
    "Youpi3": {
      "Provider": "FileSystem",
      "Parameters": {
        "Path": "Youpi3"
      }
    },
    "Youpi4": {
      "Provider": "Azure",
      "Parameters": {
        "ConnectionString": "",
        "Container": "Youpi4"
      }
    },
    "Youpa": {
      "Provider": "Azure",
      "Parameters": {
        "ConnectionString": "",
        "Container": "Youpa"
      }
    }
  }
}

And here is the configuration I'd like to have:

"Storage": {
  "Providers": {
    "Azure": {
      "ConnectionStrings": {
        "DefaultConnection": "",
        "AnotherConnection": ""
      },
      "DefaultConnectionStringName": "DefaultConnection"
    },
    "FileSystem": {
      "RootPath": ""
    }
  },
  "Stores": {
    "Youpi1": {
      "Provider": "FileSystem"
    },
    "Youpi2": {
      "Provider": "FileSystem",
      "AccessLevel": "Public",
      "FolderName": "AnotherPath"
    },
    "Youpi3": {
      "Provider": "FileSystem",
      "FolderNameFormat": "AnotherPath-{0}"
    },
    "Youpi4": {
      "Provider": "Azure"
    },
    "Youpa": {
      "Provider": "Azure",
      "AccessLevel": "Confidential",
      "FolderNameFormat": "Youpa-{0}",
      "ConnectionStringName": "AnotherConnection"
    }
    "Youpa2": {
      "Provider": "Azure",
      "ConnectionString": ""
    }
  }
}

Global:

FileSystem:

Azure:

What do you think @sandorfr? 😃

sandorfr commented 7 years ago

I like it very much, Just wondering how it would impact IStore<TOptions>

sandorfr commented 7 years ago

Be carefull with you azure sample as container names have limitations on their names. Provisionning and AccessLevel feature is ❤️

asiffermann commented 7 years ago

After talking with @annayafi, I changed a little bit some options, introduced Named Providers, and extract the ScopedStores configurations in another key:

"Storage": {

  "Providers": {
    "FirstAzure": {
      "Type": "Azure",
      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=default;AccountKey=<key>;EndpointSuffix=core.windows.net"
    },
    "AnotherAzure": {
      "Type": "Azure",
      "ConnectionStringName": "ConnectionStringFromAppSettings"
    },
    "FirstFileSystem": {
      "Type": "FileSystem",
      "RootPath": "C:/First"
    },
    "AnotherFileSystem": {
      "Type": "FileSystem",
      "RootPath": "D:/Another"
    }
  },

  "Stores": {
    "Youpi1": {
      "ProviderName": "FirstFileSystem"
    },
    "Youpi2": {
      "ProviderName": "FirstFileSystem",
      "AccessLevel": "Public",
      "FolderName": "AnotherPath"
    },
    "Youpi4": {
      "ProviderName": "FirstAzure",
      "AccessLevel": "Private"
    },
    "Youpa2": {
      "ProviderType": "Azure",
      "ConnectionString": "DefaultEndpointsProtocol=https;AccountName=excpetionaccount;AccountKey=<key>;EndpointSuffix=core.windows.net"
    }
  },

  "ScopedStores": {
    "Youpi3": {
      "ProviderName": "AnotherFileSystem",
      "FolderNameFormat": "AnotherPath-{0}"
    },
    "Youpa": {
      "ProviderName": "AnotherAzure",
      "AccessLevel": "Confidential",
      "FolderNameFormat": "Youpa-{0}"
    }
  }
}

Global:

ScopeStores:

FileSystem:

Azure:

What do you think @sandorfr and @arnaudauroux? 😃

asiffermann commented 7 years ago

@arnaudauroux and @annayafi are a little bit shy, but they found it cool! 😄

arnaudauroux commented 7 years ago

@asiffermann We are talking about a configuration file enhancement ;) This is not gonna save kittens ! :P

anna-git commented 7 years ago

this conversation is getting too weird for me !

sandorfr commented 7 years ago

Moi je pense que c'est vital pour les chatons !

asiffermann commented 7 years ago

@sandorfr and @arnaudauroux, it would be great if you could review the PR 😃

There is only two things left: