INNER CODE UNIT · Python

api

theonedev/onedev · server-product/helm/files/stop-servers.py:95

    def api(method, path, body=None):
        request = urllib.request.Request(endpoint + path, method=method,
            data=json.dumps(body).encode() if body is not None else None,
            headers={"Authorization": "Bearer " + (credentials / "token").read_text().strip(),
                     "Content-Type": "application/merge-patch+json" if method == "PATCH" else "application/json"})
        with urllib.request.urlopen(request, context=context, timeout=15) as response:
            return json.load(response)

    stop_servers(api, os.environ["POD_NAMESPACE"], os.environ["STATEFULSET_NAME"],
                 os.environ["TARGET_IMAGE"], int(os.environ["STOP_TIMEOUT"]))


if __name__ == "__main__":
    main()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…