]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: kresctl: print nothing on success
authorAleš Mrázek <ales.mrazek@nic.cz>
Thu, 2 Mar 2023 15:23:54 +0000 (16:23 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Thu, 2 Mar 2023 15:23:54 +0000 (16:23 +0100)
doc/manager-client.rst
manager/knot_resolver_manager/cli/cmd/config.py
manager/knot_resolver_manager/cli/cmd/reload.py
manager/knot_resolver_manager/cli/cmd/schema.py
manager/knot_resolver_manager/cli/cmd/stop.py
manager/knot_resolver_manager/cli/cmd/validate.py

index d5c8157c480ed8072b3211997be46350b2ac0f63..1d202d8b602f42fd97d2ec0666811457c3a91fe9 100644 (file)
@@ -143,7 +143,7 @@ Only one of these arguments can be selected during the execution of a single ``k
 
     .. option:: -l, --live
 
-        Get current configuration JSON-schema directly from the running resolver.
+        Get configuration JSON-schema from the running resolver.
         Requires connection to the management API.
 
     .. option:: <file>
index 80a90dd4f5a39f81f870c870f344ec459a95ce5a..33e7ea32cc8910680122387d5794c15ca26888fb 100644 (file)
@@ -244,8 +244,6 @@ class ConfigCommand(Command):
             print(response)
             sys.exit(1)
 
-        print(f"status: {response.status}")
-
         if self.operation == Operations.GET and self.file:
             with open(self.file, "w") as f:
                 f.write(reformat(response.body, self.format))
index 0ed903c0f5eb60a5594eb6a6a16a79556a25a17a..5818a54c134cf7e0ee50a55f5139738346a96085 100644 (file)
@@ -29,9 +29,8 @@ class ReloadCommand(Command):
         return {}
 
     def run(self, args: CommandArgs) -> None:
-        url = f"{args.socket}/reload"
-        response = request("POST", url)
-        print(response)
+        response = request("POST", f"{args.socket}/reload")
 
         if response.status != 200:
+            print(response)
             sys.exit(1)
index 9b40e8f7b73dfc357ca3cbc9a7dd20b207f88075..0d8a032426129bc8491cf50a082207fbba39dda1 100644 (file)
@@ -25,7 +25,7 @@ class SchemaCommand(Command):
         schema.add_argument(
             "-l",
             "--live",
-            help="Get current configuration JSON-schema directly from the running resolver. Requires connection to the management API.",
+            help="Get configuration JSON-schema from the running resolver. Requires connection to the management API.",
             action="store_true",
             default=False,
         )
@@ -41,11 +41,10 @@ class SchemaCommand(Command):
     def run(self, args: CommandArgs) -> None:
         if self.live:
             response = request("GET", f"{args.socket}/schema")
-            if response.status == 200:
-                schema = response.body
-            else:
+            if response.status != 200:
                 print(response)
                 sys.exit(1)
+            schema = response.body
         else:
             schema = json.dumps(KresConfig.json_schema(), indent=4)
 
index 471927f6327b2cfe56d035c67374cb05cf30d2b5..e792dec33be87ab7723c464ca03e9971cfead0d5 100644 (file)
@@ -11,18 +11,6 @@ class StopCommand(Command):
     def __init__(self, namespace: argparse.Namespace) -> None:
         super().__init__(namespace)
 
-    def run(self, args: CommandArgs) -> None:
-        url = f"{args.socket}/stop"
-        response = request("POST", url)
-        print(response)
-
-        if response.status != 200:
-            sys.exit(1)
-
-    @staticmethod
-    def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
-        return {}
-
     @staticmethod
     def register_args_subparser(
         subparser: "argparse._SubParsersAction[argparse.ArgumentParser]",
@@ -31,3 +19,14 @@ class StopCommand(Command):
             "stop", help="Tells the resolver to shutdown everthing. No process will run after this command."
         )
         return stop, StopCommand
+
+    def run(self, args: CommandArgs) -> None:
+        response = request("POST", f"{args.socket}/stop")
+
+        if response.status != 200:
+            print(response)
+            sys.exit(1)
+
+    @staticmethod
+    def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
+        return {}
index a93e5a9d72ec1c8efd2ac43355edcceb29e57b05..f2bd4c7789f6675e5353cda108319068d2c96d08 100644 (file)
@@ -39,11 +39,10 @@ class ValidateCommand(Command):
             with open(self.input_file, "r") as f:
                 data = f.read()
         else:
-            data = input("Type new configuration: ")
+            data = input("Type configuration to validate: ")
 
         try:
             KresConfig(try_to_parse(data))
-            print("config is valid")
         except (DataParsingError, DataValidationError) as e:
             print(e)
             sys.exit(1)