frontegg.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from materialize.mzcompose.service import (
  10. Service,
  11. ServiceDependency,
  12. )
  13. from materialize.ui import UIError
  14. class FronteggMock(Service):
  15. def __init__(
  16. self,
  17. users: str,
  18. issuer: str,
  19. encoding_key: str | None = None,
  20. encoding_key_file: str | None = None,
  21. decoding_key: str | None = None,
  22. decoding_key_file: str | None = None,
  23. name: str = "frontegg-mock",
  24. mzbuild: str = "frontegg-mock",
  25. volumes: list[str] = [],
  26. depends_on: list[str] = [],
  27. ) -> None:
  28. command = [
  29. "--listen-addr=0.0.0.0:6880",
  30. "--users",
  31. users,
  32. "--issuer",
  33. issuer,
  34. ]
  35. if encoding_key:
  36. command += ["--encoding-key", encoding_key]
  37. elif encoding_key_file:
  38. command += ["--encoding-key-file", encoding_key_file]
  39. else:
  40. raise UIError("FronteggMock service must specify encoding-key[-file]")
  41. if decoding_key:
  42. command += ["--decoding-key", decoding_key]
  43. elif decoding_key_file:
  44. command += ["--decoding-key-file", decoding_key_file]
  45. else:
  46. raise UIError("FronteggMock service must specify decoding-key[-file]")
  47. depends_graph: dict[str, ServiceDependency] = {
  48. s: {"condition": "service_started"} for s in depends_on
  49. }
  50. super().__init__(
  51. name=name,
  52. config={
  53. "mzbuild": mzbuild,
  54. "command": command,
  55. "ports": [6880],
  56. "volumes": volumes,
  57. "depends_on": depends_graph,
  58. },
  59. )