← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad-layers:states-to-flags into launchpad-layers:main

 

Colin Watson has proposed merging ~cjwatson/launchpad-layers:states-to-flags into launchpad-layers:main.

Commit message:
Avoid deprecated reactive functions

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-layers/+git/launchpad-layers/+merge/441455

`set_state` and `remove_state` were deprecated in charms.reactive 0.5.0; see https://charmsreactive.readthedocs.io/en/latest/changelog.html.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad-layers:states-to-flags into launchpad-layers:main.
diff --git a/launchpad-base/reactive/launchpad-base.py b/launchpad-base/reactive/launchpad-base.py
index 3063019..adc40d7 100644
--- a/launchpad-base/reactive/launchpad-base.py
+++ b/launchpad-base/reactive/launchpad-base.py
@@ -14,10 +14,10 @@ from charms.launchpad.base import (
     update_pgpass,
 )
 from charms.reactive import (
+    clear_flag,
     endpoint_from_flag,
     hook,
-    remove_state,
-    set_state,
+    set_flag,
     when,
     when_any,
     when_none,
@@ -65,12 +65,12 @@ def get_rabbitmq_uris(rabbitmq):
 
 @when_any("rabbitmq.available", "config.set.rabbitmq_broker_urls")
 def rabbitmq_available():
-    set_state("launchpad.rabbitmq.available")
+    set_flag("launchpad.rabbitmq.available")
 
 
 @when_none("rabbitmq.available", "config.set.rabbitmq_broker_urls")
 def rabbitmq_unavailable():
-    remove_state("launchpad.rabbitmq.available")
+    clear_flag("launchpad.rabbitmq.available")
 
 
 @when("ols.configured", "db.master.available", "launchpad.rabbitmq.available")
@@ -108,7 +108,7 @@ def configure():
     configure_rsync(
         config, "launchpad-base-rsync.conf", "010-launchpad-base.conf"
     )
-    set_state("launchpad.base.configured")
+    set_flag("launchpad.base.configured")
 
 
 @when("launchpad.base.configured")
@@ -116,8 +116,8 @@ def configure():
     "ols.configured", "db.master.available", "launchpad.rabbitmq.available"
 )
 def deconfigure():
-    remove_state("launchpad.base.configured")
-    remove_state("service.configured")
+    clear_flag("launchpad.base.configured")
+    clear_flag("service.configured")
 
 
 @hook("upgrade-charm")
@@ -126,31 +126,31 @@ def upgrade_charm():
     # ols.configured, and service.configured states.  Remove
     # launchpad.base.configured as well so that we have an opportunity to
     # rewrite base configuration files.
-    remove_state("launchpad.base.configured")
+    clear_flag("launchpad.base.configured")
 
 
 @when("config.changed.build_label")
 def build_label_changed():
-    remove_state("ols.service.installed")
-    remove_state("ols.configured")
-    remove_state("launchpad.base.configured")
-    remove_state("service.configured")
+    clear_flag("ols.service.installed")
+    clear_flag("ols.configured")
+    clear_flag("launchpad.base.configured")
+    clear_flag("service.configured")
 
 
 @when("config.changed")
 def config_changed():
-    remove_state("launchpad.base.configured")
-    remove_state("service.configured")
+    clear_flag("launchpad.base.configured")
+    clear_flag("service.configured")
 
 
 @when("db.database.changed", "launchpad.base.configured")
 def db_changed():
-    remove_state("launchpad.base.configured")
-    remove_state("service.configured")
-    remove_state("db.database.changed")
+    clear_flag("launchpad.base.configured")
+    clear_flag("service.configured")
+    clear_flag("db.database.changed")
 
 
 @hook("{requires:rabbitmq}-relation-changed")
 def rabbitmq_relation_changed(*args):
-    remove_state("launchpad.base.configured")
-    remove_state("service.configured")
+    clear_flag("launchpad.base.configured")
+    clear_flag("service.configured")