brpm_module_brpm 0.1.24 → 0.1.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +8 -8
  2. data/config.yml +1 -1
  3. data/lib/brpm_rest_client.rb +33 -23
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTNlM2E2N2Y5MTcyOTMxMTA5MWUwN2JjODY3N2YzNDVhZDlkNjU3Ng==
4
+ NjY2YzYwMWRkMWUxOTNjYTBiZTVjYjY4YjEwNTAzZDE0NjJmNzdlNA==
5
5
  data.tar.gz: !binary |-
6
- NjVlYmI3YmYzMjRlODQ0NWFiMGQxZTQyMmRmM2FjNDA0MTI4YWM0MQ==
6
+ NzMzNTMzZjQxY2U0MjNiMWYxODRiYmQ4ZTA1OTJkZWU0YjRmZTMxMg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWE4ZGU3MDg0MTMwMTczNTYzNTI0NDQ2Y2Y0NTM3Mzg2MDQyM2ExMDhlMzBh
10
- ZTNjNWU4MjZkZWRjYjU0MmJlYzJkYzNlNTA4ZGJmMzAxODRhYmE4OWJlNGI0
11
- OWQ3MTJjYWNlMWI3Y2RiMzljOTFlZmE2NWI5ZmQyNzE5YzNjZDc=
9
+ YmJlZjI0ZTA3YzZmNjczNWRjNjU4N2VlMzM0ODBmZjczM2YwMzc3ZDcxMDAx
10
+ NjUwZGUxODJlMjAyYTc1Y2QyZWQ1ZWJlZmIwN2U4ZGIwMmE0YzhiYmQ0YTA0
11
+ YzhmZDU3YmE5Yzk4ZTk2MjlkZDIwZjZjMDNmZmRlNWZlMjdjN2U=
12
12
  data.tar.gz: !binary |-
13
- NjllMmNjOTRmZmNiN2UzYTA1NTQxZmU0OGNlZGJlOWVmZTZmMWJhNjZiZTlm
14
- NjJhMDdkYjU3NWM2NjIwYzM1YTkxYjQ1YTk5ODhjNmRiNmEwNzQ0Y2IzMTIy
15
- ZGUwZGRmOTQ0YjU1MDBiYTZhYWQzZTRkZjI4MDNiN2UxODNmZmU=
13
+ ZTQ5MGI3ZDc3YmJmZWQ1Y2EzOWQ4NzRhOTRmMTVkNTVjNzQ4NDliZjU5NTBh
14
+ ZmIxZmFlODgwZmM4OTUwODRkNGJjMTZmNGI4NjE5ZDZmMTU3OTJhYTgyYTEx
15
+ YzgxNDkyZjg5MzljNTJkNzUwMzc2ZTM1ODdjNjdkZGYzM2VlOTQ=
data/config.yml CHANGED
@@ -1,4 +1,4 @@
1
- version: 0.1.24
1
+ version: 0.1.25
2
2
 
3
3
  author: Niek Bartholomeus
4
4
  email: niek.bartholomeus@gmail.com
@@ -1636,11 +1636,7 @@ class BrpmRestClient
1636
1636
  result = brpm_get "v1/scripts?filters[name]=#{name}"
1637
1637
 
1638
1638
  if result["status"] == "success"
1639
- if result["response"] == "null"
1640
- result_hash = nil
1641
- else
1642
- result_hash = result["response"].first
1643
- end
1639
+ result_hash = result["response"].first
1644
1640
  else
1645
1641
  if result["code"] == 404
1646
1642
  result_hash = nil
@@ -1695,30 +1691,44 @@ class BrpmRestClient
1695
1691
  end
1696
1692
 
1697
1693
  def create_or_update_script(script)
1698
- BrpmAuto.log "Checking if the corresponding script already exists ..."
1699
- existing_script = get_script_by_name(script["name"])
1700
-
1701
- if existing_script.nil?
1702
- BrpmAuto.log "Script doesn't exist yet."
1703
- script_already_exists=false
1704
- else
1705
- BrpmAuto.log "Script already exists."
1706
- script_already_exists=true
1707
-
1708
- script["id"] = existing_script["id"].to_s
1709
- end
1694
+ # TODO: the scripts REST API is not finished yet: get_script_by_name always returns "null". So for now we are going to create the script and if it returns an error that the name is already taken we will update it
1695
+
1696
+ # BrpmAuto.log "Checking if the corresponding script already exists ..."
1697
+ # existing_script = get_script_by_name(script["name"])
1698
+ #
1699
+ # if existing_script.nil?
1700
+ # BrpmAuto.log "Script doesn't exist yet."
1701
+ # script_already_exists=false
1702
+ # else
1703
+ # BrpmAuto.log "Script already exists."
1704
+ # script_already_exists=true
1705
+ #
1706
+ # script["id"] = existing_script["id"].to_s
1707
+ # end
1710
1708
 
1711
1709
  data = {}
1712
1710
  data["script"] = script
1713
1711
 
1714
- if script_already_exists
1715
- BrpmAuto.log "Updating the script..."
1716
- script = update_script_from_hash(script)
1717
- BrpmAuto.log "Script is updated."
1718
- else
1719
- BrpmAuto.log "Creating the script..."
1712
+ # if script_already_exists
1713
+ # BrpmAuto.log "Updating the script..."
1714
+ # script = update_script_from_hash(script)
1715
+ # BrpmAuto.log "Script is updated."
1716
+ # else
1717
+ # BrpmAuto.log "Creating the script..."
1718
+ # script = create_script_from_hash(script)
1719
+ # BrpmAuto.log "Script is created."
1720
+ # end
1721
+
1722
+ BrpmAuto.log "Creating the script..."
1723
+ begin
1720
1724
  script = create_script_from_hash(script)
1721
1725
  BrpmAuto.log "Script is created."
1726
+ rescue Exception => e
1727
+ if "#{e}".include?("has already been taken")
1728
+ BrpmAuto.log "Script already exists, updating it..."
1729
+ script = update_script_from_hash(script)
1730
+ BrpmAuto.log "Script is updated."
1731
+ end
1722
1732
  end
1723
1733
 
1724
1734
  script
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brpm_module_brpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.24
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niek Bartholomeus