|
| 1 | +# Add a new transport |
| 2 | + |
| 3 | +[Eventually](https://github.com/puppetlabs/pdk/pull/666) there will be a `pdk new transport`, for now you'll need to copy in a few files for this workshop. |
| 4 | + |
| 5 | +Copy the files from [this directory](./04-adding-a-new-transport/) into your new module: |
| 6 | + |
| 7 | +* .sync.yml |
| 8 | +* lib/puppet/transport/hue.rb |
| 9 | +* lib/puppet/transport/schema/hue.rb |
| 10 | +* lib/puppet/util/network_device/hue/device.rb |
| 11 | +* spec/unit/puppet/transport/hue_spec.rb |
| 12 | +* spec/unit/puppet/transport/schema/hue_spec.rb |
| 13 | + |
| 14 | +Afterwards run `pdk update --force` to enable a few future defaults that are required for these templates: |
| 15 | + |
| 16 | +``` |
| 17 | +david@davids:~/tmp/hue$ pdk update --force |
| 18 | +pdk (INFO): Updating david-hue using the default template, from master@c43fc26 to master@c43fc26 |
| 19 | +
|
| 20 | +----------Files to be modified---------- |
| 21 | +Gemfile |
| 22 | +spec/spec_helper.rb |
| 23 | +
|
| 24 | +---------------------------------------- |
| 25 | +
|
| 26 | +You can find a report of differences in update_report.txt. |
| 27 | +
|
| 28 | +[✔] Resolving default Gemfile dependencies. |
| 29 | +
|
| 30 | +------------Update completed------------ |
| 31 | +
|
| 32 | +2 files modified. |
| 33 | +
|
| 34 | +david@davids:~/tmp/hue$ |
| 35 | +``` |
| 36 | + |
| 37 | +## Checkpoint |
| 38 | + |
| 39 | +To make sure that everything went well with creating the module and copying in the files you can run `pdk validate --parallel` and `pdk test unit`: |
| 40 | + |
| 41 | +``` |
| 42 | +david@davids:~/tmp/hue$ pdk validate --parallel |
| 43 | +pdk (INFO): Running all available validators... |
| 44 | +pdk (INFO): Using Ruby 2.5.5 |
| 45 | +pdk (INFO): Using Puppet 6.4.2 |
| 46 | +┌ [✔] Validating module using 5 threads ┌ |
| 47 | +├──[✔] Checking metadata syntax (metadat├──son tasks/*.json). |
| 48 | +├──[✔] Checking task names (tasks/**/*).├── |
| 49 | +└──[✔] Checking YAML syntax (["**/*.yaml├──"*.yaml", "**/*.yml", "*.yml"]). |
| 50 | +└──[/] Checking module metadata style (metadata.json). |
| 51 | +└──[✔] Checking module metadata style (metadata.json). |
| 52 | +info: puppet-syntax: ./: Target does not contain any files to validate (**/*.pp). |
| 53 | +info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json). |
| 54 | +info: puppet-lint: ./: Target does not contain any files to validate (**/*.pp). |
| 55 | +david@davids:~/tmp/hue$ pdk test unit |
| 56 | +pdk (INFO): Using Ruby 2.5.5 |
| 57 | +pdk (INFO): Using Puppet 6.4.2 |
| 58 | +[✔] Preparing to run the unit tests. |
| 59 | +[✔] Running unit tests in parallel. |
| 60 | +Run options: exclude {:bolt=>true} |
| 61 | + Evaluated 6 tests in 2.405066937 seconds: 0 failures, 0 pending. |
| 62 | +david@davids:~/tmp/hue$ |
| 63 | +``` |
| 64 | + |
| 65 | +If you're working with a version control system, this would also be a good point to make the first commit to store away all the boilerplate code and later revisit the changes you made. Here I'm showing how to initialise a local git repository and storing all files in an initial commit: |
| 66 | + |
| 67 | +``` |
| 68 | +david@davids:~/tmp/hue$ git init |
| 69 | +Initialized empty Git repository in ~/tmp/hue/.git/ |
| 70 | +david@davids:~/tmp/hue$ git add -A |
| 71 | +david@davids:~/tmp/hue$ git commit -m 'initial commit' |
| 72 | +[master (root-commit) 67951dd] initial commit |
| 73 | + 26 files changed, 887 insertions(+) |
| 74 | + create mode 100644 .fixtures.yml |
| 75 | + create mode 100644 .gitattributes |
| 76 | + create mode 100644 .gitignore |
| 77 | + create mode 100644 .gitlab-ci.yml |
| 78 | + create mode 100644 .pdkignore |
| 79 | + create mode 100644 .puppet-lint.rc |
| 80 | + create mode 100644 .rspec |
| 81 | + create mode 100644 .rubocop.yml |
| 82 | + create mode 100644 .sync.yml |
| 83 | + create mode 100644 .travis.yml |
| 84 | + create mode 100644 .yardopts |
| 85 | + create mode 100644 CHANGELOG.md |
| 86 | + create mode 100644 Gemfile |
| 87 | + create mode 100644 README.md |
| 88 | + create mode 100644 Rakefile |
| 89 | + create mode 100644 appveyor.yml |
| 90 | + create mode 100644 data/common.yaml |
| 91 | + create mode 100644 hiera.yaml |
| 92 | + create mode 100644 lib/puppet/transport/hue.rb |
| 93 | + create mode 100644 lib/puppet/transport/schema/hue.rb |
| 94 | + create mode 100644 lib/puppet/util/network_device/hue/device.rb |
| 95 | + create mode 100644 metadata.json |
| 96 | + create mode 100644 spec/default_facts.yml |
| 97 | + create mode 100644 spec/spec_helper.rb |
| 98 | + create mode 100644 spec/unit/puppet/transport/hue_spec.rb |
| 99 | + create mode 100644 spec/unit/puppet/transport/schema/hue_spec.rb |
| 100 | +david@davids:~/tmp/hue$ |
| 101 | +``` |
| 102 | + |
| 103 | +## Next up |
| 104 | + |
| 105 | +Once you have everything ready, head on to [implement the transport](./05-implementing-the-transport.md). |
0 commit comments