Class: Chef::Knife::DigitalOceanDomainRecordCreate
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::DigitalOceanDomainRecordCreate
- Includes:
- DigitalOceanBase
- Defined in:
- lib/chef/knife/digital_ocean_domain_record_create.rb
Instance Method Summary collapse
Methods included from DigitalOceanBase
#client, included, load_deps, #locate_config_value, #validate!, #wait_for_status
Instance Method Details
#run ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/chef/knife/digital_ocean_domain_record_create.rb', line 43 def run $stdout.sync = true validate! unless locate_config_value(:domain) ui.error('Domain cannot be empty. => -D <domain-id>') exit 1 end unless locate_config_value(:type) ui.error('Record type cannot be empty. => -T <record-type>') exit 1 end unless locate_config_value(:name) ui.error('Record name cannot be empty. => -N <record-name>') exit 1 end unless locate_config_value(:data) ui.error('Record data cannot be empty. => -d <data>') exit 1 end domain_record = DropletKit::DomainRecord.new( type: locate_config_value(:type), name: locate_config_value(:name), data: locate_config_value(:data) ) result = client.domain_records.create domain_record, for_domain: locate_config_value(:domain) ui.info 'OK' if result.class == DropletKit::DomainRecord || ui.error(JSON.parse(result)['message']) end |