Create a class

To create a class in your module, use the pdk new class command.

The pdk new class command creates a class manifest file, with the naming convention class_name.pp, and a test file.

  1. From the command line, in your module's directory, run pdk new class <CLASS_NAME>

    To create the module's main class, defined in an init.pp file, give the class the same name as the module: pdk new class <MODULE_NAME>.

Results

PDK creates the new class manifest and a test template file (class_name_spec.rb) in your module's /spec/classes directory. The test template checks that your class compiles on all supported operating systems as listed in the metadata.json file. You can then write additional tests in the test file to validate your class's behavior.