Skip to content

Commit

Permalink
BREAKING CHANGE: SqlServerDsc: Implement all suggested fixes from iss…
Browse files Browse the repository at this point in the history
…ue 851 (#902)

- BREAKING CHANGE: Significant rename to reduce length of resource names. 
  See issue #851 for a complete table mapping rename changes.
  Impact to all resources.
  • Loading branch information
mgreenegit authored and johlju committed Nov 28, 2017
1 parent 50f4e99 commit b333565
Show file tree
Hide file tree
Showing 200 changed files with 3,956 additions and 3,944 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!--
Your feedback and support is greatly appreciated, thanks for contributing!
Please prefix the issue title with the resource name, i.e. 'xSQLServerSetup: Short description of my issue'
Please prefix the issue title with the resource name, i.e. 'SqlSetup: Short description of my issue'
Please provide the following information regarding your issue (place N/A if the fields that don't apply to your issue):
If you like to contribute more please feel free to read the contributing section at https://github.com/PowerShell/xSQLServer#contributing.
If you like to contribute more please feel free to read the contributing section at https://github.com/PowerShell/SQLServerDsc#contributing.
-->
**Details of the scenario you tried and the problem that is occurring:**

Expand Down
6 changes: 3 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Thanks for submitting a Pull Request (PR) to this project.
Your contribution to this project is greatly appreciated!
Please make sure you have read the contributing section
at https://github.com/PowerShell/xSQLServer#contributing.
at https://github.com/PowerShell/SqlServerDsc#contributing.
Please prefix the PR title with the resource name,
i.e. 'xSQLServerSetup: My short description'
i.e. 'SqlSetup: My short description'
If this is a breaking change, then also prefix the PR title
with 'BREAKING CHANGE:',
i.e. 'BREAKING CHANGE: xSQLServerSetup: My short description'
i.e. 'BREAKING CHANGE: SqlSetup: My short description'
-->
**Pull Request (PR) description**
<!-- Replace this with a description of your pull request -->
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Change log for xSQLServer
# Change log for SqlServerDsc

## Unreleased

- BREAKING CHANGE: Significant rename to reduce length of Resource names
- See [issue #851](https://github.com/PowerShell/xSQLServer/issues/851) for a
complete table mapping rename changes.
- Impact to all resources

## 9.0.0.0

- Changes to xSQLServer
Expand Down
49 changes: 27 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to xSQLServer
# Contributing to SqlServerDsc

If you are keen to make xSQLServer better, why not consider contributing your work
If you are keen to make SqlServerDsc better, why not consider contributing your work
to the project? Every little change helps us make a better resource for everyone
to use, and we would love to have contributions from the community.

Expand All @@ -10,7 +10,7 @@ We follow all of the standard contribution guidelines for DSC resources
[outlined in DscResources repository](https://github.com/PowerShell/DscResources/blob/master/CONTRIBUTING.md),
so please review these as a baseline for contributing.

## xSQLServer specific guidelines
## SqlServerDsc specific guidelines

### Automatic formatting with VS Code

Expand All @@ -34,10 +34,14 @@ Those SQL Server products that are still supported can be listed at the

### Naming convention

```naming
<Module Identifier>[<Component>][<Action>]<Scope>{<Feature> | <Property>}
```

#### mof-based resource

All mof-based resource (with Get/Set/Test-TargetResource) should be prefixed with
'MSFT\_xSQLServer'. I.e. MSFT\_xSQLServerConfiguration
'MSFT\_SqlServer'. I.e. MSFT\_SqlServerConfiguration

Please note that not all places should contain the prefix 'MSFT\_'.

Expand All @@ -49,14 +53,14 @@ This is to make those folders more user friendly, to resemble the name the user
would use in the configuration file.

```Text
DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.psm1
DSCResources/MSFT_xSQLServerConfiguration/MSFT_xSQLServerConfiguration.schema.mof
DSCResources/MSFT_xSQLServerConfiguration/en-US/MSFT_xSQLServerConfiguration.strings.psd1
DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.psm1
DSCResources/MSFT_SqlServerConfiguration/MSFT_SqlServerConfiguration.schema.mof
DSCResources/MSFT_SqlServerConfiguration/en-US/MSFT_SqlServerConfiguration.strings.psd1
Tests/Unit/MSFT_xSQLServerConfiguration.Tests.ps1
Tests/Unit/MSFT_SqlServerConfiguration.Tests.ps1
Examples/Resources/xSQLServerConfiguration/1-AddConfigurationOption.ps1
Examples/Resources/xSQLServerConfiguration/2-RemoveConfigurationOption.ps1
Examples/Resources/SqlServerConfiguration/1-AddConfigurationOption.ps1
Examples/Resources/SqlServerConfiguration/2-RemoveConfigurationOption.ps1
```

##### Schema mof file
Expand All @@ -65,8 +69,8 @@ Please note that the `FriendlyName` in the schema mof file should not contain th
prefix `MSFT\_`.

```powershell
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerConfiguration")]
class MSFT_xSQLServerConfiguration : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlServerConfiguration")]
class MSFT_SqlServerConfiguration : OMI_BaseResource
{
# Properties removed for readability.
};
Expand All @@ -75,7 +79,7 @@ class MSFT_xSQLServerConfiguration : OMI_BaseResource
#### Composite or class-based resource

Any composite (with a Configuration) or class-based resources should be prefixed
with just 'xSQLServer'
with just 'Sql'

### Localization

Expand All @@ -87,15 +91,15 @@ In each resource folder there should be, at least, a localization folder for
english language 'en-US'.
In the 'en-US' (and any other language folder) there should be a file named
'MSFT_ResourceName.strings.psd1', i.e.
'MSFT_xSQLServerSetup.strings.psd1'.
'MSFT_SqlSetup.strings.psd1'.
At the top of each resource the localized strings should be loaded, see the helper
function `Get-LocalizedData` for more information on how this is done.

The localized string file should contain the following (beside the localization
strings)

```powershell
# Localized resources for xSQLServerSetup
# Localized resources for SqlSetup
ConvertFrom-StringData @'
InstallingUsingPathMessage = Installing using path '{0}'.
Expand Down Expand Up @@ -272,17 +276,17 @@ This should be used at the top of each resource like this.
Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
-ChildPath 'CommonResourceHelper.psm1')
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerSetup'
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlSetup'
```

#### Old localization helper function

To be able to support localization we have added wrappers for the cmdlets
`Write-Verbose` and `Write-Warning`, and also for creating a terminating error
message.
The localized strings are placed in a file named 'xSQLServerHelper.strings.psd1'
The localized strings are placed in a file named 'SqlServerDscHelper.strings.psd1'
which are located in each language folder in the root of the module. For English
language strings the folder is ['en-US'](https://github.com/PowerShell/xSQLServer/blob/dev/en-US).
language strings the folder is ['en-US'](https://github.com/PowerShell/SqlServerDsc/blob/dev/en-US).

##### New-TerminatingError

Expand All @@ -305,7 +309,7 @@ Helper functions or wrapper functions that are used by the resource can preferab
be placed in the resource module file. If the functions are of a type that could
be used by more than
one resource, then the functions can also be placed in the common
[xSQLServerHelper.psm1](https://github.com/PowerShell/xSQLServer/blob/dev/xSQLServerHelper.psm1)
[SqlServerDscHelper.psm1](https://github.com/PowerShell/SqlServerDsc/blob/dev/SqlServerDscHelper.psm1)
module file.

### Tests
Expand Down Expand Up @@ -340,12 +344,13 @@ When sending in a Pull Request (PR) all example files will be tested so they can
be compiled to a .mof file. If the tests find any errors the build will fail.
Before the test runs in AppVeyor the module will be copied to the first path of
`$env:PSModulePath`.
To run this test locally, make sure you have the xSQLServer module deployed to a
path where it can be used. See `$env:PSModulePath` to view the existing paths.
To run this test locally, make sure you have the SqlServerDsc module
deployed to a path where it can be used.
See `$env:PSModulePath` to view the existing paths.

#### Using SMO stub classes

There are [stub classes](https://github.com/PowerShell/xSQLServer/blob/dev/Tests/Unit/Stubs/SMO.cs)
There are [stub classes](https://github.com/PowerShell/SqlServerDsc/blob/dev/Tests/Unit/Stubs/SMO.cs)
for the SMO classes which can be used and improved on when creating tests where
SMO classes are used in the code being tested.

Expand Down
2 changes: 1 addition & 1 deletion DSCResources/CommonResourceHelper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function New-InvalidResultException
For WindowsOptionalFeature: MSFT_WindowsOptionalFeature
For Service: MSFT_ServiceResource
For Registry: MSFT_RegistryResource
For Helper: xSQLServerHelper
For Helper: SqlServerDscHelper
.PARAMETER ScriptRoot
Optional. The root path where to expect to find the culture folder. This is only needed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force

<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnAvailabilityGroup")]
class MSFT_xSQLServerAlwaysOnAvailabilityGroup : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlAG")]
class MSFT_SqlAG : OMI_BaseResource
{
[Key, Description("The name of the availability group.")] String Name;
[Required, Description("Hostname of the SQL Server to be configured.")] String SQLServer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
-ChildPath 'CommonResourceHelper.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership'
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlAGDatabase'

<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership")]
class MSFT_xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlAGDatabase")]
class MSFT_SqlAGDatabase : OMI_BaseResource
{
[Required, Description("The name of the database(s) to add to the availability group. This accepts wildcards.")] String DatabaseName[];
[Key, Description("Hostname of the SQL Server where the primary replica of the availability group lives. If the availability group is not currently on this server, the resource will attempt to connect to the server where the primary replica lives.")] String SQLServer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Localized resources for xSQLServerAlwaysOnAvailabilityGroupDatabaseMembership
# Localized resources for SqlAGDatabase

ConvertFrom-StringData @'
AddingDatabasesToAvailabilityGroup = Adding the following databases to the '{0}' availability group: {1}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAvailabilityGroupListener")]
class MSFT_xSQLServerAvailabilityGroupListener : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlAGListener")]
class MSFT_SqlAGListener : OMI_BaseResource
{
[Key, Description("The SQL Server instance name of the primary replica.")] String InstanceName;
[Required, Description("The host name or FQDN of the primary replica.")] String NodeName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force

<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnAvailabilityGroupReplica")]
class MSFT_xSQLServerAlwaysOnAvailabilityGroupReplica : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlAGReplica")]
class MSFT_SqlAGReplica : OMI_BaseResource
{
[Key, Description("The name of the availability group replica. For named instances this must be in the following format SQLServer\\InstanceName.")] String Name;
[Key, Description("The name of the availability group.")] String AvailabilityGroupName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'xSQLServerHelper.psm1') -Force
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) -ChildPath 'SqlServerDscHelper.psm1') -Force

function Get-TargetResource
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlias")]
class MSFT_xSQLServerAlias : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlAlias")]
class MSFT_SqlAlias : OMI_BaseResource
{
[Key, Description("The name of Alias (e.g. svr01\\inst01).")] String Name;
[Write, Description("Protocol to use when connecting. Valid values are 'TCP' or 'NP' (Named Pipes). Default value is 'TCP'."), ValueMap{"TCP","NP"}, Values{"TCP","NP"}] String Protocol;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force

<#
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerAlwaysOnService")]
class MSFT_xSQLServerAlwaysOnService : OMI_BaseResource
{
[Required, Description("An enumerated value that describes if the SQL Server should have Always On high availability and disaster recovery (HADR) property enabled ('Present') or disabled ('Absent')."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
[Key, Description("The hostname of the SQL Server to be configured.")] String SQLServer;
[Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName;
[Write, Description("The length of time, in seconds, to wait for the service to restart. Default is 120 seconds.")] Uint32 RestartTimeout;
[Read, Description("Returns the status of AlwaysOn high availability and disaster recovery (HADR).")] Boolean IsHadrEnabled;
};
[ClassVersion("1.0.0.0"), FriendlyName("SqlAlwaysOnService")]
class MSFT_SqlAlwaysOnService : OMI_BaseResource
{
[Required, Description("An enumerated value that describes if the SQL Server should have Always On high availability and disaster recovery (HADR) property enabled ('Present') or disabled ('Absent')."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
[Key, Description("The hostname of the SQL Server to be configured.")] String SQLServer;
[Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName;
[Write, Description("The length of time, in seconds, to wait for the service to restart. Default is 120 seconds.")] Uint32 RestartTimeout;
[Read, Description("Returns the status of AlwaysOn high availability and disaster recovery (HADR).")] Boolean IsHadrEnabled;
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabase")]
class MSFT_xSQLServerDatabase : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabase")]
class MSFT_SqlDatabase : OMI_BaseResource
{
[Key, Description("The name of the SQL database.")] String Name;
[Write, Description("An enumerated value that describes if the database is added (Present) or dropped (Absent). Valid values are 'Present' or 'Absent'. Default Value is 'Present'."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force

Import-Module -Name (Join-Path -Path (Split-Path -Path $PSScriptRoot -Parent) `
-ChildPath 'CommonResourceHelper.psm1')

$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_xSQLServerDatabaseDefaultLocation'
$script:localizedData = Get-LocalizedData -ResourceName 'MSFT_SqlDatabaseDefaultLocation'

<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabaseDefaultLocation")]
class MSFT_xSQLServerDatabaseDefaultLocation : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabaseDefaultLocation")]
class MSFT_SqlDatabaseDefaultLocation : OMI_BaseResource
{
[Key, Description("The host name of the SQL Server to be configured.")] String SQLServer;
[Key, Description("The name of the SQL instance to be configured.")] String SQLInstanceName;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Localized resources for MSFT_xSQLServerDatabaseDefaultLocation
# Localized resources for MSFT_SqlDatabaseDefaultLocation

ConvertFrom-StringData @'
GetCurrentPath = Getting default path for '{0}' for instance '{1}'.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabaseOwner")]
class MSFT_xSQLServerDatabaseOwner : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabaseOwner")]
class MSFT_SqlDatabaseOwner : OMI_BaseResource
{
[Key, Description("The name of database to be configured.")] String Database;
[Required, Description("The name of the login that will become a owner of the desired sql database.")] String Name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0.0.0"), FriendlyName("xSQLServerDatabasePermission")]
class MSFT_xSQLServerDatabasePermission : OMI_BaseResource
[ClassVersion("1.0.0.0"), FriendlyName("SqlDatabasePermission")]
class MSFT_SqlDatabasePermission : OMI_BaseResource
{
[Write, Description("If the values should be present or absent. Valid values are 'Present' or 'Absent'."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure;
[Key, Description("The name of the database.")] String Database;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Import-Module -Name (Join-Path -Path (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent) `
-ChildPath 'xSQLServerHelper.psm1') `
-ChildPath 'SqlServerDscHelper.psm1') `
-Force
<#
.SYNOPSIS
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[ClassVersion("1.0"), FriendlyName("xSQLServerDatabaseRecoveryModel")]
class MSFT_xSQLServerDatabaseRecoveryModel : OMI_BaseResource
[ClassVersion("1.0"), FriendlyName("SqlDatabaseRecoveryModel")]
class MSFT_SqlDatabaseRecoveryModel : OMI_BaseResource
{
[Key, Description("The SQL database name")] String Name;
[Required, Description("The recovery model to use for the database."), ValueMap{"Full","Simple","BulkLogged"}, Values{"Full","Simple","BulkLogged"}] String RecoveryModel;
Expand Down
Loading

0 comments on commit b333565

Please sign in to comment.