|
| 1 | +# Add a new transport |
| 2 | + |
| 3 | +Starting with PDK 1.12.0 there is the `pdk new transport` command, that you can use to create the base files for your new transport: |
| 4 | + |
| 5 | +Next, we'll active a few future defaults. In the `hue_workshop` directory, create a file called `.sync.yml` and paste the following: |
| 6 | + |
| 7 | +``` |
| 8 | +# .sync.yml |
| 9 | +--- |
| 10 | +Gemfile: |
| 11 | + optional: |
| 12 | + ':development': |
| 13 | + - gem: 'puppet-resource_api' |
| 14 | + - gem: 'faraday' |
| 15 | + - gem: 'rspec-json_expectations' |
| 16 | +spec/spec_helper.rb: |
| 17 | + mock_with: ':rspec' |
| 18 | +``` |
| 19 | + |
| 20 | +Run `pdk update` in the module's directory to deploy the changes in the module: |
| 21 | + |
| 22 | +``` |
| 23 | +david@davids:~/tmp/hue_workshop$ pdk update --force |
| 24 | +pdk (INFO): Updating david-hue_workshop using the default template, from 1.10.0 to 1.10.0 |
| 25 | +
|
| 26 | +----------Files to be modified---------- |
| 27 | +Gemfile |
| 28 | +spec/spec_helper.rb |
| 29 | +
|
| 30 | +---------------------------------------- |
| 31 | +
|
| 32 | +You can find a report of differences in update_report.txt. |
| 33 | +
|
| 34 | +Do you want to continue and make these changes to your module? Yes |
| 35 | +
|
| 36 | +------------Update completed------------ |
| 37 | +
|
| 38 | +2 files modified. |
| 39 | +
|
| 40 | +david@davids:~/tmp/hue_workshop$ |
| 41 | +``` |
| 42 | + |
| 43 | +Then, create the actual transport: |
| 44 | + |
| 45 | +``` |
| 46 | +david@davids:~/tmp/hue$ pdk new transport hue |
| 47 | +pdk (INFO): Creating '/home/david/tmp/hue/lib/puppet/transport/hue.rb' from template. |
| 48 | +pdk (INFO): Creating '/home/david/tmp/hue/lib/puppet/transport/schema/hue.rb' from template. |
| 49 | +pdk (INFO): Creating '/home/david/tmp/hue/lib/puppet/util/network_device/hue/device.rb' from template. |
| 50 | +pdk (INFO): Creating '/home/david/tmp/hue/spec/unit/puppet/transport/hue_spec.rb' from template. |
| 51 | +pdk (INFO): Creating '/home/david/tmp/hue/spec/unit/puppet/transport/schema/hue_spec.rb' from template. |
| 52 | +david@davids:~/tmp/hue$ |
| 53 | +``` |
| 54 | + |
| 55 | +## Checkpoint |
| 56 | + |
| 57 | +To validate your new module and transport, run `pdk validate --parallel` and `pdk test unit`: |
| 58 | + |
| 59 | +``` |
| 60 | +david@davids:~/tmp/hue$ pdk validate --parallel |
| 61 | +pdk (INFO): Running all available validators... |
| 62 | +pdk (INFO): Using Ruby 2.5.5 |
| 63 | +pdk (INFO): Using Puppet 6.4.2 |
| 64 | +┌ [✔] Validating module using 5 threads ┌ |
| 65 | +├──[✔] Checking metadata syntax (metadat├──son tasks/*.json). |
| 66 | +├──[✔] Checking task names (tasks/**/*).├── |
| 67 | +└──[✔] Checking YAML syntax (["**/*.yaml├──"*.yaml", "**/*.yml", "*.yml"]). |
| 68 | +└──[/] Checking module metadata style (metadata.json). |
| 69 | +└──[✔] Checking module metadata style (metadata.json). |
| 70 | +info: puppet-syntax: ./: Target does not contain any files to validate (**/*.pp). |
| 71 | +info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json). |
| 72 | +info: puppet-lint: ./: Target does not contain any files to validate (**/*.pp). |
| 73 | +david@davids:~/tmp/hue$ pdk test unit |
| 74 | +pdk (INFO): Using Ruby 2.5.5 |
| 75 | +pdk (INFO): Using Puppet 6.4.2 |
| 76 | +[✔] Preparing to run the unit tests. |
| 77 | +[✔] Running unit tests in parallel. |
| 78 | +Run options: exclude {:bolt=>true} |
| 79 | + Evaluated 6 tests in 2.405066937 seconds: 0 failures, 0 pending. |
| 80 | +david@davids:~/tmp/hue$ |
| 81 | +``` |
| 82 | + |
| 83 | +If you're working with a version control system, now would be a good time to make your first commit and store the boilerplate code, and then you can revisit the changes you made later. For example: |
| 84 | + |
| 85 | +``` |
| 86 | +david@davids:~/tmp/hue$ git init |
| 87 | +Initialized empty Git repository in ~/tmp/hue/.git/ |
| 88 | +david@davids:~/tmp/hue$ git add -A |
| 89 | +david@davids:~/tmp/hue$ git commit -m 'initial commit' |
| 90 | +[master (root-commit) 67951dd] initial commit |
| 91 | + 26 files changed, 887 insertions(+) |
| 92 | + create mode 100644 .fixtures.yml |
| 93 | + create mode 100644 .gitattributes |
| 94 | + create mode 100644 .gitignore |
| 95 | + create mode 100644 .gitlab-ci.yml |
| 96 | + create mode 100644 .pdkignore |
| 97 | + create mode 100644 .puppet-lint.rc |
| 98 | + create mode 100644 .rspec |
| 99 | + create mode 100644 .rubocop.yml |
| 100 | + create mode 100644 .sync.yml |
| 101 | + create mode 100644 .travis.yml |
| 102 | + create mode 100644 .yardopts |
| 103 | + create mode 100644 CHANGELOG.md |
| 104 | + create mode 100644 Gemfile |
| 105 | + create mode 100644 README.md |
| 106 | + create mode 100644 Rakefile |
| 107 | + create mode 100644 appveyor.yml |
| 108 | + create mode 100644 data/common.yaml |
| 109 | + create mode 100644 hiera.yaml |
| 110 | + create mode 100644 lib/puppet/transport/hue.rb |
| 111 | + create mode 100644 lib/puppet/transport/schema/hue.rb |
| 112 | + create mode 100644 lib/puppet/util/network_device/hue/device.rb |
| 113 | + create mode 100644 metadata.json |
| 114 | + create mode 100644 spec/default_facts.yml |
| 115 | + create mode 100644 spec/spec_helper.rb |
| 116 | + create mode 100644 spec/unit/puppet/transport/hue_spec.rb |
| 117 | + create mode 100644 spec/unit/puppet/transport/schema/hue_spec.rb |
| 118 | +david@davids:~/tmp/hue$ |
| 119 | +``` |
| 120 | + |
| 121 | +## Next up |
| 122 | + |
| 123 | +Now that you have everything ready, you'll [implement the transport](./05-implementing-the-transport.md). |
0 commit comments