diff --git a/.gitattributes b/.gitattributes new file mode 100755 index 0000000..dfe0770 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.github/ISSUE_TEMPLATE/General.md b/.github/ISSUE_TEMPLATE/General.md new file mode 100644 index 0000000..9234087 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/General.md @@ -0,0 +1,8 @@ +--- +name: General question or documentation update +about: If you have a general question or documentation update suggestion around the resource module. +--- + + diff --git a/.github/ISSUE_TEMPLATE/Problem_with_resource.yml b/.github/ISSUE_TEMPLATE/Problem_with_resource.yml new file mode 100644 index 0000000..7f3635a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Problem_with_resource.yml @@ -0,0 +1,86 @@ +name: Problem with a resource +description: If you have a problem, bug, or enhancement with a resource in this resource module. +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + Please prefix the issue title (above) with the resource name, e.g. 'ResourceName: Short description of my issue'! + + Your feedback and support is greatly appreciated, thanks for contributing! + - type: textarea + id: description + attributes: + label: Problem description + description: Details of the scenario you tried and the problem that is occurring. + validations: + required: true + - type: textarea + id: logs + attributes: + label: Verbose logs + description: | + Verbose logs showing the problem. **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as plain text._ + placeholder: | + Paste verbose logs here + render: text + validations: + required: true + - type: textarea + id: configuration + attributes: + label: DSC configuration + description: | + The DSC configuration that is used to reproduce the issue (as detailed as possible). **NOTE! Sensitive information should be obfuscated.** _Will be automatically formatted as PowerShell code._ + placeholder: | + Paste DSC configuration here + render: powershell + validations: + required: true + - type: textarea + id: suggestedSolution + attributes: + label: Suggested solution + description: Do you have any suggestions how to solve the issue? + validations: + required: true + - type: textarea + id: targetNodeOS + attributes: + label: Operating system the target node is running + description: | + Please provide as much as possible about the target node, for example edition, version, build, and language. _Will be automatically formatted as plain text._ + + On OS with WMF 5.1 the following command can help get this information: `Get-ComputerInfo -Property @('OsName','OsOperatingSystemSKU','OSArchitecture','WindowsVersion','WindowsBuildLabEx','OsLanguage','OsMuiLanguages')` + placeholder: | + Add operating system information here + render: text + validations: + required: true + - type: textarea + id: targetNodePS + attributes: + label: PowerShell version and build the target node is running + description: | + Please provide the version and build of PowerShell the target node is running. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `$PSVersionTable` + placeholder: | + Add PowerShell information here + render: text + validations: + required: true + - type: textarea + id: moduleVersion + attributes: + label: xoap-application-packaging-dsc version + description: | + Please provide the version of the xoap-application-packaging-dsc module that was used. _Will be automatically formatted as plain text._ + + To help with this information, please run this command: `Get-Module -Name 'xoap-application-packaging-dsc' -ListAvailable | ft Name,Version,Path` + placeholder: | + Add module information here + render: text + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/Resource_proposal.yml b/.github/ISSUE_TEMPLATE/Resource_proposal.yml new file mode 100644 index 0000000..2ddd098 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/Resource_proposal.yml @@ -0,0 +1,39 @@ +name: New resource proposal +description: If you have a new resource proposal that you think should be added to this resource module. +title: "NewResourceName: New resource proposal" +labels: [] +assignees: [] +body: + - type: markdown + attributes: + value: | + Please replace `NewResourceName` in the issue title (above) with your proposed resource name. + + Thank you for contributing and making this resource module better! + - type: textarea + id: description + attributes: + label: Resource proposal + description: Provide information how this resource will/should work and how it will help users. + validations: + required: true + - type: textarea + id: proposedProperties + attributes: + label: Proposed properties + description: | + List all the proposed properties that the resource should have (key, required, write, and/or read). For each property provide a detailed description, the data type, if a default value should be used, and if the property is limited to a set of values. + value: | + Property | Type qualifier | Data type | Description | Default value | Allowed values + --- | --- | --- | --- | --- | --- + PropertyName | Key | String | Detailed description | None | None + validations: + required: true + - type: textarea + id: considerations + attributes: + label: Special considerations or limitations + description: | + Provide any considerations or limitations you can think of that a contributor should take in account when coding the proposed resource, and or what limitations a user will encounter or should consider when using the proposed resource. + validations: + required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..4cd6921 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,5 @@ +blank_issues_enabled: false +contact_links: + - name: "Virtual PowerShell User Group #DSC channel" + url: https://dsccommunity.org/community/contact/ + about: "To talk to the community and maintainers of DSC Community, please visit the #DSC channel." diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..8c6462e --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,52 @@ + + +#### Pull Request (PR) description + + + +#### This Pull Request (PR) fixes the following issues + + + +#### Task list + + + +- [ ] Added an entry to the change log under the Unreleased section of the file CHANGELOG.md. + Entry should say what was changed and how that affects users (if applicable), and + reference the issue being resolved (if applicable). +- [ ] Resource documentation added/updated in README.md. +- [ ] Resource parameter descriptions added/updated in README.md, schema.mof and comment-based + help. +- [ ] Comment-based help added/updated. +- [ ] Localization strings added/updated in all localization files as appropriate. +- [ ] Examples appropriately added/updated. +- [ ] Unit tests added/updated. See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] Integration tests added/updated (where possible). See [DSC Community Testing Guidelines](https://dsccommunity.org/guidelines/testing-guidelines). +- [ ] New/changed code adheres to [DSC Community Style Guidelines](https://dsccommunity.org/styleguidelines). diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..766c1a4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,19 @@ +--- +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + target-branch: dev + schedule: + interval: daily + labels: + - github-actions + - dependencies + - package-ecosystem: terraform + directory: / + target-branch: dev + schedule: + interval: daily + labels: + - terraform + - dependencies diff --git a/.github/workflows/commit-message-validator.yaml b/.github/workflows/commit-message-validator.yaml new file mode 100644 index 0000000..173ce0c --- /dev/null +++ b/.github/workflows/commit-message-validator.yaml @@ -0,0 +1,12 @@ +name: Commit linter +on: + pull_request: + branches: [main, master] +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: wagoid/commitlint-github-action@v5 diff --git a/.github/workflows/dependabot.yaml b/.github/workflows/dependabot.yaml new file mode 100644 index 0000000..0ece537 --- /dev/null +++ b/.github/workflows/dependabot.yaml @@ -0,0 +1,27 @@ +--- +name: Dependabot Pull Request Approve and Merge +on: pull_request_target +permissions: + pull-requests: write + contents: write +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + - name: Dependabot metadata + id: dependabot-metadata + uses: dependabot/fetch-metadata@v1.6.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + - name: Approve a PR + run: gh pr review --approve "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Enable auto-merge for Dependabot PRs + if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }} + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/megalinter.yaml b/.github/workflows/megalinter.yaml new file mode 100644 index 0000000..ebe367f --- /dev/null +++ b/.github/workflows/megalinter.yaml @@ -0,0 +1,34 @@ +--- +name: Linting files +on: + pull_request: + branches: [main, master] +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true +jobs: + build: + name: MegaLinter + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + fetch-depth: 0 + - name: MegaLinter + id: ml + uses: megalinter/megalinter/flavors/terraform@v7.2.1 + env: + VALIDATE_ALL_CODEBASE: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DISABLE: COPYPASTE,SPELL + DISABLE_LINTERS: TERRAFORM_TERRASCAN + - name: Archive production artifacts + if: ${{ success() }} || ${{ failure() }} + uses: actions/upload-artifact@v3 + with: + name: MegaLinter reports + path: | + report + mega-linter.log diff --git a/.github/workflows/tagging.yaml b/.github/workflows/tagging.yaml new file mode 100644 index 0000000..7495596 --- /dev/null +++ b/.github/workflows/tagging.yaml @@ -0,0 +1,43 @@ +--- +name: Create tag and release + +on: + push: + branches: + - master + - main + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + fetch-depth: 0 + - name: Github Tag with semantic versioning + # You may pin to the exact commit or the version. + # uses: hennejg/github-tag-action@2cd21a8413aa58e36a69cb22e64d5ad20aeb9b99 + id: tag_version + uses: hennejg/github-tag-action@v4.4.0 + with: + tag_prefix: "" + # Required for permission to tag the repo. + github_token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + - name: Zip Release + # You may pin to the exact commit or the version. + # uses: TheDoctor0/zip-release@09336613be18a8208dfa66bd57efafd9e2685657 + id: zip + uses: TheDoctor0/zip-release@0.7.1 + with: + type: 'zip' + filename: 'XOAPModuleTemplateDSC_${{ steps.tag_version.outputs.new_tag }}.zip' + exclusions: '*.git* /*License/* CONTRIBUTING.md CODEOWNERS.md CODE_OF_CONDUCT.md .pre-commit.yaml .gitignore .gitattributes .github /templates/* New-CompositeResource.ps1 /test/*' + - name: Create a GitHub release + uses: ncipollo/release-action@v1 + with: + artifacts: 'XOAPModuleTemplateDSC_${{ steps.tag_version.outputs.new_tag }}.zip' + tag: ${{ steps.tag_version.outputs.new_tag }} + name: ${{ steps.tag_version.outputs.new_tag }} + body: ${{ steps.tag_version.outputs.changelog }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c7262bd --- /dev/null +++ b/.gitignore @@ -0,0 +1,148 @@ +# JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# VSCode ----------------------------------------------------------- + +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Windows ----------------------------------------------------------- + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# macOS ----------------------------------------------------------- + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..6e86672 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..6261e9c --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/xoap-powershell-dsc-module-template.iml b/.idea/xoap-powershell-dsc-module-template.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/xoap-powershell-dsc-module-template.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..96674e8 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,10 @@ +{ + "default": true, + "MD029": { + "style": "one" + }, + "MD013": true, + "MD024": false, + "MD034": false, + "no-hard-tabs": true +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..bc662d8 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,40 @@ +--- +repos: + - repo: https://github.com/compilerla/conventional-pre-commit + rev: v2.3.0 + hooks: + - id: conventional-pre-commit + stages: [commit-msg] + args: [] + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-builtin-literals + - id: fix-byte-order-marker + - id: check-json + - id: check-xml + - id: check-yaml + - id: check-merge-conflict + - id: check-shebang-scripts-are-executable + - id: check-symlinks + - id: mixed-line-ending + - id: detect-private-key + - id: no-commit-to-branch + args: + - -b master + - id: no-commit-to-branch + args: + - -b main + - repo: https://github.com/sirosen/check-jsonschema + rev: 0.23.3 + hooks: + - id: check-github-workflows + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.0.0 + hooks: + - id: prettier + stages: [commit] diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..414e964 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,41 @@ +{ + "powershell.codeFormatting.openBraceOnSameLine": false, + "powershell.codeFormatting.newLineAfterOpenBrace": true, + "powershell.codeFormatting.newLineAfterCloseBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenBrace": true, + "powershell.codeFormatting.whitespaceBeforeOpenParen": true, + "powershell.codeFormatting.whitespaceAroundOperator": true, + "powershell.codeFormatting.whitespaceAfterSeparator": true, + "powershell.codeFormatting.ignoreOneLineBlock": false, + "powershell.codeFormatting.pipelineIndentationStyle": "IncreaseIndentationAfterEveryPipeline", + "powershell.codeFormatting.preset": "Custom", + "powershell.codeFormatting.alignPropertyValuePairs": true, + "powershell.developer.bundledModulesPath": "${cwd}/output/RequiredModules", + "powershell.scriptAnalysis.settingsPath": ".vscode\\analyzersettings.psd1", + "powershell.scriptAnalysis.enable": true, + "files.trimTrailingWhitespace": true, + "files.trimFinalNewlines": true, + "files.insertFinalNewline": true, + "files.associations": { + "*.ps1xml": "xml" + }, + "cSpell.words": [ + "COMPANYNAME", + "ICONURI", + "LICENSEURI", + "PROJECTURI", + "RELEASENOTES", + "buildhelpers", + "endregion", + "gitversion", + "icontains", + "keepachangelog", + "notin", + "pscmdlet", + "steppable" + ], + "[markdown]": { + "files.trimTrailingWhitespace": false, + "files.encoding": "utf8" + } +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..cc2b367 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,110 @@ +{ + "version": "2.0.0", + "_runner": "terminal", + "windows": { + "options": { + "shell": { + "executable": "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", + "args": ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"] + } + } + }, + "linux": { + "options": { + "shell": { + "executable": "/usr/bin/pwsh", + "args": ["-NoProfile", "-Command"] + } + } + }, + "osx": { + "options": { + "shell": { + "executable": "/usr/local/bin/pwsh", + "args": ["-NoProfile", "-Command"] + } + } + }, + "tasks": [ + { + "label": "build", + "type": "shell", + "command": "&${cwd}/build.ps1", + "args": [], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "new", + "clear": false + }, + "runOptions": { + "runOn": "default" + }, + "problemMatcher": [ + { + "owner": "powershell", + "fileLocation": ["absolute"], + "severity": "error", + "pattern": [ + { + "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", + "message": 1 + }, + { + "regexp": "(.*)", + "code": 1 + }, + { + "regexp": "" + }, + { + "regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*", + "file": 1, + "line": 2 + } + ] + } + ] + }, + { + "label": "test", + "type": "shell", + "command": "&${cwd}/build.ps1", + "args": ["-AutoRestore", "-Tasks", "test"], + "presentation": { + "echo": true, + "reveal": "always", + "focus": true, + "panel": "dedicated", + "showReuseMessage": true, + "clear": false + }, + "problemMatcher": [ + { + "owner": "powershell", + "fileLocation": ["absolute"], + "severity": "error", + "pattern": [ + { + "regexp": "^\\s*(\\[-\\]\\s*.*?)(\\d+)ms\\s*$", + "message": 1 + }, + { + "regexp": "(.*)", + "code": 1 + }, + { + "regexp": "" + }, + { + "regexp": "^.*,\\s*(.*):\\s*line\\s*(\\d+).*", + "file": 1, + "line": 2 + } + ] + } + ] + } + ] +} diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5a7778b --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,30 @@ +# Changelog for xoap-application-packaging-dsc + +The format is based on and uses the types of changes according to [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- None + +### Changed + +- None + +### Deprecated + +- None + +### Removed + +- None + +### Fixed + +- None + +### Security + +- None diff --git a/CODEOWNERS.md b/CODEOWNERS.md new file mode 100644 index 0000000..793d704 --- /dev/null +++ b/CODEOWNERS.md @@ -0,0 +1,2 @@ +@ssokolic +@xoap_io \ No newline at end of file diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..a691bfd --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,132 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or advances of + any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email address, + without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][mozilla coc]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][faq]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[mozilla coc]: https://github.com/mozilla/diversity +[faq]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..860470a --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +tbd + +## Running the Tests + +tbd diff --git a/DSCResources/Services/Services.psd1 b/DSCResources/Services/Services.psd1 new file mode 100644 index 0000000..8cc8b32 --- /dev/null +++ b/DSCResources/Services/Services.psd1 @@ -0,0 +1,124 @@ +# +# Module manifest for module 'Services' +# +# Generated by: Sinisa Sokolic +# +# Generated on: 7/25/2023 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'Services.schema.psm1' + +# Version number of this module. +ModuleVersion = '0.0.1' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = '09a6295a-d863-47d9-b8ac-22fedaf9fcfc' + +# Author of this module +Author = 'Sinisa Sokolic' + +# Company or vendor of this module +CompanyName = 'RIS AG' + +# Copyright statement for this module +Copyright = '(c) 2023 XOAP. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Configure Windows Services for Azure Virtual Desktop VMs based on Windows 11.' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = '*' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = '*' + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = '*' + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + + diff --git a/DSCResources/Services/Services.schema.psm1 b/DSCResources/Services/Services.schema.psm1 new file mode 100644 index 0000000..2dd915d --- /dev/null +++ b/DSCResources/Services/Services.schema.psm1 @@ -0,0 +1,53 @@ +<# +.SYNOPSIS​ +Please fill me. +​ +.DESCRIPTION​ +Please fill me. + +.COMPONENT​ +Information about PowerShell Modules to be required. ​ +Powershell Module: PSDesiredStateConfiguration​ +Powershell Module: AuditPolicyDSC​ +Powershell Module: SecurityPolicyDSC​ +Powershell Module: PowerShellAccessControl​ +​Powershell Module: WindowsDefender + +.EXAMPLE +Get-DscResource -Module XOAP* + +.NOTES +For more information about advanced functions, call Get-Help with any +of the topics in the links listed below. +Module Name : XOAPModuleTemplateDSC +Resource Name : Services.schema.psm1 +Author : info@XOAP.io +​ +.LINK​ +https://www.microsoft.com/en-us/download/details.aspx?id=55319​ +​ +.LINK​ +https://www.powershellgallery.com/packages/BaselineManagement/2.9.0​ +​ +.LINK​ +https://gallery.technet.microsoft.com/scriptcenter/PowerShellAccessControl-d3be7b83​ + +.LINK +https://www.powershellgallery.com/packages/WindowsDefender/1.0.0.4 +#> +configuration Services +{ + + #Import-DSCResource -ModuleName xPSDesiredStateConfiguration + # + #xRegistry disableInsecureCipher_a + #{ + # Key = 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Ciphers\DES 56/56' + # ValueName = 'Enabled' + # ValueData = '0' + # ValueType = 'Dword' + # Ensure = 'Present' + # Force = $true + #} + +} diff --git a/Examples/Resources/_dummy b/Examples/Resources/_dummy new file mode 100644 index 0000000..e69de29 diff --git a/Examples/XOAPModuleTemplateDSC.ps1 b/Examples/XOAPModuleTemplateDSC.ps1 new file mode 100644 index 0000000..aaa6dd7 --- /dev/null +++ b/Examples/XOAPModuleTemplateDSC.ps1 @@ -0,0 +1,27 @@ +configuration XOAPModuleTemplateDSC +{ + param + ( + # Target nodes to apply the configuration + [string[]]$NodeName = 'localhost' + ) + + Import-Module XOAPModuleTemplateDSC + Import-DSCResource -ModuleName XOAPModuleTemplateDSC + + Node $NodeName + { + + $moduleRoot = [io.path]::GetDirectoryName((Get-Module XOAPModuleTemplateDSC).Path) + #$examples = "$moduleRoot\Examples" + + # Install the IIS role + WindowsFeature IIS + { + Ensure = "Present" + Name = "Web-Server" + } + + } +} + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3ebd87e --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 XOAP.io + +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. diff --git a/New-CompositeResource.ps1 b/New-CompositeResource.ps1 new file mode 100755 index 0000000..75ce43d --- /dev/null +++ b/New-CompositeResource.ps1 @@ -0,0 +1,75 @@ +#Requires -Modules @{ ModuleName="Plaster"; ModuleVersion="1.1.3" } + +[CmdletBinding()] +param ( + [Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string] + $Module, + [Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string] + $Version, + [Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string] + $Ressource, + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $Company = "RIS AG" +) + +$globalPrefix = "XOAP" +$curDirectory = Resolve-Path .\ +$templatePath = Join-Path $curDirectory "templates" +$rootModulePath = Resolve-Path .\source +$Module = "${globalPrefix}${Module}DSC" +$modulePath = Join-Path $rootModulePath "$Module" +$moduleVersionPath = Join-Path $modulePath $Version +$moduleRessources = Join-Path $moduleVersionPath "DSCResources" +$ressourcePath = Join-Path $moduleRessources $Ressource + + +Write-Output "Checking if module $Module already exists under $moduleVersionPath" + +if(Test-Path "$moduleVersionPath") +{ + Write-Output "Module $Module with version $Version already exists. Continuing." +} +else +{ + Write-Warning "Module $Module with version $Version does not exist. Creating new module. Please provide missing data." + $template = Join-Path $templatePath "shared_module" + $moduleData = @{ + project_name = $Module + version = $Version + company = $Company + TemplatePath = "$template" + DestinationPath = "$moduleVersionPath" + } + + Invoke-Plaster @moduleData +} + + +Write-Output "Going to check if ressource $Ressource exists under $ressourcePath" + +if(Test-Path "$ressourcePath") +{ + Write-Error "Ressource $Ressource already exists. Aborting" +} +else +{ + Write-Output "Creating new ressource $Ressource for module $Module" + $template = Join-Path $templatePath "composite_resource" + $moduleData = @{ + project_name = "${Ressource}" + version = "0.0.1" + company = $Company + TemplatePath = "$template" + DestinationPath = "$ressourcePath" + } + + Invoke-Plaster @moduleData +} diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..77c6892 --- /dev/null +++ b/Readme.md @@ -0,0 +1,59 @@ +# XOAPModuleTemplateDSC + +This repository is a template that can be used as a starting point for creating new DSC modules and resources. + +## Code of Conduct + +This project has adopted this [Code of Conduct](CODE_OF_CONDUCT.md). + +## Contributing + +Please check out common DSC Community [contributing guidelines](https://dsccommunity.org/guidelines/contributing). + +## Change log + +A full list of changes in each version can be found in the [change log](CHANGELOG.md). + +## Documentation + +This script is used to easily create new DSC modules and resources. + +## Prerequisites + +Please install Plaster first and make sure it's present. + +```powershell +Install-Module Plaster +Import-Module Plaster +``` + +## Create new DSC modules + +Modules will be automatically created once you are creating a new DSC resource. + +## Create new DSC resources + +DSC resources can easily be deployed via the invocation of + +```powershell +.\New-CompositeResource.ps1 +``` + +with parameters + +```powershell +.\New-CompositeResource.ps1 -Module XOAPModuleTemplateDSC -Version 0.0.1 -Resource ScheduledTasks +``` + +The parameter list is as followed: + +| Parameter | Description | Note | +|-----------|----------------------------------------|------| +| Module | Name of the outer module part | - | +| Version | Target version of the module | - | +| Ressource | The name of the ressource /config part | - | + +### Examples + +You can review the [Examples](/Examples/Resources) directory in the **XOAPModuleTemplateDSC** module +for some general use scenarios for all the resources that are in the module. diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..2cfe789 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,30 @@ +## Security + +XOAP takes the security of our modules seriously, which includes all source code repositories managed through our GitHub organization. + +If you believe you have found a security vulnerability in any XOAP owned repository, please report it to us as described below. + +## Reporting Security Issues + +**Please do not report security vulnerabilities through public GitHub issues.** + +Instead, please report them to one or several members of the XOAP organization. +The easiest way to do so is to send us a direct message via Twitter. + +You should receive a response within 48 hours. If for some reason you do not, please follow up to other members of the community. + +Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: + +- Type of issue +- Full paths of source file(s) related to the manifestation of the issue +- The location of the affected source code (tag/branch/commit or direct URL) +- Any special configuration required to reproduce the issue +- Step-by-step instructions to reproduce the issue +- Proof-of-concept or exploit code (if possible) +- Impact of the issue, including how an attacker might exploit the issue + +This information will help us triage your report more quickly. + +## Preferred Languages + +We prefer all communications to be in English. diff --git a/XOAPModuleTemplateDSC.psd1 b/XOAPModuleTemplateDSC.psd1 new file mode 100644 index 0000000..5e34dea --- /dev/null +++ b/XOAPModuleTemplateDSC.psd1 @@ -0,0 +1,124 @@ +# +# Module manifest for module 'XOAPAModuleTemplate1DSC' +# +# Generated by: Sinisa Sokolic +# +# Generated on: 7/25/2023 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = '0.0.1' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = '9300a1eb-8865-4cf3-abf2-bd2f8f7d861d' + +# Author of this module +Author = 'Sinisa Sokolic' + +# Company or vendor of this module +CompanyName = 'RIS AG' + +# Copyright statement for this module +Copyright = '(c) 2023 XOAP.io. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Module to configure Azure Virtual Desktop Optimizations on Windows 11. ' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = @() + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + + diff --git a/templates/composite_resource/plasterManifest.xml b/templates/composite_resource/plasterManifest.xml new file mode 100755 index 0000000..5eacbbf --- /dev/null +++ b/templates/composite_resource/plasterManifest.xml @@ -0,0 +1,32 @@ + + + + PowershellDSCResource + 14f99429-b25c-45e0-be57-e43666652ab5 + 1.0.0 + PowershellDSCResource + + XOAP + + + + + + + + + + + Creating new module manifest for ${PLASTER_PARAM_project_name} + + Copying schema template + + + diff --git a/templates/composite_resource/resource.schema.psm1.template b/templates/composite_resource/resource.schema.psm1.template new file mode 100755 index 0000000..d273581 --- /dev/null +++ b/templates/composite_resource/resource.schema.psm1.template @@ -0,0 +1,7 @@ +configuration <%=${PLASTER_PARAM_project_name}%> +{ +Import-DSCResource -ModuleName xPSDesiredStateConfiguration + + + +} diff --git a/templates/shared_module/1-ConfigureScheduledTask.template b/templates/shared_module/1-ConfigureScheduledTask.template new file mode 100755 index 0000000..171eaa8 --- /dev/null +++ b/templates/shared_module/1-ConfigureScheduledTask.template @@ -0,0 +1,15 @@ +configuration Example +{ + param + ( + [string[]]$NodeName = 'localhost' + ) + + Import-DSCResource -ModuleName XOAPModuleTemplateDSC + + WindowsFeature IIS + { + Ensure = "Present" + Name = "Web-Server" + } +} diff --git a/templates/shared_module/CHANGELOG.md b/templates/shared_module/CHANGELOG.md new file mode 100755 index 0000000..0f1e233 --- /dev/null +++ b/templates/shared_module/CHANGELOG.md @@ -0,0 +1,32 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [unreleased] + +- tbd + +## [0.0.1] - 2022-06-26 + +### Changed + +- tdb + +### Added + +- tdb + +### Fixed + +- tbd + +### Removed + +- tbd + +### Security + +- tbd diff --git a/templates/shared_module/README.md b/templates/shared_module/README.md new file mode 100755 index 0000000..124ac29 --- /dev/null +++ b/templates/shared_module/README.md @@ -0,0 +1,38 @@ +# <%=${PLASTER_PARAM_project_name}%> + +The <%=${PLASTER_PARAM_project_name}%> PowerShell module provides +DSC resources that can be used to ... (explain what functionality the resources are meant to provide) + +## Installation + +To manually install the module, download the source code and unzip the contents +of the \Modules\<%=${PLASTER_PARAM_project_name}%> directory to the +$env:ProgramFiles\WindowsPowerShell\Modules folder + +To install from the PowerShell gallery using PowerShellGet (in PowerShell 5.0) +run the following command: + + Find-Module -Name <%=${PLASTER_PARAM_project_name}%> -Repository PSGallery | Install-Module + +To confirm installation, run the below command and ensure you see the +<%=${PLASTER_PARAM_project_name}%> DSC resources available: + + Get-DscResource -Module <%=${PLASTER_PARAM_project_name}%> + +## Usage + +Include the following in your DSC configuration + + Import-DSCResource -ModuleName <%=${PLASTER_PARAM_project_name}%> + +### MyResource + + MyResource resourceName { + Ensure = "Present" + } + +## Requirements + +The minimum PowerShell version required is 4.0, which ships in Windows 8.1 +or Windows Server 2012R2 (or higher versions). The preferred version is +PowerShell 5.0 or higher, which ships with Windows 10 or Windows Server 2016. diff --git a/templates/shared_module/_gitignore b/templates/shared_module/_gitignore new file mode 100755 index 0000000..c7262bd --- /dev/null +++ b/templates/shared_module/_gitignore @@ -0,0 +1,148 @@ +# JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# VSCode ----------------------------------------------------------- + +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets + +# Local History for Visual Studio Code +.history/ + +# Built Visual Studio Code Extensions +*.vsix + +# Windows ----------------------------------------------------------- + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# macOS ----------------------------------------------------------- + +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk \ No newline at end of file diff --git a/templates/shared_module/plasterManifest.xml b/templates/shared_module/plasterManifest.xml new file mode 100755 index 0000000..6bdc30d --- /dev/null +++ b/templates/shared_module/plasterManifest.xml @@ -0,0 +1,37 @@ + + + + PowershellDSCModule + 76d2fef8-679c-44d8-8d99-1d35c77f9c0d + 1.0.0 + PowershellDSCModule + + XOAP + + + + + + + + + + + + Scaffold a PowerShell Module with the files required to run Pester tests. + + + + + + + + + + diff --git a/test/Boilerplate.Tests.ps1 b/test/Boilerplate.Tests.ps1 new file mode 100644 index 0000000..55b9675 --- /dev/null +++ b/test/Boilerplate.Tests.ps1 @@ -0,0 +1,71 @@ +$Global:DSCResourceName = 'My_DSCResource' #<----- Just change this + +Import-Module "$($PSScriptRoot)\..\..\DSCResources\$($Global:DSCResourceName)\$($Global:DSCResourceName).psm1" -Force + +# Helper function to list the names of mandatory parameters of *-TargetResource functions +Function Get-MandatoryParameter { + [CmdletBinding()] + Param( + [Parameter(Mandatory=$True)] + [string]$CommandName + ) + $GetCommandData = Get-Command "$($Global:DSCResourceName)\$CommandName" + $MandatoryParameters = $GetCommandData.Parameters.Values | Where-Object { $_.Attributes.Mandatory -eq $True } + return $MandatoryParameters.Name +} + +# Getting the names of mandatory parameters for each *-TargetResource function +$GetMandatoryParameter = Get-MandatoryParameter -CommandName "Get-TargetResource" +$TestMandatoryParameter = Get-MandatoryParameter -CommandName "Test-TargetResource" +$SetMandatoryParameter = Get-MandatoryParameter -CommandName "Set-TargetResource" + +# Splatting parameters values for Get, Test and Set-TargetResource functions +$GetParams = @{ + +} +$TestParams = @{ + +} +$SetParams = @{ + +} + +Describe "$($Global:DSCResourceName)\Get-TargetResource" { + + $GetReturn = & "$($Global:DSCResourceName)\Get-TargetResource" @GetParams + + It "Should return a hashtable" { + $GetReturn | Should BeOfType System.Collections.Hashtable + } + Foreach ($MandatoryParameter in $GetMandatoryParameter) { + + It "Should return a hashtable with key named $MandatoryParameter" { + $GetReturn.ContainsKey($MandatoryParameter) | Should Be $True + } + } +} + +Describe "$($Global:DSCResourceName)\Test-TargetResource" { + + $TestReturn = & "$($Global:DSCResourceName)\Test-TargetResource" @TestParams + + It "Should have the same mandatory parameters as Get-TargetResource" { + # Does not check for $True or $False but uses the output of Compare-Object. + # That way, if this test fails Pester will show us the actual difference(s). + (Compare-Object $GetMandatoryParameter $TestMandatoryParameter).InputObject | Should Be $Null + } + It "Should return a boolean" { + $TestReturn | Should BeOfType System.Boolean + } +} + +Describe "$($Global:DSCResourceName)\Set-TargetResource" { + +$SetReturn = & "$($Global:DSCResourceName)\Set-TargetResource" @SetParams + +It "Should have the same mandatory parameters as Test-TargetResource" { +(Compare-Object $TestMandatoryParameter $SetMandatoryParameter).InputObject | Should Be $Null +} +It "Should not return anything" { +$SetReturn | Should Be $Null +} diff --git a/test/integration/default/XOAPModuleTemplateDSC.Tests.ps1 b/test/integration/default/XOAPModuleTemplateDSC.Tests.ps1 new file mode 100644 index 0000000..3148b7b --- /dev/null +++ b/test/integration/default/XOAPModuleTemplateDSC.Tests.ps1 @@ -0,0 +1,12 @@ +Describe 'When setting up a webserver' { + Context 'to start the default website' { + + It 'verifies IIS is installed' { + (Get-WindowsFeature web-server).installed | should be $true + } + + It 'installs a default website' { + Get-Website 'Default Web Site' | should not be $null + } + } +}