Class: Chef::Knife::DigitalOceanDomainRecordEdit
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::DigitalOceanDomainRecordEdit
- Includes:
- DigitalOceanBase
- Defined in:
- lib/chef/knife/digital_ocean_domain_record_edit.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
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 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/chef/knife/digital_ocean_domain_record_edit.rb', line 48 def run $stdout.sync = true validate! unless locate_config_value(:domain) ui.error('Domain cannot be empty. => -D <domain-name>') exit 1 end unless locate_config_value(:record) ui.error('Record cannot be empty. => -R <record-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.update(domain_record, for_domain: locate_config_value(:domain), id: locate_config_value(:record) ) ui.info 'OK' if result == true || ui.error(JSON.parse(result)['message']) end |