diff --git a/changelog/+escape-hfid.fixed.md b/changelog/+escape-hfid.fixed.md new file mode 100644 index 00000000..b7621ef5 --- /dev/null +++ b/changelog/+escape-hfid.fixed.md @@ -0,0 +1 @@ +- Fixed issue with improperly escaped special characters in `hfid` fields and other string values in GraphQL mutations by implementing proper JSON-style string escaping \ No newline at end of file diff --git a/changelog/529.added.md b/changelog/529.added.md new file mode 100644 index 00000000..cb02de4f --- /dev/null +++ b/changelog/529.added.md @@ -0,0 +1,2 @@ +Add `create_diff` method to create a diff summary between two timestamps +Update `get_diff_summary` to accept optional time range parameters \ No newline at end of file diff --git a/changelog/535.fixed.md b/changelog/535.fixed.md new file mode 100644 index 00000000..fdbd499e --- /dev/null +++ b/changelog/535.fixed.md @@ -0,0 +1 @@ +Fix branch handling in `_run_transform` and `execute_graphql_query` functions in Infrahubctl to use environment variables for branch management. \ No newline at end of file diff --git a/docs/docs/python-sdk/introduction.mdx b/docs/docs/python-sdk/introduction.mdx index 1b737dca..26f945ce 100644 --- a/docs/docs/python-sdk/introduction.mdx +++ b/docs/docs/python-sdk/introduction.mdx @@ -1,9 +1,16 @@ --- title: Python SDK --- +import VideoPlayer from '../../src/components/VideoPlayer'; The Infrahub Python SDK greatly simplifies how you can interact with Infrahub programmatically. +## Videos + +
+ +
+ ## Blog posts - [Querying Data in Infrahub via the Python SDK](https://www.opsmill.com/querying-data-in-infrahub-via-the-python-sdk/) diff --git a/docs/package-lock.json b/docs/package-lock.json index 7fdd6241..35a180d1 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -15,7 +15,8 @@ "prism-react-renderer": "^2.3.0", "raw-loader": "^4.0.2", "react": "^18.0.0", - "react-dom": "^18.0.0" + "react-dom": "^18.0.0", + "react-player": "^3.3.2" }, "devDependencies": { "@docusaurus/module-type-aliases": "^3.8.1", @@ -4076,6 +4077,74 @@ "react": ">=16" } }, + "node_modules/@mux/mux-data-google-ima": { + "version": "0.2.8", + "resolved": "https://registry.npmjs.org/@mux/mux-data-google-ima/-/mux-data-google-ima-0.2.8.tgz", + "integrity": "sha512-0ZEkHdcZ6bS8QtcjFcoJeZxJTpX7qRIledf4q1trMWPznugvtajCjCM2kieK/pzkZj1JM6liDRFs1PJSfVUs2A==", + "license": "MIT", + "dependencies": { + "mux-embed": "5.9.0" + } + }, + "node_modules/@mux/mux-player": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@mux/mux-player/-/mux-player-3.6.0.tgz", + "integrity": "sha512-yVWmTMJUoKNZZxsINFmz7ZUUR3GC+Qf7b6Qv2GTmUoYn14pO1aXywHLlMLDohstLIvdeOdh6F/WsD2/gDVSOmQ==", + "license": "MIT", + "dependencies": { + "@mux/mux-video": "0.27.0", + "@mux/playback-core": "0.31.0", + "media-chrome": "~4.13.1", + "player.style": "^0.2.0" + } + }, + "node_modules/@mux/mux-player-react": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/@mux/mux-player-react/-/mux-player-react-3.6.0.tgz", + "integrity": "sha512-bh2Z1fQqNkKCNUMS/3VU6jL2iY22155ZSIyizfz+bVX0EYHqdsS/iG95iDYLPlzA8WPyIh+J210tme68e1qP+w==", + "license": "MIT", + "dependencies": { + "@mux/mux-player": "3.6.0", + "@mux/playback-core": "0.31.0", + "prop-types": "^15.8.1" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0", + "react": "^17.0.2 || ^17.0.0-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0", + "react-dom": "^17.0.2 || ^17.0.2-0 || ^18 || ^18.0.0-0 || ^19 || ^19.0.0-0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@mux/mux-video": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/@mux/mux-video/-/mux-video-0.27.0.tgz", + "integrity": "sha512-Oi142YAcPKrmHTG+eaWHWaE7ucMHeJwx1FXABbLM2hMGj9MQ7kYjsD5J3meFlvuyz5UeVDsPLHeUJgeBXUZovg==", + "license": "MIT", + "dependencies": { + "@mux/mux-data-google-ima": "0.2.8", + "@mux/playback-core": "0.31.0", + "castable-video": "~1.1.10", + "custom-media-element": "~1.4.5", + "media-tracks": "~0.3.3" + } + }, + "node_modules/@mux/playback-core": { + "version": "0.31.0", + "resolved": "https://registry.npmjs.org/@mux/playback-core/-/playback-core-0.31.0.tgz", + "integrity": "sha512-VADcrtS4O6fQBH8qmgavS6h7v7amzy2oCguu1NnLaVZ3Z8WccNXcF0s7jPRoRDyXWGShgtVhypW2uXjLpkPxyw==", + "license": "MIT", + "dependencies": { + "hls.js": "~1.6.6", + "mux-embed": "^5.8.3" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4465,6 +4534,12 @@ "url": "https://github.com/sponsors/gregberge" } }, + "node_modules/@svta/common-media-library": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/@svta/common-media-library/-/common-media-library-0.12.4.tgz", + "integrity": "sha512-9EuOoaNmz7JrfGwjsrD9SxF9otU5TNMnbLu1yU4BeLK0W5cDxVXXR58Z89q9u2AnHjIctscjMTYdlqQ1gojTuw==", + "license": "Apache-2.0" + }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", @@ -4876,6 +4951,16 @@ "integrity": "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==", "license": "ISC" }, + "node_modules/@vimeo/player": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/@vimeo/player/-/player-2.29.0.tgz", + "integrity": "sha512-9JjvjeqUndb9otCCFd0/+2ESsLk7VkDE6sxOBy9iy2ukezuQbplVRi+g9g59yAurKofbmTi/KcKxBGO/22zWRw==", + "license": "MIT", + "dependencies": { + "native-promise-only": "0.8.1", + "weakmap-polyfill": "2.0.4" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.14.1.tgz", @@ -5500,6 +5585,45 @@ "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==", "license": "MIT" }, + "node_modules/bcp-47": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/bcp-47/-/bcp-47-2.1.0.tgz", + "integrity": "sha512-9IIS3UPrvIa1Ej+lVDdDwO7zLehjqsaByECw0bu2RRGP73jALm6FYbzI5gWbgHLvNdkvfXB5YrSbocZdOS0c0w==", + "license": "MIT", + "dependencies": { + "is-alphabetical": "^2.0.0", + "is-alphanumerical": "^2.0.0", + "is-decimal": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-match": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/bcp-47-match/-/bcp-47-match-2.0.3.tgz", + "integrity": "sha512-JtTezzbAibu8G0R9op9zb3vcWZd9JF6M0xOYGPn0fNCd7wOpRB1mU2mH9T8gaBGbAAyIIVgB2G7xG0GP98zMAQ==", + "license": "MIT", + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, + "node_modules/bcp-47-normalize": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/bcp-47-normalize/-/bcp-47-normalize-2.3.0.tgz", + "integrity": "sha512-8I/wfzqQvttUFz7HVJgIZ7+dj3vUaIyIxYXaTRP1YWoSDfzt6TUmxaKZeuXR62qBmYr+nvuWINFRl6pZ5DlN4Q==", + "license": "MIT", + "dependencies": { + "bcp-47": "^2.0.0", + "bcp-47-match": "^2.0.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/wooorm" + } + }, "node_modules/big.js": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", @@ -5813,6 +5937,15 @@ ], "license": "CC-BY-4.0" }, + "node_modules/castable-video": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/castable-video/-/castable-video-1.1.10.tgz", + "integrity": "sha512-/T1I0A4VG769wTEZ8gWuy1Crn9saAfRTd1UYTb8xbOPlN78+zOi/1nU2dD5koNkfE5VWvgabkIqrGKmyNXOjSQ==", + "license": "MIT", + "dependencies": { + "custom-media-element": "~1.4.5" + } + }, "node_modules/ccount": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/ccount/-/ccount-2.0.1.tgz", @@ -5823,6 +5956,15 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/ce-la-react": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/ce-la-react/-/ce-la-react-0.3.1.tgz", + "integrity": "sha512-g0YwpZDPIwTwFumGTzNHcgJA6VhFfFCJkSNdUdC04br2UfU+56JDrJrJva3FZ7MToB4NDHAFBiPE/PZdNl1mQA==", + "license": "BSD-3-Clause", + "peerDependencies": { + "react": ">=17.0.0" + } + }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -6065,6 +6207,12 @@ "node": ">=6" } }, + "node_modules/cloudflare-video-element": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/cloudflare-video-element/-/cloudflare-video-element-1.3.4.tgz", + "integrity": "sha512-F9g+tXzGEXI6v6L48qXxr8vnR8+L6yy7IhpJxK++lpzuVekMHTixxH7/dzLuq6OacVGziU4RB5pzZYJ7/LYtJg==", + "license": "MIT" + }, "node_modules/clsx": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz", @@ -6074,6 +6222,12 @@ "node": ">=6" } }, + "node_modules/codem-isoboxer": { + "version": "0.3.10", + "resolved": "https://registry.npmjs.org/codem-isoboxer/-/codem-isoboxer-0.3.10.tgz", + "integrity": "sha512-eNk3TRV+xQMJ1PEj0FQGY8KD4m0GPxT487XJ+Iftm7mVa9WpPFDMWqPt+46buiP5j5Wzqe5oMIhqBcAeKfygSA==", + "license": "MIT" + }, "node_modules/collapse-white-space": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-2.1.0.tgz", @@ -6914,6 +7068,40 @@ "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", "license": "MIT" }, + "node_modules/custom-media-element": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/custom-media-element/-/custom-media-element-1.4.5.tgz", + "integrity": "sha512-cjrsQufETwxjvwZbYbKBCJNvmQ2++G9AvT45zDi7NXL9k2PdVcs2h0jQz96J6G4TMKRCcEsoJ+QTgQD00Igtjw==", + "license": "MIT" + }, + "node_modules/dash-video-element": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/dash-video-element/-/dash-video-element-0.1.6.tgz", + "integrity": "sha512-4gHShaQjcFv6diX5EzB6qAdUGKlIUGGZY8J8yp2pQkWqR0jX4c6plYy0cFraN7mr0DZINe8ujDN1fssDYxJjcg==", + "license": "MIT", + "dependencies": { + "custom-media-element": "^1.4.5", + "dashjs": "^5.0.3" + } + }, + "node_modules/dashjs": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/dashjs/-/dashjs-5.0.3.tgz", + "integrity": "sha512-TXndNnCUjFjF2nYBxDVba+hWRpVkadkQ8flLp7kHkem+5+wZTfRShJCnVkPUosmjS0YPE9fVNLbYPJxHBeQZvA==", + "license": "BSD-3-Clause", + "dependencies": { + "@svta/common-media-library": "^0.12.4", + "bcp-47-match": "^2.0.3", + "bcp-47-normalize": "^2.3.0", + "codem-isoboxer": "0.3.10", + "fast-deep-equal": "3.1.3", + "html-entities": "^2.5.2", + "imsc": "^1.1.5", + "localforage": "^1.10.0", + "path-browserify": "^1.0.1", + "ua-parser-js": "^1.0.37" + } + }, "node_modules/debounce": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", @@ -8704,6 +8892,23 @@ "value-equal": "^1.0.1" } }, + "node_modules/hls-video-element": { + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/hls-video-element/-/hls-video-element-1.5.7.tgz", + "integrity": "sha512-R+uYimNZQndT2iqBgW7Gm0KiHT6pmlt5tnT63rYIcqOEcKD59M6pmdwqtX2vKPfHo+1ACM14Fy9JF1YMwlrLdQ==", + "license": "MIT", + "dependencies": { + "custom-media-element": "^1.4.5", + "hls.js": "^1.6.5", + "media-tracks": "^0.3.3" + } + }, + "node_modules/hls.js": { + "version": "1.6.12", + "resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.6.12.tgz", + "integrity": "sha512-Pz+7IzvkbAht/zXvwLzA/stUHNqztqKvlLbfpq6ZYU68+gZ+CZMlsbQBPUviRap+3IQ41E39ke7Ia+yvhsehEQ==", + "license": "Apache-2.0" + }, "node_modules/hoist-non-react-statics": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", @@ -9067,6 +9272,12 @@ "node": ">=16.x" } }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "license": "MIT" + }, "node_modules/import-fresh": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", @@ -9092,6 +9303,21 @@ "node": ">=8" } }, + "node_modules/imsc": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/imsc/-/imsc-1.1.5.tgz", + "integrity": "sha512-V8je+CGkcvGhgl2C1GlhqFFiUOIEdwXbXLiu1Fcubvvbo+g9inauqT3l0pNYXGoLPBj3jxtZz9t+wCopMkwadQ==", + "license": "BSD-2-Clause", + "dependencies": { + "sax": "1.2.1" + } + }, + "node_modules/imsc/node_modules/sax": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", + "integrity": "sha512-8I2a3LovHTOpm7NV5yOyO8IHqgVsfK4+UuySrXU8YXkSRX7k6hCV9b3HrkKCr3nMpgj+0bmocaJJWpvp1oc7ZA==", + "license": "ISC" + }, "node_modules/imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -9662,6 +9888,15 @@ "node": ">=6" } }, + "node_modules/lie": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", + "integrity": "sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw==", + "license": "MIT", + "dependencies": { + "immediate": "~3.0.5" + } + }, "node_modules/lilconfig": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.3.tgz", @@ -9703,6 +9938,15 @@ "node": ">=8.9.0" } }, + "node_modules/localforage": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.10.0.tgz", + "integrity": "sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg==", + "license": "Apache-2.0", + "dependencies": { + "lie": "3.1.1" + } + }, "node_modules/locate-path": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-7.2.0.tgz", @@ -10233,6 +10477,21 @@ "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", "license": "CC0-1.0" }, + "node_modules/media-chrome": { + "version": "4.13.1", + "resolved": "https://registry.npmjs.org/media-chrome/-/media-chrome-4.13.1.tgz", + "integrity": "sha512-jPPwYrFkM4ky27/xNYEeyRPOBC7qvru4Oydy7vQHMHplXLQJmjtcauhlLPvG0O5kkYFEaOBXv5zGYes/UxOoVw==", + "license": "MIT", + "dependencies": { + "ce-la-react": "^0.3.0" + } + }, + "node_modules/media-tracks": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/media-tracks/-/media-tracks-0.3.3.tgz", + "integrity": "sha512-9P2FuUHnZZ3iji+2RQk7Zkh5AmZTnOG5fODACnjhCVveX1McY3jmCRHofIEI+yTBqplz7LXy48c7fQ3Uigp88w==", + "license": "MIT" + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -12213,6 +12472,12 @@ "multicast-dns": "cli.js" } }, + "node_modules/mux-embed": { + "version": "5.9.0", + "resolved": "https://registry.npmjs.org/mux-embed/-/mux-embed-5.9.0.tgz", + "integrity": "sha512-wmunL3uoPhma/tWy8PrDPZkvJpXvSFBwbD3KkC4PG8Ztjfb1X3hRJwGUAQyRz7z99b/ovLm2UTTitrkvStjH4w==", + "license": "MIT" + }, "node_modules/nanoid": { "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", @@ -12231,6 +12496,12 @@ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" } }, + "node_modules/native-promise-only": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/native-promise-only/-/native-promise-only-0.8.1.tgz", + "integrity": "sha512-zkVhZUA3y8mbz652WrL5x0fB0ehrBkulWT3TomAQ9iDtyXZvzKeEA6GPxAItBYeNYl5yngKRX612qHOhvMkDeg==", + "license": "MIT" + }, "node_modules/negotiator": { "version": "0.6.4", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.4.tgz", @@ -12791,6 +13062,12 @@ "tslib": "^2.0.3" } }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==", + "license": "MIT" + }, "node_modules/path-exists": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-5.0.0.tgz", @@ -12881,6 +13158,22 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/player.style": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/player.style/-/player.style-0.2.0.tgz", + "integrity": "sha512-Ngoaz49TClptMr8HDA2IFmjT3Iq6R27QEUH/C+On33L59RSF3dCLefBYB1Au2RDZQJ6oVFpc1sXaPVpp7fEzzA==", + "license": "MIT", + "workspaces": [ + ".", + "site", + "examples/*", + "scripts/*", + "themes/*" + ], + "dependencies": { + "media-chrome": "~4.13.0" + } + }, "node_modules/postcss": { "version": "8.5.6", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.6.tgz", @@ -14756,6 +15049,29 @@ "webpack": ">=4.41.1 || 5.x" } }, + "node_modules/react-player": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/react-player/-/react-player-3.3.2.tgz", + "integrity": "sha512-MBSCxTA1FPyMR19Wy+2LtVjguhrLl9p2l5nODY4fbumgsoaCEuhMLpZvxh8RWjzzvqL8V3jYcPfw/XhqrbTzFw==", + "license": "MIT", + "dependencies": { + "@mux/mux-player-react": "^3.5.1", + "cloudflare-video-element": "^1.3.3", + "dash-video-element": "^0.1.6", + "hls-video-element": "^1.5.6", + "spotify-audio-element": "^1.0.2", + "tiktok-video-element": "^0.1.0", + "twitch-video-element": "^0.1.2", + "vimeo-video-element": "^1.5.3", + "wistia-video-element": "^1.3.3", + "youtube-video-element": "^1.6.1" + }, + "peerDependencies": { + "@types/react": "^17.0.0 || ^18 || ^19", + "react": "^17.0.2 || ^18 || ^19", + "react-dom": "^17.0.2 || ^18 || ^19" + } + }, "node_modules/react-router": { "version": "5.3.4", "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.3.4.tgz", @@ -16060,6 +16376,12 @@ "wbuf": "^1.7.3" } }, + "node_modules/spotify-audio-element": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/spotify-audio-element/-/spotify-audio-element-1.0.3.tgz", + "integrity": "sha512-I1/qD8cg/UnTlCIMiKSdZUJTyYfYhaqFK7LIVElc48eOqUUbVCaw1bqL8I6mJzdMJTh3eoNyF/ewvB7NoS/g9A==", + "license": "MIT" + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -16250,6 +16572,12 @@ "postcss": "^8.4.31" } }, + "node_modules/super-media-element": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/super-media-element/-/super-media-element-1.4.2.tgz", + "integrity": "sha512-9pP/CVNp4NF2MNlRzLwQkjiTgKKe9WYXrLh9+8QokWmMxz+zt2mf1utkWLco26IuA3AfVcTb//qtlTIjY3VHxA==", + "license": "MIT" + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -16420,6 +16748,12 @@ "integrity": "sha512-eHY7nBftgThBqOyHGVN+l8gF0BucP09fMo0oO/Lb0w1OF80dJv+lDVpXG60WMQvkcxAkNybKsrEIE3ZtKGmPrA==", "license": "MIT" }, + "node_modules/tiktok-video-element": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/tiktok-video-element/-/tiktok-video-element-0.1.1.tgz", + "integrity": "sha512-BaiVzvNz2UXDKTdSrXzrNf4q6Ecc+/utYUh7zdEu2jzYcJVDoqYbVfUl0bCfMoOeeAqg28vD/yN63Y3E9jOrlA==", + "license": "MIT" + }, "node_modules/tiny-invariant": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", @@ -16497,6 +16831,12 @@ "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", "license": "0BSD" }, + "node_modules/twitch-video-element": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/twitch-video-element/-/twitch-video-element-0.1.4.tgz", + "integrity": "sha512-SDpZ4f7sZmwHF6XG5PF0KWuP18pH/kNG04MhTcpqJby7Lk/D3TS/lCYd+RSg0rIAAVi1LDgSIo1yJs9kmHlhgw==", + "license": "MIT" + }, "node_modules/type-fest": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-2.19.0.tgz", @@ -16566,6 +16906,32 @@ "node": ">=14.17" } }, + "node_modules/ua-parser-js": { + "version": "1.0.41", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.41.tgz", + "integrity": "sha512-LbBDqdIC5s8iROCUjMbW1f5dJQTEFB1+KO9ogbvlb3nm9n4YHa5p4KTvFPWvh2Hs8gZMBuiB1/8+pdfe/tDPug==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + }, + { + "type": "github", + "url": "https://github.com/sponsors/faisalman" + } + ], + "license": "MIT", + "bin": { + "ua-parser-js": "script/cli.js" + }, + "engines": { + "node": "*" + } + }, "node_modules/undici-types": { "version": "7.10.0", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.10.0.tgz", @@ -17060,6 +17426,15 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/vimeo-video-element": { + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/vimeo-video-element/-/vimeo-video-element-1.5.5.tgz", + "integrity": "sha512-9QVvKPPnubMNeNYHY5KZqAYerVMuVG+7PSK+6IrEUD7a/wnCGtzb8Sfxl9qNxDAL6Q8i+p+5SDoVKobCd866vw==", + "license": "MIT", + "dependencies": { + "@vimeo/player": "2.29.0" + } + }, "node_modules/watchpack": { "version": "2.4.4", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.4.tgz", @@ -17082,6 +17457,15 @@ "minimalistic-assert": "^1.0.0" } }, + "node_modules/weakmap-polyfill": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/weakmap-polyfill/-/weakmap-polyfill-2.0.4.tgz", + "integrity": "sha512-ZzxBf288iALJseijWelmECm/1x7ZwQn3sMYIkDr2VvZp7r6SEKuT8D0O9Wiq6L9Nl5mazrOMcmiZE/2NCenaxw==", + "license": "MIT", + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/web-namespaces": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-2.0.1.tgz", @@ -17483,6 +17867,15 @@ "integrity": "sha512-CC1bOL87PIWSBhDcTrdeLo6eGT7mCFtrg0uIJtqJUFyK+eJnzl8A1niH56uu7KMa5XFrtiV+AQuHO3n7DsHnLQ==", "license": "MIT" }, + "node_modules/wistia-video-element": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/wistia-video-element/-/wistia-video-element-1.3.4.tgz", + "integrity": "sha512-2l22oaQe4jUfi3yvsh2m2oCEgvbqTzaSYx6aJnZAvV5hlMUJlyZheFUnaj0JU2wGlHdVGV7xNY+5KpKu+ruLYA==", + "license": "MIT", + "dependencies": { + "super-media-element": "~1.4.2" + } + }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -17620,6 +18013,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/youtube-video-element": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/youtube-video-element/-/youtube-video-element-1.6.2.tgz", + "integrity": "sha512-YHDIOAqgRpfl1Ois9HcB8UFtWOxK8KJrV5TXpImj4BKYP1rWT04f/fMM9tQ9SYZlBKukT7NR+9wcI3UpB5BMDQ==", + "license": "MIT" + }, "node_modules/zwitch": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-2.0.4.tgz", diff --git a/docs/package.json b/docs/package.json index 0817379e..0dc1e714 100644 --- a/docs/package.json +++ b/docs/package.json @@ -22,7 +22,8 @@ "prism-react-renderer": "^2.3.0", "raw-loader": "^4.0.2", "react": "^18.0.0", - "react-dom": "^18.0.0" + "react-dom": "^18.0.0", + "react-player": "^3.3.2" }, "devDependencies": { "@docusaurus/module-type-aliases": "^3.8.1", diff --git a/docs/src/components/VideoPlayer/index.tsx b/docs/src/components/VideoPlayer/index.tsx new file mode 100644 index 00000000..b100cc12 --- /dev/null +++ b/docs/src/components/VideoPlayer/index.tsx @@ -0,0 +1,31 @@ +import React from 'react'; +import ReactPlayer from 'react-player'; + +interface VideoPlayerProps { + url: string; + light?: boolean; +} + +export default function VideoPlayer({ url, light = false }: VideoPlayerProps) { + return ( +
+
+ +
+
+ ); +} \ No newline at end of file diff --git a/infrahub_sdk/branch.py b/infrahub_sdk/branch.py index 2403e1ef..2b1905ce 100644 --- a/infrahub_sdk/branch.py +++ b/infrahub_sdk/branch.py @@ -188,9 +188,7 @@ async def all(self) -> dict[str, BranchData]: query = Query(name="GetAllBranch", query=QUERY_ALL_BRANCHES_DATA) data = await self.client.execute_graphql(query=query.render(), tracker="query-branch-all") - branches = {branch["name"]: BranchData(**branch) for branch in data["Branch"]} - - return branches + return {branch["name"]: BranchData(**branch) for branch in data["Branch"]} async def get(self, branch_name: str) -> BranchData: query = Query(name="GetBranch", query=QUERY_ONE_BRANCH_DATA, variables={"branch_name": str}) @@ -230,9 +228,7 @@ def all(self) -> dict[str, BranchData]: query = Query(name="GetAllBranch", query=QUERY_ALL_BRANCHES_DATA) data = self.client.execute_graphql(query=query.render(), tracker="query-branch-all") - branches = {branch["name"]: BranchData(**branch) for branch in data["Branch"]} - - return branches + return {branch["name"]: BranchData(**branch) for branch in data["Branch"]} def get(self, branch_name: str) -> BranchData: query = Query(name="GetBranch", query=QUERY_ONE_BRANCH_DATA, variables={"branch_name": str}) diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index 671a2f5f..6b27599a 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -5,6 +5,7 @@ import logging import time from collections.abc import Coroutine, MutableMapping +from datetime import datetime from functools import wraps from time import sleep from typing import ( @@ -24,6 +25,7 @@ from .batch import InfrahubBatch, InfrahubBatchSync from .branch import ( + MUTATION_QUERY_TASK, BranchData, InfrahubBranchManager, InfrahubBranchManagerSync, @@ -305,8 +307,7 @@ def _initialize(self) -> None: async def get_version(self) -> str: """Return the Infrahub version.""" response = await self.execute_graphql(query="query { InfrahubInfo { version }}") - version = response.get("InfrahubInfo", {}).get("version", "") - return version + return response.get("InfrahubInfo", {}).get("version", "") async def get_user(self) -> dict: """Return user information""" @@ -1154,21 +1155,57 @@ async def query_gql_query( return decode_json(response=resp) + async def create_diff( + self, branch: str, name: str, from_time: datetime, to_time: datetime, wait_until_completion: bool = True + ) -> bool | str: + if from_time > to_time: + raise ValueError("from_time must be <= to_time") + input_data = { + "wait_until_completion": wait_until_completion, + "data": { + "name": name, + "branch": branch, + "from_time": from_time.isoformat(), + "to_time": to_time.isoformat(), + }, + } + + mutation_query = MUTATION_QUERY_TASK if not wait_until_completion else {"ok": None} + query = Mutation(mutation="DiffUpdate", input_data=input_data, query=mutation_query) + response = await self.execute_graphql(query=query.render(), tracker="mutation-diff-update") + + if not wait_until_completion and "task" in response["DiffUpdate"]: + return response["DiffUpdate"]["task"]["id"] + + return response["DiffUpdate"]["ok"] + async def get_diff_summary( self, branch: str, + name: str | None = None, + from_time: datetime | None = None, + to_time: datetime | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True, ) -> list[NodeDiff]: query = get_diff_summary_query() + input_data = {"branch_name": branch} + if name: + input_data["name"] = name + if from_time and to_time and from_time > to_time: + raise ValueError("from_time must be <= to_time") + if from_time: + input_data["from_time"] = from_time.isoformat() + if to_time: + input_data["to_time"] = to_time.isoformat() response = await self.execute_graphql( query=query, branch_name=branch, timeout=timeout, tracker=tracker, raise_for_error=raise_for_error, - variables={"branch_name": branch}, + variables=input_data, ) node_diffs: list[NodeDiff] = [] @@ -1564,8 +1601,7 @@ def _initialize(self) -> None: def get_version(self) -> str: """Return the Infrahub version.""" response = self.execute_graphql(query="query { InfrahubInfo { version }}") - version = response.get("InfrahubInfo", {}).get("version", "") - return version + return response.get("InfrahubInfo", {}).get("version", "") def get_user(self) -> dict: """Return user information""" @@ -2293,21 +2329,57 @@ def query_gql_query( return decode_json(response=resp) + def create_diff( + self, branch: str, name: str, from_time: datetime, to_time: datetime, wait_until_completion: bool = True + ) -> bool | str: + if from_time > to_time: + raise ValueError("from_time must be <= to_time") + input_data = { + "wait_until_completion": wait_until_completion, + "data": { + "name": name, + "branch": branch, + "from_time": from_time.isoformat(), + "to_time": to_time.isoformat(), + }, + } + + mutation_query = MUTATION_QUERY_TASK if not wait_until_completion else {"ok": None} + query = Mutation(mutation="DiffUpdate", input_data=input_data, query=mutation_query) + response = self.execute_graphql(query=query.render(), tracker="mutation-diff-update") + + if not wait_until_completion and "task" in response["DiffUpdate"]: + return response["DiffUpdate"]["task"]["id"] + + return response["DiffUpdate"]["ok"] + def get_diff_summary( self, branch: str, + name: str | None = None, + from_time: datetime | None = None, + to_time: datetime | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True, ) -> list[NodeDiff]: query = get_diff_summary_query() + input_data = {"branch_name": branch} + if name: + input_data["name"] = name + if from_time and to_time and from_time > to_time: + raise ValueError("from_time must be <= to_time") + if from_time: + input_data["from_time"] = from_time.isoformat() + if to_time: + input_data["to_time"] = to_time.isoformat() response = self.execute_graphql( query=query, branch_name=branch, timeout=timeout, tracker=tracker, raise_for_error=raise_for_error, - variables={"branch_name": branch}, + variables=input_data, ) node_diffs: list[NodeDiff] = [] diff --git a/infrahub_sdk/ctl/cli_commands.py b/infrahub_sdk/ctl/cli_commands.py index bc6cc3d3..91222785 100644 --- a/infrahub_sdk/ctl/cli_commands.py +++ b/infrahub_sdk/ctl/cli_commands.py @@ -46,7 +46,7 @@ from ..schema import MainSchemaTypesAll, SchemaRoot from ..template import Jinja2Template from ..template.exceptions import JinjaTemplateError -from ..utils import get_branch, write_to_file +from ..utils import write_to_file from ..yaml import SchemaFile from .exporter import dump from .importer import load @@ -208,7 +208,6 @@ async def _run_transform( debug: Prints debug info to the command line repository_config: Repository config object. This is used to load the graphql query from the repository. """ - branch = get_branch(branch) try: response = execute_graphql_query( diff --git a/infrahub_sdk/ctl/utils.py b/infrahub_sdk/ctl/utils.py index 66f86865..074a066e 100644 --- a/infrahub_sdk/ctl/utils.py +++ b/infrahub_sdk/ctl/utils.py @@ -118,6 +118,10 @@ def execute_graphql_query( query_str = query_object.load_query() client = initialize_client_sync() + + if not branch: + branch = client.config.default_infrahub_branch + response = client.execute_graphql( query=query_str, branch_name=branch, diff --git a/infrahub_sdk/ctl/validate.py b/infrahub_sdk/ctl/validate.py index 99318239..d1715d9f 100644 --- a/infrahub_sdk/ctl/validate.py +++ b/infrahub_sdk/ctl/validate.py @@ -14,7 +14,7 @@ from ..ctl.exceptions import QueryNotFoundError from ..ctl.utils import catch_exception, find_graphql_query, parse_cli_vars from ..exceptions import GraphQLError -from ..utils import get_branch, write_to_file +from ..utils import write_to_file from ..yaml import SchemaFile from .parameters import CONFIG_PARAM from .utils import load_yamlfile_from_disk_and_exit @@ -68,8 +68,6 @@ def validate_graphql( ) -> None: """Validate the format of a GraphQL Query stored locally by executing it on a remote GraphQL endpoint""" - branch = get_branch(branch) - try: query_str = find_graphql_query(query) except QueryNotFoundError: @@ -81,6 +79,10 @@ def validate_graphql( variables_dict = parse_cli_vars(variables) client = initialize_client_sync() + + if not branch: + branch = client.config.default_infrahub_branch + try: response = client.execute_graphql( query=query_str, diff --git a/infrahub_sdk/diff.py b/infrahub_sdk/diff.py index c445000f..fad10080 100644 --- a/infrahub_sdk/diff.py +++ b/infrahub_sdk/diff.py @@ -37,8 +37,8 @@ class NodeDiffPeer(TypedDict): def get_diff_summary_query() -> str: return """ - query GetDiffTree($branch_name: String!) { - DiffTree(branch: $branch_name) { + query GetDiffTree($branch_name: String!, $name: String, $from_time: DateTime, $to_time: DateTime) { + DiffTree(branch: $branch_name, name: $name, from_time: $from_time, to_time: $to_time) { nodes { uuid kind @@ -117,12 +117,11 @@ def diff_tree_node_to_node_diff(node_dict: dict[str, Any], branch_name: str) -> ) relationship_diff["peers"] = peer_diffs element_diffs.append(relationship_diff) - node_diff = NodeDiff( + return NodeDiff( branch=branch_name, kind=str(node_dict.get("kind")), id=str(node_dict.get("uuid")), - action=str(node_dict.get("action")), + action=str(node_dict.get("status")), display_label=str(node_dict.get("label")), elements=element_diffs, ) - return node_diff diff --git a/infrahub_sdk/graphql.py b/infrahub_sdk/graphql.py index cf48ad83..2610e8d1 100644 --- a/infrahub_sdk/graphql.py +++ b/infrahub_sdk/graphql.py @@ -1,5 +1,6 @@ from __future__ import annotations +import json from enum import Enum from typing import Any @@ -18,7 +19,9 @@ def convert_to_graphql_as_string(value: Any, convert_enum: bool = False) -> str: return convert_to_graphql_as_string(value=value.value, convert_enum=True) return value.name if isinstance(value, str): - return f'"{value}"' + # Use json.dumps() to properly escape the string according to JSON rules, + # which are compatible with GraphQL string escaping + return json.dumps(value) if isinstance(value, bool): return repr(value).lower() if isinstance(value, list): diff --git a/infrahub_sdk/node/node.py b/infrahub_sdk/node/node.py index e6d129c3..72624467 100644 --- a/infrahub_sdk/node/node.py +++ b/infrahub_sdk/node/node.py @@ -579,8 +579,7 @@ async def artifact_fetch(self, name: str) -> str | dict[str, Any]: self._validate_artifact_support(ARTIFACT_GENERATE_FEATURE_NOT_SUPPORTED_MESSAGE) artifact = await self._client.get(kind="CoreArtifact", name__value=name, object__ids=[self.id]) - content = await self._client.object_store.get(identifier=artifact._get_attribute(name="storage_id").value) - return content + return await self._client.object_store.get(identifier=artifact._get_attribute(name="storage_id").value) async def delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None: input_data = {"data": {"id": self.id}} @@ -1208,8 +1207,7 @@ def artifact_generate(self, name: str) -> None: def artifact_fetch(self, name: str) -> str | dict[str, Any]: self._validate_artifact_support(ARTIFACT_FETCH_FEATURE_NOT_SUPPORTED_MESSAGE) artifact = self._client.get(kind="CoreArtifact", name__value=name, object__ids=[self.id]) - content = self._client.object_store.get(identifier=artifact._get_attribute(name="storage_id").value) - return content + return self._client.object_store.get(identifier=artifact._get_attribute(name="storage_id").value) def delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None: input_data = {"data": {"id": self.id}} diff --git a/infrahub_sdk/playback.py b/infrahub_sdk/playback.py index 0ec72e8c..c00badc5 100644 --- a/infrahub_sdk/playback.py +++ b/infrahub_sdk/playback.py @@ -56,5 +56,4 @@ def _read_request( with Path(f"{self.directory}/{filename}.json").open(encoding="utf-8") as fobj: data = ujson.load(fobj) - response = httpx.Response(status_code=data["status_code"], content=data["response_content"], request=request) - return response + return httpx.Response(status_code=data["status_code"], content=data["response_content"], request=request) diff --git a/infrahub_sdk/repository.py b/infrahub_sdk/repository.py index 9472c4fa..331d15f1 100644 --- a/infrahub_sdk/repository.py +++ b/infrahub_sdk/repository.py @@ -29,5 +29,4 @@ def initialize_repo(self) -> Repo: @property def active_branch(self) -> str | None: - active_branch = porcelain.active_branch(self.root_directory).decode("utf-8") - return active_branch + return porcelain.active_branch(self.root_directory).decode("utf-8") diff --git a/infrahub_sdk/timestamp.py b/infrahub_sdk/timestamp.py index a9a56278..578a149e 100644 --- a/infrahub_sdk/timestamp.py +++ b/infrahub_sdk/timestamp.py @@ -43,8 +43,7 @@ def obj(self) -> ZonedDateTime: @classmethod def _parse_string(cls, value: str) -> ZonedDateTime: try: - zoned_date = ZonedDateTime.parse_common_iso(value) - return zoned_date + return ZonedDateTime.parse_common_iso(value) except ValueError: pass diff --git a/pyproject.toml b/pyproject.toml index cb185950..0e29c57a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -193,7 +193,6 @@ ignore = [ "PLW1641", # Object does not implement `__hash__` method "PTH100", # `os.path.abspath()` should be replaced by `Path.resolve()` "PTH109", # `os.getcwd()` should be replaced by `Path.cwd()` - "RET504", # Unnecessary assignment to `data` before `return` statement "RUF005", # Consider `[*path, str(key)]` instead of concatenation "RUF015", # Prefer `next(iter(input_data["variables"].keys()))` over single element slice "RUF029", # Function is declared `async`, but doesn't `await` or use `async` features. @@ -273,6 +272,7 @@ max-complexity = 17 "ANN201", # ANN201 Missing return type annotation for public function "ANN202", # Missing return type annotation for private function "ANN204", # Missing return type annotation for special method + "RET504", # Unnecessary assignment to `data` before `return` statement ] "tests/unit/sdk/test_client.py" = [ diff --git a/tests/fixtures/repos/ctl_integration/.infrahub.yml b/tests/fixtures/repos/ctl_integration/.infrahub.yml index 605cdff4..7d7d8682 100644 --- a/tests/fixtures/repos/ctl_integration/.infrahub.yml +++ b/tests/fixtures/repos/ctl_integration/.infrahub.yml @@ -26,7 +26,13 @@ generator_definitions: parameters: name: "name__value" +jinja2_transforms: + - name: tags + query: "tags_query" + template_path: "templates/tags.j2" queries: - name: animal_person file_path: queries/animal_person.gql + - name: tags_query + file_path: templates/tags_query.gql diff --git a/tests/fixtures/repos/ctl_integration/templates/tags.j2 b/tests/fixtures/repos/ctl_integration/templates/tags.j2 new file mode 100644 index 00000000..deeeb42c --- /dev/null +++ b/tests/fixtures/repos/ctl_integration/templates/tags.j2 @@ -0,0 +1 @@ +{{ data['BuiltinTag']['edges'][0]['node']['name']['value'] }} \ No newline at end of file diff --git a/tests/fixtures/repos/ctl_integration/templates/tags_query.gql b/tests/fixtures/repos/ctl_integration/templates/tags_query.gql new file mode 100644 index 00000000..6d2ea6ab --- /dev/null +++ b/tests/fixtures/repos/ctl_integration/templates/tags_query.gql @@ -0,0 +1,11 @@ +query TagsQuery($name: String!) { + BuiltinTag(name__value: $name) { + edges { + node { + name { + value + } + } + } + } +} diff --git a/tests/unit/ctl/test_render_app.py b/tests/unit/ctl/test_render_app.py index dceba985..0589acda 100644 --- a/tests/unit/ctl/test_render_app.py +++ b/tests/unit/ctl/test_render_app.py @@ -73,3 +73,44 @@ def test_validate_template_not_found(test_case: RenderAppFailure, httpx_mock: HT output = runner.invoke(app, ["render", test_case.template, "name=red"]) assert test_case.error in strip_color(output.stdout) assert output.exit_code == 1 + + +@pytest.mark.parametrize( + "cli_branch,env_branch,from_git,expected_branch", + [ + ("cli-branch", None, False, "cli-branch"), + (None, "env-branch", False, "env-branch"), + (None, None, True, "git-branch"), + ], +) +@requires_python_310 +def test_render_branch_selection(monkeypatch, httpx_mock: HTTPXMock, cli_branch, env_branch, from_git, expected_branch): + """Test that the render command uses the correct branch source.""" + + if from_git: + monkeypatch.setattr("dulwich.porcelain.active_branch", lambda _: b"git-branch") + + httpx_mock.add_response( + method="POST", + url=f"http://mock/graphql/{expected_branch}", + json=json.loads( + read_fixture( + "red_tag.json", + "unit/test_infrahubctl/red_tags_query", + ) + ), + ) + + with temp_repo_and_cd(source_dir=FIXTURE_BASE_DIR / "ctl_integration"): + args = ["render", "tags", "name=red"] + env = {} + # Add test-specific variables + if cli_branch: + args.extend(["--branch", cli_branch]) + if env_branch: + env["INFRAHUB_DEFAULT_BRANCH"] = env_branch + env["INFRAHUB_DEFAULT_BRANCH_FROM_GIT"] = "false" + if from_git: + env["INFRAHUB_DEFAULT_BRANCH_FROM_GIT"] = "true" + output = runner.invoke(app, args, env=env) + assert output.exit_code == 0 diff --git a/tests/unit/sdk/test_diff_summary.py b/tests/unit/sdk/test_diff_summary.py index 7a176b20..73832cab 100644 --- a/tests/unit/sdk/test_diff_summary.py +++ b/tests/unit/sdk/test_diff_summary.py @@ -109,7 +109,7 @@ async def test_diffsummary(clients: BothClients, mock_diff_tree_query, client_ty "branch": "branch2", "kind": "TestCar", "id": "17fbadf0-6637-4fa2-43e6-1677ea170e0f", - "action": "None", + "action": "UPDATED", "display_label": "nolt #444444", "elements": [ { @@ -124,7 +124,7 @@ async def test_diffsummary(clients: BothClients, mock_diff_tree_query, client_ty "branch": "branch2", "kind": "TestPerson", "id": "17fbadf0-634f-05a8-43e4-1677e744d4c0", - "action": "None", + "action": "UPDATED", "display_label": "Jane", "elements": [ { @@ -140,7 +140,7 @@ async def test_diffsummary(clients: BothClients, mock_diff_tree_query, client_ty "branch": "branch2", "kind": "TestPerson", "id": "17fbadf0-6243-5d3c-43ee-167718ff8dac", - "action": "None", + "action": "UPDATED", "display_label": "Jonathan", "elements": [ {