Skip to content

Commit 57901ea

Browse files
clairecadmanDavidS
authored andcommitted
(FM-8079) Docs edit
1 parent 34603a6 commit 57901ea

8 files changed

+67
-67
lines changed

docs/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Resource API hands-on lab
22

3-
This lab will walk you through the basic steps of creating a native integration with puppet. After this you will have a fully functioning module to manage Philips HUE lights and have seen all the bits fall into place.
3+
The Resource API hands-on lab walks you through creating a native integration with Puppet. After completely this lab, you will have a fully functioning module to manage Philips HUE lights.
44

5-
These labs are intended for new and experienced developers alike. Please post feedback and suggestions for improvement in the [issues section](https://github.com/puppetlabs/puppet-resource_api/issues).
5+
>Note: These labs are intended for both new and experienced developers. If you have any feedback or suggestions for improvement, post it in the [issues section](https://github.com/puppetlabs/puppet-resource_api/issues).
66
7-
Start with [installing the Puppet Development Kit](./hands-on-lab/01-installing-prereqs.md)
7+
To start with, we'll go through [installing Puppet Development Kit](./hands-on-lab/01-installing-prereqs.md)(PDK).
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
# Install the Puppet Development Kit and other tools
1+
# Install Puppet Development Kit (PDK) and other tools
22

3-
To start out, install the Puppet Development Kit (PDK), which will provide all necessary tools and libraries to build and test modules. Additionally we recommend an emulator for the target device of this lab, a code editor with good ruby and puppet support, and GIT, a version control system to keep track of our progress.
3+
To start, install Puppet Development Kit (PDK), which provides all the necessary tools and libraries to build and test modules. We also recommend an emulator for the target device, a code editor with good Ruby and Puppet support, and git — a version control system to keep track of your progress.
44

5-
1. Choose your platform from https://puppet.com/download-puppet-development-kit; download and install the package
5+
1. [Download PDK](https://puppet.com/download-puppet-development-kit) on your platform of choice.
66

7-
2. If you do not have a Philips HUE hub available, you can download the [Hue-Emulator](https://github.com/SteveyO/Hue-Emulator/raw/master/HueEmulator-v0.8.jar). You will need to have Java installed to run this.
7+
2. If you do not have a Philips HUE hub available, you can download the [Hue-Emulator](https://github.com/SteveyO/Hue-Emulator/raw/master/HueEmulator-v0.8.jar). You need to have Java installed to run this.
88

99
3. To edit code, we recommend the cross-platform editor [VSCode](https://code.visualstudio.com/download), with the [Ruby](https://marketplace.visualstudio.com/items?itemName=rebornix.Ruby) and [Puppet](https://marketplace.visualstudio.com/items?itemName=jpogran.puppet-vscode) extensions. There are lots of other extensions that can help you with your development workflow.
1010

11-
4. Git is a version control system that helps you keep track of changes and collaborate with others. In the course of the hands-on lab, we will show some integrations with cloud services that can help you. If you never used git before, skip this and all related steps for now.
11+
4. Git is a version control system that helps you keep track of changes and collaborate with others. As we go through hands-on lab, we will show you some integrations with cloud services. If you have never used git before, ignore this and all related steps.
1212

1313

1414
## Next up
1515

16-
Having installed all of this, let's [light up a few](./02-connecting-to-the-lightbulbs.md).
16+
After installing the relevant tools, you'll [light up a few](./02-connecting-to-the-lightbulbs.md).
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
# Connecting to the Lightbulbs
1+
# Connecting to the light bulbs
22

3-
While there are no technical restrictions on the kinds of remote devices or APIs you can connect to with transports, for the purpose of this workshop we are connecting to a Philips HUE hub and make some colourful wireless lightbulbs light up. If you (understandably) do not have physical devices available, you can get going with the Hue Emulator.
3+
There are no technical restrictions on the kinds of remote devices or APIs you can connect to with transports. For this lab, we will connect to a Philips HUE hub and make some colourful wireless light bulbs light up. If you (understandably) do not have physical devices available, you can use the Hue Emulator.
44

55
## Hue Emulator
66

77
Download the [HueEmulator-v0.8.jar](https://github.com/SteveyO/Hue-Emulator/blob/master/HueEmulator-v0.8.jar) from [SteveyO/Hue-Emulator](https://github.com/SteveyO/Hue-Emulator).
88

9-
To run this emulator, you will need to have a Java Runtime installed. Once you have java installed, use `java -jar` with the emulator's filename to run it:
9+
To run the Hue Emulator, you need to have a Java Runtime installed. Use `java -jar` with the emulator's filename to run it, for example:
1010

1111
```
1212
david@davids:~$ java -jar ~/Downloads/HueEmulator-v0.8.jar
1313
```
1414

15-
It will not produce any output on the command line, but it will pop up a window with a hub and a few predefined lights:
15+
It does not produce any output on the command line, but a window pops up with a hub and a few predefined lights:
1616

1717
![](./02-connecting-to-the-lightbulbs-emulator.png)
1818

19-
All you need now is to input a port (the default 8000 is usually fine) and press "Start" to activate the built-in server.
19+
All you need now is to input a port (the default 8000 is usually fine) and click "Start" to activate the built-in server.
2020

2121
## Connecting to your hub
2222

23-
To connect to an actual hub, you will need be able to access the Hub on your network and get an API key. Follow the [Philips Developer docs](http://www.developers.meethue.com/documentation/getting-started) (registration required) for that.
23+
To connect to an actual hub, you need be able to access the bub on your network and get an API key. See the [Philips Developer docs](http://www.developers.meethue.com/documentation/getting-started) (registration required).
2424

2525

2626
## Next up
2727

28-
Once you have some lights up, head on to [create a new module](./03-creating-a-new-module.md).
28+
Now that you have some lights up, you'll [create a module](./03-creating-a-new-module.md).

docs/hands-on-lab/03-creating-a-new-module.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
# Create a new module
1+
# Create a module
22

3-
Depending on your preferences, you can use the VSCode/PDK integration or run the PDK from the command line in a terminal of your choice.
3+
Depending on your preferences, you can use the VSCode/PDK integration or run PDK from the command line in a terminal of your choice.
44

5-
## VSCode
5+
## Create a module with VSCode
66

7-
Hit up the Command Palette (⇧⌘P on the Mac or Ctrl+Shift+P on Windows and Linux) and search for the `Puppet: PDK New Module` task:
7+
Spin up the Command Palette (⇧⌘P on the Mac or Ctrl+Shift+P on Windows and Linux) and search for the `Puppet: PDK New Module` task:
88

99
![](./03-creating-a-new-module_vscode.png)
1010

11-
Press Enter (↩) to execute this and follow the on-screen prompts.
11+
Click Enter (↩) to execute this and follow the on-screen prompts.
1212

1313
The module will open in a new VSCode window.
1414

15-
## Command Line
15+
## Create a module from the command line
1616

17-
In your regular workspace (for example your home directory) run
17+
In your regular workspace (for example your home directory), run the following:
1818

1919
```
2020
pdk new module hue_workshop --skip-interview
2121
```
2222

23-
This will create a new module `hue_workshop` in a directory of the same name, using all defaults. Output should look like the following:
23+
This command creates a new module `hue_workshop` in your directory of the same name, using all defaults. The output will look like:
2424

2525
```
2626
david@davids:~/tmp$ pdk new module hue_workshop --skip-interview
@@ -33,15 +33,15 @@ CHANGELOG.md examples Gemfile hiera.yaml metadata.json README.md tasks
3333
david@davids:~/tmp$
3434
```
3535

36-
To read more about the different options when creating new modules see [the PDK docs](https://puppet.com/docs/pdk/1.x/pdk_creating_modules.html).
36+
To read more about the different options when creating new modules, see [PDK docs](https://puppet.com/docs/pdk/1.x/pdk_creating_modules.html).
3737

38-
Open the new directory in VSCode, or your coding editor of choice:
38+
Open the new directory in your code editor:
3939

4040
```
4141
code -a hue_workshop
4242
```
4343

44-
For this workshop, we'll active a few future defaults to make our lives easier down the line. Directly in the `hue_workshop` directory, create a file called `.sync.yml` and paste the following snippet:
44+
Next, we'll active a few future defaults. In the `hue_workshop` directory, create a file called `.sync.yml` and paste the following:
4545

4646
```
4747
# .sync.yml
@@ -56,7 +56,7 @@ spec/spec_helper.rb:
5656
mock_with: ':rspec'
5757
```
5858

59-
Then run `pdk update` in the module's directory to deploy the changes into the module:
59+
Run `pdk update` in the module's directory to deploy the changes in the module:
6060

6161
```
6262
david@davids:~/tmp/hue_workshop$ pdk update
@@ -82,4 +82,4 @@ david@davids:~/tmp/hue_workshop$
8282

8383
## Next up
8484

85-
Once you have the module ready, head on to [add a transport](./04-adding-a-new-transport.md).
85+
Now that you have created a module, you'll [add a transport](./04-adding-a-new-transport.md).

docs/hands-on-lab/04-adding-a-new-transport.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Add a new transport
22

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.
3+
[Eventually](https://github.com/puppetlabs/pdk/pull/666) there will be a `pdk new transport` command. For now, you'll need to copy the files below.
44

55
Copy the files from [this directory](./04-adding-a-new-transport/) into your new module:
66

@@ -11,7 +11,7 @@ Copy the files from [this directory](./04-adding-a-new-transport/) into your new
1111
* spec/unit/puppet/transport/hue_spec.rb
1212
* spec/unit/puppet/transport/schema/hue_spec.rb
1313

14-
Afterwards run `pdk update --force` to enable a few future defaults that are required for these templates:
14+
Run `pdk update --force` to enable a few future defaults that are required for these templates:
1515

1616
```
1717
david@davids:~/tmp/hue$ pdk update --force
@@ -36,7 +36,7 @@ david@davids:~/tmp/hue$
3636

3737
## Checkpoint
3838

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`:
39+
To validate your new module and transport, run `pdk validate --parallel` and `pdk test unit`:
4040

4141
```
4242
david@davids:~/tmp/hue$ pdk validate --parallel
@@ -62,7 +62,7 @@ Run options: exclude {:bolt=>true}
6262
david@davids:~/tmp/hue$
6363
```
6464

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:
65+
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:
6666

6767
```
6868
david@davids:~/tmp/hue$ git init
@@ -102,4 +102,4 @@ david@davids:~/tmp/hue$
102102

103103
## Next up
104104

105-
Once you have everything ready, head on to [implement the transport](./05-implementing-the-transport.md).
105+
Now that you have everything ready, you'll [implement the transport](./05-implementing-the-transport.md).

docs/hands-on-lab/05-implementing-the-transport-hints.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
## Implementing the transport - Exercise
22

3-
Implement a `request_debug` option that can be toggled on to create additional debug output on each request. You will not need concepts that you haven't yet seen in this tutorial, and basic programing skills. If you get stuck, have a look at some hints below, or [the finished file](TODO).
3+
Implement the `request_debug` option that you can toggle on to create additional debug output on each request. If you get stuck, review the hints below, or [the finished file](TODO).
44

55
## Hints
66

7-
* A toggle option can be created with the `Boolean` (`true` or `false`) data type. Add it to the `connection_info` in the transport schema.
7+
* You can create a toggle option with the `Boolean` (`true` or `false`) data type. Add it to the `connection_info` in the transport schema.
88

99
* Make it an `Optional[Boolean]` so that users who do not require request debugging do not have to specify the value.
1010

11-
* To remember the value passed in from the user, store `connection_info[:request_debug]` in a `@request_debug` variable.
11+
* To remember the value you passed, store `connection_info[:request_debug]` in a `@request_debug` variable.
1212

13-
* In the `hue_get` and `hue_put` methods add `context.debug(message)` calls showing the method's arguments.
13+
* In the `hue_get` and `hue_put` methods, add `context.debug(message)` calls showing the method's arguments.
1414

15-
* Make the debugging optional based on the user's input by appending `if @request_debug` to each logging statement.
15+
* Make the debugging optional based on your input by appending `if @request_debug` to each logging statement.
1616

1717
# Next Up
1818

docs/hands-on-lab/05-implementing-the-transport.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ A transport consists of a *schema* describing the required data and credentials
44

55
## Schema
66

7-
The transport schema defines those attributes in a reusable manner, allowing users to understand the requirements of the transport. All schemas are located in `lib/puppet/transport/schema` in a ruby file named after the transport. In this case `hue.rb`.
7+
The transport schema defines attributes in a reusable way, allowing you to understand the requirements of the transport. All schemas are located in `lib/puppet/transport/schema` in a Ruby file named after the transport. In this case `hue.rb`.
88

9-
To connect to the HUE hub we need an IP address, a port, and an API key.
9+
To connect to the HUE hub you need an IP address, a port, and an API key.
1010

11-
Replace the `connection_info` in `lib/puppet/transport/schema/hue.rb` with the following snippet.
11+
Replace the `connection_info` in `lib/puppet/transport/schema/hue.rb` with the following code:
1212

1313
```ruby
1414
connection_info: {
@@ -28,21 +28,21 @@ Replace the `connection_info` in `lib/puppet/transport/schema/hue.rb` with the f
2828
},
2929
```
3030

31-
> Note: The Resource API transports use [Puppet Data Types](https://puppet.com/docs/puppet/5.3/lang_data_type.html#core-data-types) to define the allowable values for an attribute. Abstract types like `Optional[]` can be useful to make using your transport easier. Take special note of the `sensitive: true` annotation on the `key`; it instructs all services processing this attribute with special care, for example to avoid logging the key.
31+
> Note: The Resource API transports use [Puppet Data Types](https://puppet.com/docs/puppet/5.3/lang_data_type.html#core-data-types) to define the allowable values for an attribute. Abstract types like `Optional[]` can be useful to make using your transport easier. Take note of the `sensitive: true` annotation on the `key`; it instructs all services processing this attribute with special care, for example to avoid logging the key.
3232
3333

3434
## Implementation
3535

36-
The implementation of a transport provides connectivity and utility functions for both puppet and the providers managing the remote target. The HUE API is a simple REST interface, so we can store the credentials until we need make a connection. The default template at `lib/puppet/transport/hue.rb` already does this. Have a look at the `initialize` function to see how this is done.
36+
The implementation of a transport provides connectivity and utility functions for both Puppet and the providers managing the remote target. The HUE API is a simple REST interface, so you can store the credentials until you need make a connection. The default template at `lib/puppet/transport/hue.rb` already does this. Have a look at the `initialize` function to see how this is done.
3737

38-
For the HUE's REST API, we want to create a `Faraday` object to capture the target host and key, so the transport can facilitate requests. Replace the `initialize` method in `lib/puppet/transport/hue.rb` with the following snippet:
38+
For the HUE's REST API, we want to create a `Faraday` object to capture the target host and key so that the transport can facilitate requests. Replace the `initialize` method in `lib/puppet/transport/hue.rb` with the following code:
3939

4040
<!-- TODO: do we really need this? -- probably not ```
4141
# @summary
4242
# Expose the `Faraday` object connected to the hub
4343
attr_reader :connection
4444
45-
``` -->
45+
```-->
4646
```
4747
# @summary
4848
# Initializes and returns a faraday connection to the given host
@@ -60,7 +60,7 @@ For the HUE's REST API, we want to create a `Faraday` object to capture the targ
6060

6161
The transport is also responsible for collecting any facts from the remote target, similar to how facter works for regular systems. For now we'll only return a hardcoded `operatingsystem` value to mark HUE Hubs:
6262

63-
Replace the example `facts` method in `lib/puppet/transport/hue.rb` with this snippet:
63+
Replace the example `facts` method in `lib/puppet/transport/hue.rb` with the following code:
6464

6565
```
6666
# @summary
@@ -70,13 +70,13 @@ Replace the example `facts` method in `lib/puppet/transport/hue.rb` with this sn
7070
end
7171
```
7272

73-
### Connection Verification and Closing
73+
### Connection verification and closing
7474

7575
To enable better feedback when something goes wrong, a transport can implement a `verify` method to run extra checks on the credentials passed in.
7676

7777
To save resources both on the target and the node running the transport, the `close` method will be called when the transport is not needed anymore. The transport can close connections and release memory and other resources at this point.
7878

79-
For this tutorial, replace the example methods with this snippet:
79+
For this tutorial, replace the example methods with the following code:
8080

8181
```
8282
# @summary
@@ -93,9 +93,9 @@ For this tutorial, replace the example methods with this snippet:
9393

9494
### Making requests
9595

96-
Besides exposing some standardises functionality to puppet, the transport is also a good place to put utility functions that can be reused across your providers. While it may seem overkill for this small example, it is no extra effort, and will establish a healthy pattern.
96+
Besides exposing some standardises functionality to Puppet, the transport is also a good place to put utility functions that can be reused across your providers. While it may seem overkill for this small example, it is no extra effort, and will establish a healthy pattern.
9797

98-
Insert the following snippet after the `close` method:
98+
Insert the following code after the `close` method:
9999

100100
```
101101
# @summary
@@ -118,7 +118,7 @@ Insert the following snippet after the `close` method:
118118

119119
## Exercise
120120

121-
Implement a `request_debug` option that can be toggled on to create additional debug output on each request. You will not need concepts that you haven't yet seen in this tutorial, and basic programing skills. If you get stuck, have a look at [some hints](./05-implementing-the-transport-hints.md), or [the finished file](TODO).
121+
Implement a `request_debug` option that you can toggle to create additional debug output on each request. If you get stuck, have a look at [some hints](./05-implementing-the-transport-hints.md), or [the finished file](TODO).
122122

123123

124124
# Next Up

0 commit comments

Comments
 (0)