From bfa61058cd22d80aec8965858af114e89bc7da3b Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Thu, 9 Oct 2025 20:06:06 -0700 Subject: [PATCH] remove github only managed repo webhooks feature. Not well implemented or documented, also provider specific. --- Cargo.lock | 411 +++--------------- Cargo.toml | 10 +- bin/core/Cargo.toml | 2 - bin/core/src/api/read/build.rs | 84 +--- bin/core/src/api/read/mod.rs | 10 - bin/core/src/api/read/repo.rs | 105 +---- bin/core/src/api/read/stack.rs | 95 +--- bin/core/src/api/read/sync.rs | 96 +--- bin/core/src/api/write/build.rs | 206 +-------- bin/core/src/api/write/mod.rs | 8 - bin/core/src/api/write/repo.rs | 230 +--------- bin/core/src/api/write/stack.rs | 221 +--------- bin/core/src/api/write/sync.rs | 225 +--------- bin/core/src/config.rs | 291 +++++++------ bin/core/src/state.rs | 88 +--- client/core/rs/src/api/read/build.rs | 26 -- client/core/rs/src/api/read/mod.rs | 2 - client/core/rs/src/api/read/repo.rs | 31 -- client/core/rs/src/api/read/stack.rs | 29 -- client/core/rs/src/api/read/sync.rs | 29 -- client/core/rs/src/api/write/action.rs | 39 -- client/core/rs/src/api/write/build.rs | 40 -- client/core/rs/src/api/write/repo.rs | 42 -- client/core/rs/src/api/write/stack.rs | 42 -- client/core/rs/src/api/write/sync.rs | 43 -- client/core/rs/src/entities/config/core.rs | 61 --- client/core/ts/src/responses.ts | 12 - client/core/ts/src/types.ts | 244 +---------- frontend/public/client/responses.d.ts | 12 - frontend/public/client/types.d.ts | 234 +--------- frontend/public/client/types.js | 32 +- .../src/components/resources/build/config.tsx | 70 +-- .../src/components/resources/repo/config.tsx | 183 +------- .../resources/resource-sync/config.tsx | 124 +----- .../src/components/resources/stack/config.tsx | 138 +----- 35 files changed, 301 insertions(+), 3214 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ac10adaba..ec8d24f59 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -61,7 +61,7 @@ dependencies = [ "cfg-if", "getrandom 0.3.3", "once_cell", - "version_check 0.9.5", + "version_check", "zerocopy", ] @@ -158,17 +158,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "async-recursion" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "async-trait" version = "0.1.89" @@ -207,9 +196,9 @@ checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" [[package]] name = "aws-config" -version = "1.8.7" +version = "1.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04b37ddf8d2e9744a0b9c19ce0b78efe4795339a90b66b7bae77987092cd2e69" +checksum = "37cf2b6af2a95a20e266782b4f76f1a5e12bf412a9db2de9c1e9123b9d8c0ad8" dependencies = [ "aws-credential-types", "aws-runtime", @@ -237,9 +226,9 @@ dependencies = [ [[package]] name = "aws-credential-types" -version = "1.2.7" +version = "1.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799a1290207254984cb7c05245111bc77958b92a3c9bb449598044b36341cce6" +checksum = "faf26925f4a5b59eb76722b63c2892b1d70d06fa053c72e4a100ec308c1d47bc" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -273,9 +262,9 @@ dependencies = [ [[package]] name = "aws-runtime" -version = "1.5.11" +version = "1.5.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e1ed337dabcf765ad5f2fb426f13af22d576328aaf09eac8f70953530798ec0" +checksum = "bfa006bb32360ed90ac51203feafb9d02e3d21046e1fd3a450a404b90ea73e5d" dependencies = [ "aws-credential-types", "aws-sigv4", @@ -297,9 +286,9 @@ dependencies = [ [[package]] name = "aws-sdk-ec2" -version = "1.171.0" +version = "1.172.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0cc9763956b4fa7baba55414db830349eaaf0a94ab809f14a14ba466ecb7045c" +checksum = "e64e82faa945cee1d97c8c0239988a4d924d9b29d1b604ad97ded7c8683fbbce" dependencies = [ "aws-credential-types", "aws-runtime", @@ -320,9 +309,9 @@ dependencies = [ [[package]] name = "aws-sdk-sso" -version = "1.85.0" +version = "1.86.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f2c741e2e439f07b5d1b33155e246742353d82167c785a2ff547275b7e32483" +checksum = "4a0abbfab841446cce6e87af853a3ba2cc1bc9afcd3f3550dd556c43d434c86d" dependencies = [ "aws-credential-types", "aws-runtime", @@ -342,9 +331,9 @@ dependencies = [ [[package]] name = "aws-sdk-ssooidc" -version = "1.87.0" +version = "1.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6428ae5686b18c0ee99f6f3c39d94ae3f8b42894cdc35c35d8fb2470e9db2d4c" +checksum = "9a68d675582afea0e94d38b6ca9c5aaae4ca14f1d36faa6edb19b42e687e70d7" dependencies = [ "aws-credential-types", "aws-runtime", @@ -364,9 +353,9 @@ dependencies = [ [[package]] name = "aws-sdk-sts" -version = "1.87.0" +version = "1.88.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5871bec9a79a3e8d928c7788d654f135dde0e71d2dd98089388bab36b37ef607" +checksum = "d30990923f4f675523c51eb1c0dec9b752fb267b36a61e83cbc219c9d86da715" dependencies = [ "aws-credential-types", "aws-runtime", @@ -387,9 +376,9 @@ dependencies = [ [[package]] name = "aws-sigv4" -version = "1.3.4" +version = "1.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084c34162187d39e3740cb635acd73c4e3a551a36146ad6fe8883c929c9f876c" +checksum = "bffc03068fbb9c8dd5ce1c6fb240678a5cffb86fb2b7b1985c999c4b83c8df68" dependencies = [ "aws-credential-types", "aws-smithy-http", @@ -409,9 +398,9 @@ dependencies = [ [[package]] name = "aws-smithy-async" -version = "1.2.5" +version = "1.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e190749ea56f8c42bf15dd76c65e14f8f765233e6df9b0506d9d934ebef867c" +checksum = "127fcfad33b7dfc531141fda7e1c402ac65f88aca5511a4d31e2e3d2cd01ce9c" dependencies = [ "futures-util", "pin-project-lite", @@ -420,9 +409,9 @@ dependencies = [ [[package]] name = "aws-smithy-http" -version = "0.62.3" +version = "0.62.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c4dacf2d38996cf729f55e7a762b30918229917eca115de45dfa8dfb97796c9" +checksum = "3feafd437c763db26aa04e0cc7591185d0961e64c61885bece0fb9d50ceac671" dependencies = [ "aws-smithy-runtime-api", "aws-smithy-types", @@ -440,9 +429,9 @@ dependencies = [ [[package]] name = "aws-smithy-http-client" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "734b4282fbb7372923ac339cc2222530f8180d9d4745e582de19a18cee409fd8" +checksum = "1053b5e587e6fa40ce5a79ea27957b04ba660baa02b28b7436f64850152234f1" dependencies = [ "aws-smithy-async", "aws-smithy-runtime-api", @@ -470,27 +459,27 @@ dependencies = [ [[package]] name = "aws-smithy-json" -version = "0.61.5" +version = "0.61.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaa31b350998e703e9826b2104dd6f63be0508666e1aba88137af060e8944047" +checksum = "cff418fc8ec5cadf8173b10125f05c2e7e1d46771406187b2c878557d4503390" dependencies = [ "aws-smithy-types", ] [[package]] name = "aws-smithy-observability" -version = "0.1.3" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9364d5989ac4dd918e5cc4c4bdcc61c9be17dcd2586ea7f69e348fc7c6cab393" +checksum = "2d1881b1ea6d313f9890710d65c158bdab6fb08c91ea825f74c1c8c357baf4cc" dependencies = [ "aws-smithy-runtime-api", ] [[package]] name = "aws-smithy-query" -version = "0.60.7" +version = "0.60.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2fbd61ceb3fe8a1cb7352e42689cec5335833cd9f94103a61e98f9bb61c64bb" +checksum = "d28a63441360c477465f80c7abac3b9c4d075ca638f982e605b7dc2a2c7156c9" dependencies = [ "aws-smithy-types", "urlencoding", @@ -498,9 +487,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime" -version = "1.9.2" +version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fa63ad37685ceb7762fa4d73d06f1d5493feb88e3f27259b9ed277f4c01b185" +checksum = "40ab99739082da5347660c556689256438defae3bcefd66c52b095905730e404" dependencies = [ "aws-smithy-async", "aws-smithy-http", @@ -522,9 +511,9 @@ dependencies = [ [[package]] name = "aws-smithy-runtime-api" -version = "1.9.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07f5e0fc8a6b3f2303f331b94504bbf754d85488f402d6f1dd7a6080f99afe56" +checksum = "3683c5b152d2ad753607179ed71988e8cfd52964443b4f74fd8e552d0bbfeb46" dependencies = [ "aws-smithy-async", "aws-smithy-types", @@ -539,9 +528,9 @@ dependencies = [ [[package]] name = "aws-smithy-types" -version = "1.3.2" +version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d498595448e43de7f4296b7b7a18a8a02c61ec9349128c80a368f7c3b4ab11a8" +checksum = "9f5b3a7486f6690ba25952cabf1e7d75e34d69eaff5081904a47bc79074d6457" dependencies = [ "base64-simd", "bytes", @@ -565,18 +554,18 @@ dependencies = [ [[package]] name = "aws-smithy-xml" -version = "0.60.10" +version = "0.60.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3db87b96cb1b16c024980f133968d52882ca0daaee3a086c6decc500f6c99728" +checksum = "e9c34127e8c624bc2999f3b657e749c1393bedc9cd97b92a804db8ced4d2e163" dependencies = [ "xmlparser", ] [[package]] name = "aws-types" -version = "1.3.8" +version = "1.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b069d19bf01e46298eaedd7c6f283fe565a59263e53eebec945f3e6398f42390" +checksum = "e2fd329bf0e901ff3f60425691410c69094dc2a1f34b331f37bfc4e9ac1565a1" dependencies = [ "aws-credential-types", "aws-smithy-async", @@ -923,9 +912,6 @@ name = "bytes" version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" -dependencies = [ - "serde", -] [[package]] name = "bytes-utils" @@ -963,7 +949,7 @@ version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" dependencies = [ - "nom 7.1.3", + "nom", ] [[package]] @@ -1272,7 +1258,7 @@ dependencies = [ "bitflags 2.9.4", "crossterm_winapi", "document-features", - "parking_lot 0.12.5", + "parking_lot", "rustix", "winapi", ] @@ -1431,7 +1417,7 @@ dependencies = [ "hashbrown 0.14.5", "lock_api", "once_cell", - "parking_lot_core 0.9.12", + "parking_lot_core", ] [[package]] @@ -1991,7 +1977,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "typenum", - "version_check 0.9.5", + "version_check", "zeroize", ] @@ -2206,7 +2192,7 @@ dependencies = [ "ipconfig", "lru-cache", "once_cell", - "parking_lot 0.12.5", + "parking_lot", "rand 0.8.5", "resolv-conf", "smallvec", @@ -2626,18 +2612,6 @@ dependencies = [ "generic-array", ] -[[package]] -name = "instant" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" -dependencies = [ - "cfg-if", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "interpolate" version = "2.0.0-dev-48" @@ -2762,11 +2736,9 @@ checksum = "5a87cc7a48537badeae96744432de36f4be2b4a34a05a5ef32e9dd8a1c169dde" dependencies = [ "base64 0.22.1", "js-sys", - "pem", "ring", "serde", "serde_json", - "simple_asn1", ] [[package]] @@ -2873,8 +2845,6 @@ dependencies = [ "komodo_client", "logger", "noise", - "nom_pem", - "octorust", "openidconnect", "partial_derive2", "periphery_client", @@ -3025,9 +2995,6 @@ name = "log" version = "0.4.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" -dependencies = [ - "serde", -] [[package]] name = "logger" @@ -3320,16 +3287,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "nom" -version = "4.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" -dependencies = [ - "memchr", - "version_check 0.1.5", -] - [[package]] name = "nom" version = "7.1.3" @@ -3340,15 +3297,6 @@ dependencies = [ "minimal-lexical", ] -[[package]] -name = "nom_pem" -version = "4.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46345232a84add363a2b3bf214777cf13443f6dab781161aafbdadb8b1f0bd2d" -dependencies = [ - "nom 4.2.3", -] - [[package]] name = "ntapi" version = "0.4.1" @@ -3367,16 +3315,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-bigint-dig" version = "0.8.4" @@ -3478,39 +3416,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "octorust" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c488b641cf652f023d371f6d472191bf3b3fd8075a11f274e95d4fe6e5e3878" -dependencies = [ - "async-recursion", - "async-trait", - "bytes", - "chrono", - "http 1.3.1", - "jsonwebtoken", - "log", - "mime", - "parse_link_header", - "pem", - "percent-encoding", - "reqwest", - "reqwest-conditional-middleware", - "reqwest-middleware", - "reqwest-retry", - "reqwest-tracing", - "ring", - "schemars 0.8.22", - "serde", - "serde_json", - "serde_urlencoded", - "thiserror 1.0.69", - "tokio", - "url", - "uuid", -] - [[package]] name = "once_cell" version = "1.21.3" @@ -3696,17 +3601,6 @@ dependencies = [ "sha2", ] -[[package]] -name = "parking_lot" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" -dependencies = [ - "instant", - "lock_api", - "parking_lot_core 0.8.6", -] - [[package]] name = "parking_lot" version = "0.12.5" @@ -3714,21 +3608,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" dependencies = [ "lock_api", - "parking_lot_core 0.9.12", -] - -[[package]] -name = "parking_lot_core" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60a2cfe6f0ad2bfc16aefa463b497d5c7a5ecd44a23efa72aa342d90177356dc" -dependencies = [ - "cfg-if", - "instant", - "libc", - "redox_syscall 0.2.16", - "smallvec", - "winapi", + "parking_lot_core", ] [[package]] @@ -3739,22 +3619,11 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.18", + "redox_syscall", "smallvec", "windows-link 0.2.0", ] -[[package]] -name = "parse_link_header" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3687fe9debbbf2a019f381a8bc6b42049b22647449b39af54b3013985c0cf6de" -dependencies = [ - "http 0.2.12", - "lazy_static", - "regex", -] - [[package]] name = "partial_derive2" version = "0.4.3" @@ -3784,16 +3653,6 @@ dependencies = [ "digest", ] -[[package]] -name = "pem" -version = "3.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38af38e8470ac9dee3ce1bae1af9c1671fffc44ddfd8bd1d0a3445bf349a8ef3" -dependencies = [ - "base64 0.22.1", - "serde", -] - [[package]] name = "pem-rfc7468" version = "0.7.0" @@ -4148,15 +4007,6 @@ dependencies = [ "getrandom 0.3.3", ] -[[package]] -name = "redox_syscall" -version = "0.2.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" -dependencies = [ - "bitflags 1.3.2", -] - [[package]] name = "redox_syscall" version = "0.5.18" @@ -4243,7 +4093,6 @@ dependencies = [ "js-sys", "log", "mime", - "mime_guess", "percent-encoding", "pin-project-lite", "quinn", @@ -4268,71 +4117,6 @@ dependencies = [ "webpki-roots 1.0.2", ] -[[package]] -name = "reqwest-conditional-middleware" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f67ad7fdf5c0a015763fcd164bee294b13fb7b6f89f1b55961d40f00c3e32d6b" -dependencies = [ - "async-trait", - "http 1.3.1", - "reqwest", - "reqwest-middleware", -] - -[[package]] -name = "reqwest-middleware" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57f17d28a6e6acfe1733fe24bcd30774d13bffa4b8a22535b4c8c98423088d4e" -dependencies = [ - "anyhow", - "async-trait", - "http 1.3.1", - "reqwest", - "serde", - "thiserror 1.0.69", - "tower-service", -] - -[[package]] -name = "reqwest-retry" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c73e4195a6bfbcb174b790d9b3407ab90646976c55de58a6515da25d851178" -dependencies = [ - "anyhow", - "async-trait", - "futures", - "getrandom 0.2.16", - "http 1.3.1", - "hyper 1.7.0", - "parking_lot 0.11.2", - "reqwest", - "reqwest-middleware", - "retry-policies", - "thiserror 1.0.69", - "tokio", - "tracing", - "wasm-timer", -] - -[[package]] -name = "reqwest-tracing" -version = "0.5.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d70ea85f131b2ee9874f0b160ac5976f8af75f3c9badfe0d955880257d10bd83" -dependencies = [ - "anyhow", - "async-trait", - "getrandom 0.2.16", - "http 1.3.1", - "matchit", - "reqwest", - "reqwest-middleware", - "tracing", -] - [[package]] name = "resolv-conf" version = "0.7.5" @@ -4370,15 +4154,6 @@ dependencies = [ "serror", ] -[[package]] -name = "retry-policies" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5875471e6cab2871bc150ecb8c727db5113c9338cc3354dc5ee3425b6aa40a1c" -dependencies = [ - "rand 0.8.5", -] - [[package]] name = "rfc6979" version = "0.4.0" @@ -4599,22 +4374,6 @@ dependencies = [ "windows-sys 0.61.1", ] -[[package]] -name = "schemars" -version = "0.8.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fbf2ae1b8bc8e02df939598064d22402220cd5bbcca1c76f7d6a310974d5615" -dependencies = [ - "bytes", - "chrono", - "dyn-clone", - "schemars_derive", - "serde", - "serde_json", - "url", - "uuid", -] - [[package]] name = "schemars" version = "0.9.0" @@ -4639,18 +4398,6 @@ dependencies = [ "serde_json", ] -[[package]] -name = "schemars_derive" -version = "0.8.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32e265784ad618884abaea0600a9adf15393368d840e0222d101a072f3f7534d" -dependencies = [ - "proc-macro2", - "quote", - "serde_derive_internals", - "syn", -] - [[package]] name = "scopeguard" version = "1.2.0" @@ -4780,17 +4527,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_derive_internals" -version = "0.29.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "serde_json" version = "1.0.145" @@ -4849,9 +4585,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5417783452c2be558477e104686f7de5dae53dba813c28435e0e70f82d9b04ee" +checksum = "e24345aa0fe688594e73770a5f6d1b216508b4f93484c0026d521acd30134392" dependencies = [ "serde_core", ] @@ -5013,18 +4749,6 @@ dependencies = [ "rand_core 0.6.4", ] -[[package]] -name = "simple_asn1" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297f631f50729c8c99b84667867963997ec0b50f32b2a7dbcab828ef0541e8bb" -dependencies = [ - "num-bigint", - "num-traits", - "thiserror 2.0.17", - "time", -] - [[package]] name = "siphasher" version = "1.0.1" @@ -5373,7 +5097,7 @@ dependencies = [ "io-uring", "libc", "mio", - "parking_lot 0.12.5", + "parking_lot", "pin-project-lite", "signal-hook-registry", "slab", @@ -5457,9 +5181,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00e5e5d9bf2475ac9d4f0d9edab68cc573dc2fd644b0dba36b0c30a92dd9eaa0" +checksum = "f0dc8b1fb61449e27716ec0e1bdf0f6b8f3e8f6b05391e8497b8b6d7804ea6d8" dependencies = [ "indexmap 2.11.4", "serde_core", @@ -5472,18 +5196,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32f1085dec27c2b6632b04c80b3bb1b4300d6495d1e129693bdda7d91e72eec1" +checksum = "f2cdb639ebbc97961c51720f858597f7f24c4fc295327923af55b74c3c724533" dependencies = [ "serde_core", ] [[package]] name = "toml_parser" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cf893c33be71572e0e9aa6dd15e6677937abd686b066eac3f8cd3531688a627" +checksum = "c0cbe268d35bdb4bb5a56a2de88d0ad0eb70af5384a99d648cd4b3d04039800e" dependencies = [ "winnow", ] @@ -5502,9 +5226,9 @@ dependencies = [ [[package]] name = "toml_writer" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d163a63c116ce562a22cda521fcc4d79152e7aba014456fb5eb442f6d6a10109" +checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2" [[package]] name = "tonic" @@ -5916,12 +5640,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" -[[package]] -name = "version_check" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" - [[package]] name = "version_check" version = "0.9.5" @@ -6052,21 +5770,6 @@ dependencies = [ "web-sys", ] -[[package]] -name = "wasm-timer" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be0ecb0db480561e9a7642b5d3e4187c128914e58aa84330b9493e3eb68c5e7f" -dependencies = [ - "futures", - "js-sys", - "parking_lot 0.11.2", - "pin-utils", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", -] - [[package]] name = "web-sys" version = "0.3.81" diff --git a/Cargo.toml b/Cargo.toml index 7eb238e24..c5e42f220 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -79,7 +79,7 @@ bson = { version = "2.15.0" } # must keep in sync with mongodb version serde_yaml_ng = "0.10.0" serde_json = "1.0.145" serde_qs = "0.15.0" -toml = "0.9.7" +toml = "0.9.8" url = "2.5.7" # ERROR @@ -107,7 +107,6 @@ rustls = { version = "0.23.32", features = ["aws-lc-rs"] } pem-rfc7468 = { version = "0.7.0", features = ["alloc"] } openidconnect = "4.0.1" urlencoding = "2.1.3" -nom_pem = "4.0.0" bcrypt = "0.17.1" base64 = "0.22.1" pkcs8 = "0.10.2" @@ -126,9 +125,9 @@ bollard = "0.19.3" sysinfo = "0.37.1" # CLOUD -aws-config = "1.8.6" -aws-sdk-ec2 = "1.170.1" -aws-credential-types = "1.2.6" +aws-config = "1.8.8" +aws-sdk-ec2 = "1.172.0" +aws-credential-types = "1.2.8" ## CRON english-to-cron = "0.1.6" @@ -142,7 +141,6 @@ derive_builder = "0.20.2" shell-escape = "0.1.5" comfy-table = "7.2.1" typeshare = "1.0.4" -octorust = "0.10.0" dashmap = "6.1.0" wildcard = "0.3.0" colored = "3.0.0" diff --git a/bin/core/Cargo.toml b/bin/core/Cargo.toml index 4fb096671..aedb09e28 100644 --- a/bin/core/Cargo.toml +++ b/bin/core/Cargo.toml @@ -57,7 +57,6 @@ serde_yaml_ng.workspace = true typeshare.workspace = true chrono-tz.workspace = true indexmap.workspace = true -octorust.workspace = true wildcard.workspace = true arc-swap.workspace = true colored.workspace = true @@ -65,7 +64,6 @@ dashmap.workspace = true tracing.workspace = true reqwest.workspace = true futures.workspace = true -nom_pem.workspace = true dotenvy.workspace = true anyhow.workspace = true croner.workspace = true diff --git a/bin/core/src/api/read/build.rs b/bin/core/src/api/read/build.rs index 1082847b7..3080330cf 100644 --- a/bin/core/src/api/read/build.rs +++ b/bin/core/src/api/read/build.rs @@ -12,7 +12,6 @@ use komodo_client::{ entities::{ Operation, build::{Build, BuildActionState, BuildListItem, BuildState}, - config::core::CoreConfig, permission::PermissionLevel, update::UpdateStatus, }, @@ -20,13 +19,10 @@ use komodo_client::{ use resolver_api::Resolve; use crate::{ - config::core_config, helpers::query::get_all_tags, permission::get_check_permissions, resource, - state::{ - action_states, build_state_cache, db_client, github_client, - }, + state::{action_states, build_state_cache, db_client}, }; use super::ReadArgs; @@ -306,81 +302,3 @@ impl Resolve for ListCommonBuildExtraArgs { Ok(res) } } - -impl Resolve for GetBuildWebhookEnabled { - async fn resolve( - self, - ReadArgs { user }: &ReadArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Ok(GetBuildWebhookEnabledResponse { - managed: false, - enabled: false, - }); - }; - - let build = get_check_permissions::( - &self.build, - user, - PermissionLevel::Read.into(), - ) - .await?; - - if build.config.git_provider != "github.com" - || build.config.repo.is_empty() - { - return Ok(GetBuildWebhookEnabledResponse { - managed: false, - enabled: false, - }); - } - - let mut split = build.config.repo.split('/'); - let owner = split.next().context("Build repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Ok(GetBuildWebhookEnabledResponse { - managed: false, - enabled: false, - }); - }; - - let repo = - split.next().context("Build repo has no repo after the /")?; - - let github_repos = github.repos(); - - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = format!("{host}/listener/github/build/{}", build.id); - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - return Ok(GetBuildWebhookEnabledResponse { - managed: true, - enabled: true, - }); - } - } - - Ok(GetBuildWebhookEnabledResponse { - managed: true, - enabled: false, - }) - } -} diff --git a/bin/core/src/api/read/mod.rs b/bin/core/src/api/read/mod.rs index 677fd0135..992b82030 100644 --- a/bin/core/src/api/read/mod.rs +++ b/bin/core/src/api/read/mod.rs @@ -142,7 +142,6 @@ enum ReadRequest { GetStacksSummary(GetStacksSummary), GetStack(GetStack), GetStackActionState(GetStackActionState), - GetStackWebhooksEnabled(GetStackWebhooksEnabled), GetStackLog(GetStackLog), SearchStackLog(SearchStackLog), InspectStackContainer(InspectStackContainer), @@ -171,7 +170,6 @@ enum ReadRequest { GetBuildActionState(GetBuildActionState), GetBuildMonthlyStats(GetBuildMonthlyStats), ListBuildVersions(ListBuildVersions), - GetBuildWebhookEnabled(GetBuildWebhookEnabled), ListBuilds(ListBuilds), ListFullBuilds(ListFullBuilds), ListCommonBuildExtraArgs(ListCommonBuildExtraArgs), @@ -180,7 +178,6 @@ enum ReadRequest { GetReposSummary(GetReposSummary), GetRepo(GetRepo), GetRepoActionState(GetRepoActionState), - GetRepoWebhooksEnabled(GetRepoWebhooksEnabled), ListRepos(ListRepos), ListFullRepos(ListFullRepos), @@ -188,7 +185,6 @@ enum ReadRequest { GetResourceSyncsSummary(GetResourceSyncsSummary), GetResourceSync(GetResourceSync), GetResourceSyncActionState(GetResourceSyncActionState), - GetSyncWebhooksEnabled(GetSyncWebhooksEnabled), ListResourceSyncs(ListResourceSyncs), ListFullResourceSyncs(ListFullResourceSyncs), @@ -301,12 +297,6 @@ impl Resolve for GetCoreInfo { disable_non_admin_create: config.disable_non_admin_create, disable_websocket_reconnect: config.disable_websocket_reconnect, enable_fancy_toml: config.enable_fancy_toml, - github_webhook_owners: config - .github_webhook_app - .installations - .iter() - .map(|i| i.namespace.to_string()) - .collect(), timezone: config.timezone.clone(), public_key: core_keys().load().public.to_string(), }; diff --git a/bin/core/src/api/read/repo.rs b/bin/core/src/api/read/repo.rs index e1f670870..db0936681 100644 --- a/bin/core/src/api/read/repo.rs +++ b/bin/core/src/api/read/repo.rs @@ -2,7 +2,6 @@ use anyhow::Context; use komodo_client::{ api::read::*, entities::{ - config::core::CoreConfig, permission::PermissionLevel, repo::{Repo, RepoActionState, RepoListItem, RepoState}, }, @@ -10,11 +9,10 @@ use komodo_client::{ use resolver_api::Resolve; use crate::{ - config::core_config, helpers::query::get_all_tags, permission::get_check_permissions, resource, - state::{action_states, github_client, repo_state_cache}, + state::{action_states, repo_state_cache}, }; use super::ReadArgs; @@ -159,104 +157,3 @@ impl Resolve for GetReposSummary { Ok(res) } } - -impl Resolve for GetRepoWebhooksEnabled { - async fn resolve( - self, - ReadArgs { user }: &ReadArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Ok(GetRepoWebhooksEnabledResponse { - managed: false, - clone_enabled: false, - pull_enabled: false, - build_enabled: false, - }); - }; - - let repo = get_check_permissions::( - &self.repo, - user, - PermissionLevel::Read.into(), - ) - .await?; - - if repo.config.git_provider != "github.com" - || repo.config.repo.is_empty() - { - return Ok(GetRepoWebhooksEnabledResponse { - managed: false, - clone_enabled: false, - pull_enabled: false, - build_enabled: false, - }); - } - - let mut split = repo.config.repo.split('/'); - let owner = split.next().context("Repo repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Ok(GetRepoWebhooksEnabledResponse { - managed: false, - clone_enabled: false, - pull_enabled: false, - build_enabled: false, - }); - }; - - let repo_name = - split.next().context("Repo repo has no repo after the /")?; - - let github_repos = github.repos(); - - let webhooks = github_repos - .list_all_webhooks(owner, repo_name) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let clone_url = - format!("{host}/listener/github/repo/{}/clone", repo.id); - let pull_url = - format!("{host}/listener/github/repo/{}/pull", repo.id); - let build_url = - format!("{host}/listener/github/repo/{}/build", repo.id); - - let mut clone_enabled = false; - let mut pull_enabled = false; - let mut build_enabled = false; - - for webhook in webhooks { - if !webhook.active { - continue; - } - if webhook.config.url == clone_url { - clone_enabled = true - } - if webhook.config.url == pull_url { - pull_enabled = true - } - if webhook.config.url == build_url { - build_enabled = true - } - } - - Ok(GetRepoWebhooksEnabledResponse { - managed: true, - clone_enabled, - pull_enabled, - build_enabled, - }) - } -} diff --git a/bin/core/src/api/read/stack.rs b/bin/core/src/api/read/stack.rs index 6f8bbc581..1ee10515e 100644 --- a/bin/core/src/api/read/stack.rs +++ b/bin/core/src/api/read/stack.rs @@ -4,7 +4,6 @@ use anyhow::{Context, anyhow}; use komodo_client::{ api::read::*, entities::{ - config::core::CoreConfig, docker::container::Container, permission::PermissionLevel, server::{Server, ServerState}, @@ -18,15 +17,11 @@ use periphery_client::api::{ use resolver_api::Resolve; use crate::{ - config::core_config, helpers::{periphery_client, query::get_all_tags}, permission::get_check_permissions, resource, stack::get_stack_and_server, - state::{ - action_states, github_client, server_status_cache, - stack_status_cache, - }, + state::{action_states, server_status_cache, stack_status_cache}, }; use super::ReadArgs; @@ -378,91 +373,3 @@ impl Resolve for GetStacksSummary { Ok(res) } } - -impl Resolve for GetStackWebhooksEnabled { - async fn resolve( - self, - ReadArgs { user }: &ReadArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Ok(GetStackWebhooksEnabledResponse { - managed: false, - refresh_enabled: false, - deploy_enabled: false, - }); - }; - - let stack = get_check_permissions::( - &self.stack, - user, - PermissionLevel::Read.into(), - ) - .await?; - - if stack.config.git_provider != "github.com" - || stack.config.repo.is_empty() - { - return Ok(GetStackWebhooksEnabledResponse { - managed: false, - refresh_enabled: false, - deploy_enabled: false, - }); - } - - let mut split = stack.config.repo.split('/'); - let owner = split.next().context("Sync repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Ok(GetStackWebhooksEnabledResponse { - managed: false, - refresh_enabled: false, - deploy_enabled: false, - }); - }; - - let repo_name = - split.next().context("Repo repo has no repo after the /")?; - - let github_repos = github.repos(); - - let webhooks = github_repos - .list_all_webhooks(owner, repo_name) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let refresh_url = - format!("{host}/listener/github/stack/{}/refresh", stack.id); - let deploy_url = - format!("{host}/listener/github/stack/{}/deploy", stack.id); - - let mut refresh_enabled = false; - let mut deploy_enabled = false; - - for webhook in webhooks { - if webhook.active && webhook.config.url == refresh_url { - refresh_enabled = true - } - if webhook.active && webhook.config.url == deploy_url { - deploy_enabled = true - } - } - - Ok(GetStackWebhooksEnabledResponse { - managed: true, - refresh_enabled, - deploy_enabled, - }) - } -} diff --git a/bin/core/src/api/read/sync.rs b/bin/core/src/api/read/sync.rs index 1e0fec6c7..78e297a82 100644 --- a/bin/core/src/api/read/sync.rs +++ b/bin/core/src/api/read/sync.rs @@ -2,7 +2,6 @@ use anyhow::Context; use komodo_client::{ api::read::*, entities::{ - config::core::CoreConfig, permission::PermissionLevel, sync::{ ResourceSync, ResourceSyncActionState, ResourceSyncListItem, @@ -12,11 +11,8 @@ use komodo_client::{ use resolver_api::Resolve; use crate::{ - config::core_config, - helpers::query::get_all_tags, - permission::get_check_permissions, - resource, - state::{action_states, github_client}, + helpers::query::get_all_tags, permission::get_check_permissions, + resource, state::action_states, }; use super::ReadArgs; @@ -154,91 +150,3 @@ impl Resolve for GetResourceSyncsSummary { Ok(res) } } - -impl Resolve for GetSyncWebhooksEnabled { - async fn resolve( - self, - ReadArgs { user }: &ReadArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Ok(GetSyncWebhooksEnabledResponse { - managed: false, - refresh_enabled: false, - sync_enabled: false, - }); - }; - - let sync = get_check_permissions::( - &self.sync, - user, - PermissionLevel::Read.into(), - ) - .await?; - - if sync.config.git_provider != "github.com" - || sync.config.repo.is_empty() - { - return Ok(GetSyncWebhooksEnabledResponse { - managed: false, - refresh_enabled: false, - sync_enabled: false, - }); - } - - let mut split = sync.config.repo.split('/'); - let owner = split.next().context("Sync repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Ok(GetSyncWebhooksEnabledResponse { - managed: false, - refresh_enabled: false, - sync_enabled: false, - }); - }; - - let repo_name = - split.next().context("Repo repo has no repo after the /")?; - - let github_repos = github.repos(); - - let webhooks = github_repos - .list_all_webhooks(owner, repo_name) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let refresh_url = - format!("{host}/listener/github/sync/{}/refresh", sync.id); - let sync_url = - format!("{host}/listener/github/sync/{}/sync", sync.id); - - let mut refresh_enabled = false; - let mut sync_enabled = false; - - for webhook in webhooks { - if webhook.active && webhook.config.url == refresh_url { - refresh_enabled = true - } - if webhook.active && webhook.config.url == sync_url { - sync_enabled = true - } - } - - Ok(GetSyncWebhooksEnabledResponse { - managed: true, - refresh_enabled, - sync_enabled, - }) - } -} diff --git a/bin/core/src/api/write/build.rs b/bin/core/src/api/write/build.rs index 063914efc..ac86a0a6f 100644 --- a/bin/core/src/api/write/build.rs +++ b/bin/core/src/api/write/build.rs @@ -11,18 +11,14 @@ use komodo_client::{ entities::{ FileContents, NoData, Operation, RepoExecutionArgs, all_logs_success, - build::{Build, BuildInfo, PartialBuildConfig}, + build::{Build, BuildInfo}, builder::{Builder, BuilderConfig}, - config::core::CoreConfig, permission::PermissionLevel, repo::Repo, server::ServerState, update::Update, }, }; -use octorust::types::{ - ReposCreateWebhookRequest, ReposCreateWebhookRequestConfig, -}; use periphery_client::api::build::{ GetDockerfileContentsOnHost, WriteDockerfileContentsToHost, }; @@ -40,7 +36,7 @@ use crate::{ periphery::PeripheryClient, permission::get_check_permissions, resource, - state::{db_client, github_client}, + state::db_client, }; use super::WriteArgs; @@ -546,201 +542,3 @@ async fn get_git_remote( res.commit_message, ))) } - -impl Resolve for CreateBuildWebhook { - #[instrument(name = "CreateBuildWebhook", skip(args))] - async fn resolve( - self, - args: &WriteArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let WriteArgs { user } = args; - - let build = get_check_permissions::( - &self.build, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if build.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = build.config.repo.split('/'); - let owner = split.next().context("Build repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo = - split.next().context("Build repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - webhook_secret, - .. - } = core_config(); - - let webhook_secret = if build.config.webhook_secret.is_empty() { - webhook_secret - } else { - &build.config.webhook_secret - }; - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = format!("{host}/listener/github/build/{}", build.id); - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - return Ok(NoData {}); - } - } - - // Now good to create the webhook - let request = ReposCreateWebhookRequest { - active: Some(true), - config: Some(ReposCreateWebhookRequestConfig { - url, - secret: webhook_secret.to_string(), - content_type: String::from("json"), - insecure_ssl: None, - digest: Default::default(), - token: Default::default(), - }), - events: vec![String::from("push")], - name: String::from("web"), - }; - github_repos - .create_webhook(owner, repo, &request) - .await - .context("failed to create webhook")?; - - if !build.config.webhook_enabled { - UpdateBuild { - id: build.id, - config: PartialBuildConfig { - webhook_enabled: Some(true), - ..Default::default() - }, - } - .resolve(args) - .await - .map_err(|e| e.error) - .context("failed to update build to enable webhook")?; - } - - Ok(NoData {}) - } -} - -impl Resolve for DeleteBuildWebhook { - #[instrument(name = "DeleteBuildWebhook", skip(user))] - async fn resolve( - self, - WriteArgs { user }: &WriteArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let build = get_check_permissions::( - &self.build, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if build.config.git_provider != "github.com" { - return Err( - anyhow!("Can only manage github.com repo webhooks").into(), - ); - } - - if build.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't delete webhook").into(), - ); - } - - let mut split = build.config.repo.split('/'); - let owner = split.next().context("Build repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo = - split.next().context("Build repo has no repo after the /")?; - - let github_repos = github.repos(); - - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = format!("{host}/listener/github/build/{}", build.id); - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - github_repos - .delete_webhook(owner, repo, webhook.id) - .await - .context("failed to delete webhook")?; - return Ok(NoData {}); - } - } - - // No webhook to delete, all good - Ok(NoData {}) - } -} diff --git a/bin/core/src/api/write/mod.rs b/bin/core/src/api/write/mod.rs index fd5e24cd6..828de2d95 100644 --- a/bin/core/src/api/write/mod.rs +++ b/bin/core/src/api/write/mod.rs @@ -104,8 +104,6 @@ pub enum WriteRequest { RenameStack(RenameStack), WriteStackFileContents(WriteStackFileContents), RefreshStackCache(RefreshStackCache), - CreateStackWebhook(CreateStackWebhook), - DeleteStackWebhook(DeleteStackWebhook), // ==== DEPLOYMENT ==== CreateDeployment(CreateDeployment), @@ -123,8 +121,6 @@ pub enum WriteRequest { RenameBuild(RenameBuild), WriteBuildFileContents(WriteBuildFileContents), RefreshBuildCache(RefreshBuildCache), - CreateBuildWebhook(CreateBuildWebhook), - DeleteBuildWebhook(DeleteBuildWebhook), // ==== BUILDER ==== CreateBuilder(CreateBuilder), @@ -140,8 +136,6 @@ pub enum WriteRequest { UpdateRepo(UpdateRepo), RenameRepo(RenameRepo), RefreshRepoCache(RefreshRepoCache), - CreateRepoWebhook(CreateRepoWebhook), - DeleteRepoWebhook(DeleteRepoWebhook), // ==== ALERTER ==== CreateAlerter(CreateAlerter), @@ -173,8 +167,6 @@ pub enum WriteRequest { WriteSyncFileContents(WriteSyncFileContents), CommitSync(CommitSync), RefreshResourceSyncPending(RefreshResourceSyncPending), - CreateSyncWebhook(CreateSyncWebhook), - DeleteSyncWebhook(DeleteSyncWebhook), // ==== TAG ==== CreateTag(CreateTag), diff --git a/bin/core/src/api/write/repo.rs b/bin/core/src/api/write/repo.rs index 627f37760..c517e553b 100644 --- a/bin/core/src/api/write/repo.rs +++ b/bin/core/src/api/write/repo.rs @@ -1,4 +1,4 @@ -use anyhow::{Context, anyhow}; +use anyhow::Context; use database::mongo_indexed::doc; use database::mungos::{ by_id::update_one_by_id, mongodb::bson::to_document, @@ -7,19 +7,14 @@ use formatting::format_serror; use komodo_client::{ api::write::*, entities::{ - NoData, Operation, RepoExecutionArgs, - config::core::CoreConfig, - komodo_timestamp, + NoData, Operation, RepoExecutionArgs, komodo_timestamp, permission::PermissionLevel, - repo::{PartialRepoConfig, Repo, RepoInfo}, + repo::{Repo, RepoInfo}, server::Server, to_path_compatible_name, update::{Log, Update}, }, }; -use octorust::types::{ - ReposCreateWebhookRequest, ReposCreateWebhookRequestConfig, -}; use periphery_client::api; use resolver_api::Resolve; @@ -31,7 +26,7 @@ use crate::{ }, permission::get_check_permissions, resource, - state::{action_states, db_client, github_client}, + state::{action_states, db_client}, }; use super::WriteArgs; @@ -235,220 +230,3 @@ impl Resolve for RefreshRepoCache { Ok(NoData {}) } } - -impl Resolve for CreateRepoWebhook { - #[instrument(name = "CreateRepoWebhook", skip(args))] - async fn resolve( - self, - args: &WriteArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let repo = get_check_permissions::( - &self.repo, - &args.user, - PermissionLevel::Write.into(), - ) - .await?; - - if repo.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = repo.config.repo.split('/'); - let owner = split.next().context("Repo repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo_name = - split.next().context("Repo repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo_name) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - webhook_secret, - .. - } = core_config(); - - let webhook_secret = if repo.config.webhook_secret.is_empty() { - webhook_secret - } else { - &repo.config.webhook_secret - }; - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = match self.action { - RepoWebhookAction::Clone => { - format!("{host}/listener/github/repo/{}/clone", repo.id) - } - RepoWebhookAction::Pull => { - format!("{host}/listener/github/repo/{}/pull", repo.id) - } - RepoWebhookAction::Build => { - format!("{host}/listener/github/repo/{}/build", repo.id) - } - }; - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - return Ok(NoData {}); - } - } - - // Now good to create the webhook - let request = ReposCreateWebhookRequest { - active: Some(true), - config: Some(ReposCreateWebhookRequestConfig { - url, - secret: webhook_secret.to_string(), - content_type: String::from("json"), - insecure_ssl: None, - digest: Default::default(), - token: Default::default(), - }), - events: vec![String::from("push")], - name: String::from("web"), - }; - github_repos - .create_webhook(owner, repo_name, &request) - .await - .context("failed to create webhook")?; - - if !repo.config.webhook_enabled { - UpdateRepo { - id: repo.id, - config: PartialRepoConfig { - webhook_enabled: Some(true), - ..Default::default() - }, - } - .resolve(args) - .await - .map_err(|e| e.error) - .context("failed to update repo to enable webhook")?; - } - - Ok(NoData {}) - } -} - -impl Resolve for DeleteRepoWebhook { - #[instrument(name = "DeleteRepoWebhook", skip(user))] - async fn resolve( - self, - WriteArgs { user }: &WriteArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let repo = get_check_permissions::( - &self.repo, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if repo.config.git_provider != "github.com" { - return Err( - anyhow!("Can only manage github.com repo webhooks").into(), - ); - } - - if repo.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = repo.config.repo.split('/'); - let owner = split.next().context("Repo repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo_name = - split.next().context("Repo repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo_name) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = match self.action { - RepoWebhookAction::Clone => { - format!("{host}/listener/github/repo/{}/clone", repo.id) - } - RepoWebhookAction::Pull => { - format!("{host}/listener/github/repo/{}/pull", repo.id) - } - RepoWebhookAction::Build => { - format!("{host}/listener/github/repo/{}/build", repo.id) - } - }; - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - github_repos - .delete_webhook(owner, repo_name, webhook.id) - .await - .context("failed to delete webhook")?; - return Ok(NoData {}); - } - } - - // No webhook to delete, all good - Ok(NoData {}) - } -} diff --git a/bin/core/src/api/write/stack.rs b/bin/core/src/api/write/stack.rs index b3dedcfec..9cf72a477 100644 --- a/bin/core/src/api/write/stack.rs +++ b/bin/core/src/api/write/stack.rs @@ -8,18 +8,14 @@ use komodo_client::{ entities::{ FileContents, NoData, Operation, RepoExecutionArgs, all_logs_success, - config::core::CoreConfig, permission::PermissionLevel, repo::Repo, server::ServerState, - stack::{PartialStackConfig, Stack, StackInfo}, + stack::{Stack, StackInfo}, update::Update, user::stack_user, }, }; -use octorust::types::{ - ReposCreateWebhookRequest, ReposCreateWebhookRequestConfig, -}; use periphery_client::api::compose::{ GetComposeContentsOnHost, GetComposeContentsOnHostResponse, WriteComposeContentsToHost, @@ -40,7 +36,7 @@ use crate::{ remote::{RemoteComposeContents, get_repo_compose_contents}, services::extract_services_into_res, }, - state::{db_client, github_client}, + state::db_client, }; use super::WriteArgs; @@ -567,216 +563,3 @@ impl Resolve for RefreshStackCache { Ok(NoData {}) } } - -impl Resolve for CreateStackWebhook { - #[instrument(name = "CreateStackWebhook", skip(args))] - async fn resolve( - self, - args: &WriteArgs, - ) -> serror::Result { - let WriteArgs { user } = args; - - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let stack = get_check_permissions::( - &self.stack, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if stack.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = stack.config.repo.split('/'); - let owner = split.next().context("Stack repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo = - split.next().context("Stack repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - webhook_secret, - .. - } = core_config(); - - let webhook_secret = if stack.config.webhook_secret.is_empty() { - webhook_secret - } else { - &stack.config.webhook_secret - }; - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = match self.action { - StackWebhookAction::Refresh => { - format!("{host}/listener/github/stack/{}/refresh", stack.id) - } - StackWebhookAction::Deploy => { - format!("{host}/listener/github/stack/{}/deploy", stack.id) - } - }; - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - return Ok(NoData {}); - } - } - - // Now good to create the webhook - let request = ReposCreateWebhookRequest { - active: Some(true), - config: Some(ReposCreateWebhookRequestConfig { - url, - secret: webhook_secret.to_string(), - content_type: String::from("json"), - insecure_ssl: None, - digest: Default::default(), - token: Default::default(), - }), - events: vec![String::from("push")], - name: String::from("web"), - }; - github_repos - .create_webhook(owner, repo, &request) - .await - .context("failed to create webhook")?; - - if !stack.config.webhook_enabled { - UpdateStack { - id: stack.id, - config: PartialStackConfig { - webhook_enabled: Some(true), - ..Default::default() - }, - } - .resolve(args) - .await - .map_err(|e| e.error) - .context("failed to update stack to enable webhook")?; - } - - Ok(NoData {}) - } -} - -impl Resolve for DeleteStackWebhook { - #[instrument(name = "DeleteStackWebhook", skip(user))] - async fn resolve( - self, - WriteArgs { user }: &WriteArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let stack = get_check_permissions::( - &self.stack, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if stack.config.git_provider != "github.com" { - return Err( - anyhow!("Can only manage github.com repo webhooks").into(), - ); - } - - if stack.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = stack.config.repo.split('/'); - let owner = split.next().context("Stack repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo = - split.next().context("Sync repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = match self.action { - StackWebhookAction::Refresh => { - format!("{host}/listener/github/stack/{}/refresh", stack.id) - } - StackWebhookAction::Deploy => { - format!("{host}/listener/github/stack/{}/deploy", stack.id) - } - }; - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - github_repos - .delete_webhook(owner, repo, webhook.id) - .await - .context("failed to delete webhook")?; - return Ok(NoData {}); - } - } - - // No webhook to delete, all good - Ok(NoData {}) - } -} diff --git a/bin/core/src/api/write/sync.rs b/bin/core/src/api/write/sync.rs index f3603c44c..dd45b4e49 100644 --- a/bin/core/src/api/write/sync.rs +++ b/bin/core/src/api/write/sync.rs @@ -12,14 +12,13 @@ use formatting::format_serror; use komodo_client::{ api::{read::ExportAllResourcesToToml, write::*}, entities::{ - self, NoData, Operation, RepoExecutionArgs, ResourceTarget, + self, Operation, RepoExecutionArgs, ResourceTarget, action::Action, alert::{Alert, AlertData, SeverityLevel}, alerter::Alerter, all_logs_success, build::Build, builder::Builder, - config::core::CoreConfig, deployment::Deployment, komodo_timestamp, permission::PermissionLevel, @@ -27,18 +26,12 @@ use komodo_client::{ repo::Repo, server::Server, stack::Stack, - sync::{ - PartialResourceSyncConfig, ResourceSync, ResourceSyncInfo, - SyncDeployUpdate, - }, + sync::{ResourceSync, ResourceSyncInfo, SyncDeployUpdate}, to_path_compatible_name, update::{Log, Update}, user::sync_user, }, }; -use octorust::types::{ - ReposCreateWebhookRequest, ReposCreateWebhookRequestConfig, -}; use resolver_api::Resolve; use crate::{ @@ -53,7 +46,7 @@ use crate::{ }, permission::get_check_permissions, resource, - state::{db_client, github_client}, + state::db_client, sync::{ deploy::SyncDeployParams, remote::RemoteResources, view::push_updates_for_view, @@ -969,215 +962,3 @@ impl Resolve for RefreshResourceSyncPending { Ok(crate::resource::get::(&sync.id).await?) } } - -impl Resolve for CreateSyncWebhook { - #[instrument(name = "CreateSyncWebhook", skip(args))] - async fn resolve( - self, - args: &WriteArgs, - ) -> serror::Result { - let WriteArgs { user } = args; - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let sync = get_check_permissions::( - &self.sync, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if sync.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = sync.config.repo.split('/'); - let owner = split.next().context("Sync repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo = - split.next().context("Repo repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - webhook_secret, - .. - } = core_config(); - - let webhook_secret = if sync.config.webhook_secret.is_empty() { - webhook_secret - } else { - &sync.config.webhook_secret - }; - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = match self.action { - SyncWebhookAction::Refresh => { - format!("{host}/listener/github/sync/{}/refresh", sync.id) - } - SyncWebhookAction::Sync => { - format!("{host}/listener/github/sync/{}/sync", sync.id) - } - }; - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - return Ok(NoData {}); - } - } - - // Now good to create the webhook - let request = ReposCreateWebhookRequest { - active: Some(true), - config: Some(ReposCreateWebhookRequestConfig { - url, - secret: webhook_secret.to_string(), - content_type: String::from("json"), - insecure_ssl: None, - digest: Default::default(), - token: Default::default(), - }), - events: vec![String::from("push")], - name: String::from("web"), - }; - github_repos - .create_webhook(owner, repo, &request) - .await - .context("failed to create webhook")?; - - if !sync.config.webhook_enabled { - UpdateResourceSync { - id: sync.id, - config: PartialResourceSyncConfig { - webhook_enabled: Some(true), - ..Default::default() - }, - } - .resolve(args) - .await - .map_err(|e| e.error) - .context("failed to update sync to enable webhook")?; - } - - Ok(NoData {}) - } -} - -impl Resolve for DeleteSyncWebhook { - #[instrument(name = "DeleteSyncWebhook", skip(user))] - async fn resolve( - self, - WriteArgs { user }: &WriteArgs, - ) -> serror::Result { - let Some(github) = github_client() else { - return Err( - anyhow!( - "github_webhook_app is not configured in core config toml" - ) - .into(), - ); - }; - - let sync = get_check_permissions::( - &self.sync, - user, - PermissionLevel::Write.into(), - ) - .await?; - - if sync.config.git_provider != "github.com" { - return Err( - anyhow!("Can only manage github.com repo webhooks").into(), - ); - } - - if sync.config.repo.is_empty() { - return Err( - anyhow!("No repo configured, can't create webhook").into(), - ); - } - - let mut split = sync.config.repo.split('/'); - let owner = split.next().context("Sync repo has no owner")?; - - let Some(github) = github.get(owner) else { - return Err( - anyhow!("Cannot manage repo webhooks under owner {owner}") - .into(), - ); - }; - - let repo = - split.next().context("Sync repo has no repo after the /")?; - - let github_repos = github.repos(); - - // First make sure the webhook isn't already created (inactive ones are ignored) - let webhooks = github_repos - .list_all_webhooks(owner, repo) - .await - .context("failed to list all webhooks on repo")? - .body; - - let CoreConfig { - host, - webhook_base_url, - .. - } = core_config(); - - let host = if webhook_base_url.is_empty() { - host - } else { - webhook_base_url - }; - let url = match self.action { - SyncWebhookAction::Refresh => { - format!("{host}/listener/github/sync/{}/refresh", sync.id) - } - SyncWebhookAction::Sync => { - format!("{host}/listener/github/sync/{}/sync", sync.id) - } - }; - - for webhook in webhooks { - if webhook.active && webhook.config.url == url { - github_repos - .delete_webhook(owner, repo, webhook.id) - .await - .context("failed to delete webhook")?; - return Ok(NoData {}); - } - } - - // No webhook to delete, all good - Ok(NoData {}) - } -} diff --git a/bin/core/src/config.rs b/bin/core/src/config.rs index ab6f26afb..70ff0888b 100644 --- a/bin/core/src/config.rs +++ b/bin/core/src/config.rs @@ -9,10 +9,7 @@ use environment_file::{ use komodo_client::entities::{ config::{ DatabaseConfig, - core::{ - AwsCredentials, CoreConfig, Env, GithubWebhookAppConfig, - GithubWebhookAppInstallationConfig, OauthCredentials, - }, + core::{AwsCredentials, CoreConfig, Env, OauthCredentials}, }, logger::LogConfig, }; @@ -96,12 +93,13 @@ pub fn core_config() -> &'static CoreConfig { static CORE_CONFIG: OnceLock = OnceLock::new(); CORE_CONFIG.get_or_init(|| { let env: Env = match envy::from_env() - .context("Failed to parse Komodo Core environment") { - Ok(env) => env, - Err(e) => { - panic!("{e:?}"); - } - }; + .context("Failed to parse Komodo Core environment") + { + Ok(env) => env, + Err(e) => { + panic!("{e:?}"); + } + }; let config = if env.komodo_config_paths.is_empty() { println!( "{}: No config paths found, using default config", @@ -109,7 +107,8 @@ pub fn core_config() -> &'static CoreConfig { ); CoreConfig::default() } else { - let config_keywords = env.komodo_config_keywords + let config_keywords = env + .komodo_config_keywords .iter() .map(String::as_str) .collect::>(); @@ -119,7 +118,8 @@ pub fn core_config() -> &'static CoreConfig { "Config File Keywords".dimmed(), ); (ConfigLoader { - paths: &env.komodo_config_paths + paths: &env + .komodo_config_paths .iter() .map(PathBuf::as_path) .collect::>(), @@ -128,57 +128,53 @@ pub fn core_config() -> &'static CoreConfig { merge_nested: env.komodo_merge_nested_config, extend_array: env.komodo_extend_config_arrays, debug_print: env.komodo_config_debug, - }).load::() + }) + .load::() .expect("Failed at parsing config from paths") }; - let installations = match ( - maybe_read_list_from_file( - env.komodo_github_webhook_app_installations_ids_file, - env.komodo_github_webhook_app_installations_ids - ), - env.komodo_github_webhook_app_installations_namespaces - ) { - (Some(ids), Some(namespaces)) => { - if ids.len() != namespaces.len() { - panic!("KOMODO_GITHUB_WEBHOOK_APP_INSTALLATIONS_IDS length and KOMODO_GITHUB_WEBHOOK_APP_INSTALLATIONS_NAMESPACES length mismatch. Got {ids:?} and {namespaces:?}") - } - ids - .into_iter() - .zip(namespaces) - .map(|(id, namespace)| GithubWebhookAppInstallationConfig { - id, - namespace - }) - .collect() - }, - (Some(_), None) | (None, Some(_)) => { - panic!("Got only one of KOMODO_GITHUB_WEBHOOK_APP_INSTALLATIONS_IDS or KOMODO_GITHUB_WEBHOOK_APP_INSTALLATIONS_NAMESPACES, both MUST be provided"); - } - (None, None) => { - config.github_webhook_app.installations - } - }; - // recreating CoreConfig here makes sure apply all env overrides applied. CoreConfig { // Secret things overridden with file - private_key: maybe_read_item_from_file(env.komodo_private_key_file, env.komodo_private_key) - .unwrap_or(config.private_key), - passkey: maybe_read_item_from_file(env.komodo_passkey_file, env.komodo_passkey) - .or(config.passkey), - jwt_secret: maybe_read_item_from_file(env.komodo_jwt_secret_file, env.komodo_jwt_secret).unwrap_or(config.jwt_secret), - webhook_secret: maybe_read_item_from_file(env.komodo_webhook_secret_file, env.komodo_webhook_secret) - .unwrap_or(config.webhook_secret), + private_key: maybe_read_item_from_file( + env.komodo_private_key_file, + env.komodo_private_key, + ) + .unwrap_or(config.private_key), + passkey: maybe_read_item_from_file( + env.komodo_passkey_file, + env.komodo_passkey, + ) + .or(config.passkey), + jwt_secret: maybe_read_item_from_file( + env.komodo_jwt_secret_file, + env.komodo_jwt_secret, + ) + .unwrap_or(config.jwt_secret), + webhook_secret: maybe_read_item_from_file( + env.komodo_webhook_secret_file, + env.komodo_webhook_secret, + ) + .unwrap_or(config.webhook_secret), database: DatabaseConfig { - uri: maybe_read_item_from_file(env.komodo_database_uri_file,env.komodo_database_uri).unwrap_or(config.database.uri), - address: env.komodo_database_address.unwrap_or(config.database.address), - username: maybe_read_item_from_file(env.komodo_database_username_file,env - .komodo_database_username) - .unwrap_or(config.database.username), - password: maybe_read_item_from_file(env.komodo_database_password_file,env - .komodo_database_password) - .unwrap_or(config.database.password), + uri: maybe_read_item_from_file( + env.komodo_database_uri_file, + env.komodo_database_uri, + ) + .unwrap_or(config.database.uri), + address: env + .komodo_database_address + .unwrap_or(config.database.address), + username: maybe_read_item_from_file( + env.komodo_database_username_file, + env.komodo_database_username, + ) + .unwrap_or(config.database.username), + password: maybe_read_item_from_file( + env.komodo_database_password_file, + env.komodo_database_password, + ) + .unwrap_or(config.database.password), app_name: env .komodo_database_app_name .unwrap_or(config.database.app_name), @@ -188,64 +184,82 @@ pub fn core_config() -> &'static CoreConfig { }, init_admin_username: maybe_read_item_from_file( env.komodo_init_admin_username_file, - env.komodo_init_admin_username - ).or(config.init_admin_username), + env.komodo_init_admin_username, + ) + .or(config.init_admin_username), init_admin_password: maybe_read_item_from_file( env.komodo_init_admin_password_file, - env.komodo_init_admin_password - ).unwrap_or(config.init_admin_password), - oidc_enabled: env.komodo_oidc_enabled.unwrap_or(config.oidc_enabled), - oidc_provider: env.komodo_oidc_provider.unwrap_or(config.oidc_provider), - oidc_redirect_host: env.komodo_oidc_redirect_host.unwrap_or(config.oidc_redirect_host), - oidc_client_id: maybe_read_item_from_file(env.komodo_oidc_client_id_file,env - .komodo_oidc_client_id) - .unwrap_or(config.oidc_client_id), - oidc_client_secret: maybe_read_item_from_file(env.komodo_oidc_client_secret_file,env - .komodo_oidc_client_secret) - .unwrap_or(config.oidc_client_secret), - oidc_use_full_email: env.komodo_oidc_use_full_email + env.komodo_init_admin_password, + ) + .unwrap_or(config.init_admin_password), + oidc_enabled: env + .komodo_oidc_enabled + .unwrap_or(config.oidc_enabled), + oidc_provider: env + .komodo_oidc_provider + .unwrap_or(config.oidc_provider), + oidc_redirect_host: env + .komodo_oidc_redirect_host + .unwrap_or(config.oidc_redirect_host), + oidc_client_id: maybe_read_item_from_file( + env.komodo_oidc_client_id_file, + env.komodo_oidc_client_id, + ) + .unwrap_or(config.oidc_client_id), + oidc_client_secret: maybe_read_item_from_file( + env.komodo_oidc_client_secret_file, + env.komodo_oidc_client_secret, + ) + .unwrap_or(config.oidc_client_secret), + oidc_use_full_email: env + .komodo_oidc_use_full_email .unwrap_or(config.oidc_use_full_email), - oidc_additional_audiences: maybe_read_list_from_file(env.komodo_oidc_additional_audiences_file,env - .komodo_oidc_additional_audiences) - .unwrap_or(config.oidc_additional_audiences), + oidc_additional_audiences: maybe_read_list_from_file( + env.komodo_oidc_additional_audiences_file, + env.komodo_oidc_additional_audiences, + ) + .unwrap_or(config.oidc_additional_audiences), google_oauth: OauthCredentials { enabled: env .komodo_google_oauth_enabled .unwrap_or(config.google_oauth.enabled), - id: maybe_read_item_from_file(env.komodo_google_oauth_id_file,env - .komodo_google_oauth_id) - .unwrap_or(config.google_oauth.id), - secret: maybe_read_item_from_file(env.komodo_google_oauth_secret_file,env - .komodo_google_oauth_secret) - .unwrap_or(config.google_oauth.secret), + id: maybe_read_item_from_file( + env.komodo_google_oauth_id_file, + env.komodo_google_oauth_id, + ) + .unwrap_or(config.google_oauth.id), + secret: maybe_read_item_from_file( + env.komodo_google_oauth_secret_file, + env.komodo_google_oauth_secret, + ) + .unwrap_or(config.google_oauth.secret), }, github_oauth: OauthCredentials { enabled: env .komodo_github_oauth_enabled .unwrap_or(config.github_oauth.enabled), - id: maybe_read_item_from_file(env.komodo_github_oauth_id_file,env - .komodo_github_oauth_id) - .unwrap_or(config.github_oauth.id), - secret: maybe_read_item_from_file(env.komodo_github_oauth_secret_file,env - .komodo_github_oauth_secret) - .unwrap_or(config.github_oauth.secret), + id: maybe_read_item_from_file( + env.komodo_github_oauth_id_file, + env.komodo_github_oauth_id, + ) + .unwrap_or(config.github_oauth.id), + secret: maybe_read_item_from_file( + env.komodo_github_oauth_secret_file, + env.komodo_github_oauth_secret, + ) + .unwrap_or(config.github_oauth.secret), }, aws: AwsCredentials { - access_key_id: maybe_read_item_from_file(env.komodo_aws_access_key_id_file, env - .komodo_aws_access_key_id) - .unwrap_or(config.aws.access_key_id), - secret_access_key: maybe_read_item_from_file(env.komodo_aws_secret_access_key_file, env - .komodo_aws_secret_access_key) - .unwrap_or(config.aws.secret_access_key), - }, - github_webhook_app: GithubWebhookAppConfig { - app_id: maybe_read_item_from_file(env.komodo_github_webhook_app_app_id_file, env - .komodo_github_webhook_app_app_id) - .unwrap_or(config.github_webhook_app.app_id), - pk_path: env - .komodo_github_webhook_app_pk_path - .unwrap_or(config.github_webhook_app.pk_path), - installations, + access_key_id: maybe_read_item_from_file( + env.komodo_aws_access_key_id_file, + env.komodo_aws_access_key_id, + ) + .unwrap_or(config.aws.access_key_id), + secret_access_key: maybe_read_item_from_file( + env.komodo_aws_secret_access_key_file, + env.komodo_aws_secret_access_key, + ) + .unwrap_or(config.aws.secret_access_key), }, // Non secrets @@ -254,13 +268,19 @@ pub fn core_config() -> &'static CoreConfig { port: env.komodo_port.unwrap_or(config.port), bind_ip: env.komodo_bind_ip.unwrap_or(config.bind_ip), timezone: env.komodo_timezone.unwrap_or(config.timezone), - periphery_public_keys: env.komodo_periphery_public_keys.or(config.periphery_public_keys), - first_server_address: env.komodo_first_server_address.or(config.first_server_address), - first_server_name: env.komodo_first_server_name.or(config.first_server_name), - frontend_path: env.komodo_frontend_path.unwrap_or(config.frontend_path), - jwt_ttl: env - .komodo_jwt_ttl - .unwrap_or(config.jwt_ttl), + periphery_public_keys: env + .komodo_periphery_public_keys + .or(config.periphery_public_keys), + first_server_address: env + .komodo_first_server_address + .or(config.first_server_address), + first_server_name: env + .komodo_first_server_name + .or(config.first_server_name), + frontend_path: env + .komodo_frontend_path + .unwrap_or(config.frontend_path), + jwt_ttl: env.komodo_jwt_ttl.unwrap_or(config.jwt_ttl), sync_directory: env .komodo_sync_directory .unwrap_or(config.sync_directory), @@ -291,24 +311,31 @@ pub fn core_config() -> &'static CoreConfig { ui_write_disabled: env .komodo_ui_write_disabled .unwrap_or(config.ui_write_disabled), - disable_confirm_dialog: env.komodo_disable_confirm_dialog + disable_confirm_dialog: env + .komodo_disable_confirm_dialog .unwrap_or(config.disable_confirm_dialog), - disable_websocket_reconnect: env.komodo_disable_websocket_reconnect + disable_websocket_reconnect: env + .komodo_disable_websocket_reconnect .unwrap_or(config.disable_websocket_reconnect), - enable_new_users: env.komodo_enable_new_users + enable_new_users: env + .komodo_enable_new_users .unwrap_or(config.enable_new_users), - disable_user_registration: env.komodo_disable_user_registration + disable_user_registration: env + .komodo_disable_user_registration .unwrap_or(config.disable_user_registration), - disable_non_admin_create: env.komodo_disable_non_admin_create + disable_non_admin_create: env + .komodo_disable_non_admin_create .unwrap_or(config.disable_non_admin_create), - disable_init_resources: env.komodo_disable_init_resources + disable_init_resources: env + .komodo_disable_init_resources .unwrap_or(config.disable_init_resources), - enable_fancy_toml: env.komodo_enable_fancy_toml + enable_fancy_toml: env + .komodo_enable_fancy_toml .unwrap_or(config.enable_fancy_toml), - lock_login_credentials_for: env.komodo_lock_login_credentials_for + lock_login_credentials_for: env + .komodo_lock_login_credentials_for .unwrap_or(config.lock_login_credentials_for), - local_auth: env.komodo_local_auth - .unwrap_or(config.local_auth), + local_auth: env.komodo_local_auth.unwrap_or(config.local_auth), logging: LogConfig { level: env .komodo_logging_level @@ -316,9 +343,11 @@ pub fn core_config() -> &'static CoreConfig { stdio: env .komodo_logging_stdio .unwrap_or(config.logging.stdio), - pretty: env.komodo_logging_pretty + pretty: env + .komodo_logging_pretty .unwrap_or(config.logging.pretty), - location: env.komodo_logging_location + location: env + .komodo_logging_location .unwrap_or(config.logging.location), otlp_endpoint: env .komodo_logging_otlp_endpoint @@ -327,12 +356,24 @@ pub fn core_config() -> &'static CoreConfig { .komodo_logging_opentelemetry_service_name .unwrap_or(config.logging.opentelemetry_service_name), }, - pretty_startup_config: env.komodo_pretty_startup_config.unwrap_or(config.pretty_startup_config), - unsafe_unsanitized_startup_config: env.komodo_unsafe_unsanitized_startup_config.unwrap_or(config.unsafe_unsanitized_startup_config), - internet_interface: env.komodo_internet_interface.unwrap_or(config.internet_interface), - ssl_enabled: env.komodo_ssl_enabled.unwrap_or(config.ssl_enabled), - ssl_key_file: env.komodo_ssl_key_file.unwrap_or(config.ssl_key_file), - ssl_cert_file: env.komodo_ssl_cert_file.unwrap_or(config.ssl_cert_file), + pretty_startup_config: env + .komodo_pretty_startup_config + .unwrap_or(config.pretty_startup_config), + unsafe_unsanitized_startup_config: env + .komodo_unsafe_unsanitized_startup_config + .unwrap_or(config.unsafe_unsanitized_startup_config), + internet_interface: env + .komodo_internet_interface + .unwrap_or(config.internet_interface), + ssl_enabled: env + .komodo_ssl_enabled + .unwrap_or(config.ssl_enabled), + ssl_key_file: env + .komodo_ssl_key_file + .unwrap_or(config.ssl_key_file), + ssl_cert_file: env + .komodo_ssl_cert_file + .unwrap_or(config.ssl_cert_file), // These can't be overridden on env secrets: config.secrets, diff --git a/bin/core/src/state.rs b/bin/core/src/state.rs index db5480b9b..68be29678 100644 --- a/bin/core/src/state.rs +++ b/bin/core/src/state.rs @@ -1,22 +1,12 @@ -use std::{ - collections::HashMap, - sync::{Arc, OnceLock}, -}; +use std::sync::{Arc, OnceLock}; use anyhow::Context; use arc_swap::ArcSwap; use cache::CloneCache; use komodo_client::entities::{ - action::ActionState, - build::BuildState, - config::core::{CoreConfig, GithubWebhookAppConfig}, - deployment::DeploymentState, - procedure::ProcedureState, - repo::RepoState, - stack::StackState, -}; -use octorust::auth::{ - Credentials, InstallationTokenGenerator, JWTCredentials, + action::ActionState, build::BuildState, + deployment::DeploymentState, procedure::ProcedureState, + repo::RepoState, stack::StackState, }; use crate::{ @@ -149,73 +139,3 @@ pub fn all_resources_cache() -> &'static ArcSwap { OnceLock::new(); ALL_RESOURCES.get_or_init(Default::default) } - -pub fn github_client() --> Option<&'static HashMap> { - static GITHUB_CLIENT: OnceLock< - Option>, - > = OnceLock::new(); - GITHUB_CLIENT - .get_or_init(|| { - let CoreConfig { - github_webhook_app: - GithubWebhookAppConfig { - app_id, - installations, - pk_path, - .. - }, - .. - } = core_config(); - if *app_id == 0 || installations.is_empty() { - return None; - } - let private_key = match std::fs::read(pk_path).with_context(|| format!("github webhook app | failed to load private key at {pk_path}")) { - Ok(key) => key, - Err(e) => { - error!("{e:#}"); - return None; - } - }; - - let private_key = match nom_pem::decode_block(&private_key) { - Ok(key) => key, - Err(e) => { - error!("github webhook app | failed to decode private key at {pk_path} | {e:?}"); - return None; - } - }; - - let jwt = match JWTCredentials::new(*app_id, private_key.data).context("failed to initialize github JWTCredentials") { - Ok(jwt) => jwt, - Err(e) => { - error!("github webhook app | failed to make github JWTCredentials | pk path: {pk_path} | {e:#}"); - return None - } - }; - - let mut clients = - HashMap::with_capacity(installations.capacity()); - - for installation in installations { - let token_generator = InstallationTokenGenerator::new( - installation.id, - jwt.clone(), - ); - let client = match octorust::Client::new( - "github-app", - Credentials::InstallationToken(token_generator), - ).with_context(|| format!("failed to initialize github webhook client for installation {}", installation.id)) { - Ok(client) => client, - Err(e) => { - error!("{e:#}"); - continue; - } - }; - clients.insert(installation.namespace.to_string(), client); - } - - Some(clients) - }) - .as_ref() -} diff --git a/client/core/rs/src/api/read/build.rs b/client/core/rs/src/api/read/build.rs index ac886f751..feaa6985d 100644 --- a/client/core/rs/src/api/read/build.rs +++ b/client/core/rs/src/api/read/build.rs @@ -237,29 +237,3 @@ pub struct ListCommonBuildExtraArgs { #[typeshare] pub type ListCommonBuildExtraArgsResponse = Vec; -// - -/// Get whether a Build's target repo has a webhook for the build configured. Response: [GetBuildWebhookEnabledResponse]. -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoReadRequest)] -#[response(GetBuildWebhookEnabledResponse)] -#[error(serror::Error)] -pub struct GetBuildWebhookEnabled { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub build: String, -} - -/// Response for [GetBuildWebhookEnabled] -#[typeshare] -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetBuildWebhookEnabledResponse { - /// Whether the repo webhooks can even be managed. - /// The repo owner must be in `github_webhook_app.owners` list to be managed. - pub managed: bool, - /// Whether pushes to branch trigger build. Will always be false if managed is false. - pub enabled: bool, -} diff --git a/client/core/rs/src/api/read/mod.rs b/client/core/rs/src/api/read/mod.rs index ed343367b..84e3573be 100644 --- a/client/core/rs/src/api/read/mod.rs +++ b/client/core/rs/src/api/read/mod.rs @@ -108,8 +108,6 @@ pub struct GetCoreInfoResponse { pub disable_non_admin_create: bool, /// Whether confirm dialog should be disabled pub disable_confirm_dialog: bool, - /// The repo owners for which github webhook management api is available - pub github_webhook_owners: Vec, /// Whether to disable websocket automatic reconnect. pub disable_websocket_reconnect: bool, /// Whether to enable fancy toml highlighting. diff --git a/client/core/rs/src/api/read/repo.rs b/client/core/rs/src/api/read/repo.rs index 16f2521ef..551cc6da5 100644 --- a/client/core/rs/src/api/read/repo.rs +++ b/client/core/rs/src/api/read/repo.rs @@ -117,34 +117,3 @@ pub struct GetReposSummaryResponse { /// The number of repos with unknown state. pub unknown: u32, } - -// - -/// Get a target Repo's configured webhooks. Response: [GetRepoWebhooksEnabledResponse]. -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoReadRequest)] -#[response(GetRepoWebhooksEnabledResponse)] -#[error(serror::Error)] -pub struct GetRepoWebhooksEnabled { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub repo: String, -} - -/// Response for [GetRepoWebhooksEnabled] -#[typeshare] -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetRepoWebhooksEnabledResponse { - /// Whether the repo webhooks can even be managed. - /// The repo owner must be in `github_webhook_app.owners` list to be managed. - pub managed: bool, - /// Whether pushes to branch trigger clone. Will always be false if managed is false. - pub clone_enabled: bool, - /// Whether pushes to branch trigger pull. Will always be false if managed is false. - pub pull_enabled: bool, - /// Whether pushes to branch trigger build. Will always be false if managed is false. - pub build_enabled: bool, -} diff --git a/client/core/rs/src/api/read/stack.rs b/client/core/rs/src/api/read/stack.rs index 0d634b3cb..832773368 100644 --- a/client/core/rs/src/api/read/stack.rs +++ b/client/core/rs/src/api/read/stack.rs @@ -276,32 +276,3 @@ pub struct GetStacksSummaryResponse { /// The number of stacks with Unknown state. pub unknown: u32, } - -// - -/// Get a target stack's configured webhooks. Response: [GetStackWebhooksEnabledResponse]. -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoReadRequest)] -#[response(GetStackWebhooksEnabledResponse)] -#[error(serror::Error)] -pub struct GetStackWebhooksEnabled { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub stack: String, -} - -/// Response for [GetStackWebhooksEnabled] -#[typeshare] -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetStackWebhooksEnabledResponse { - /// Whether the repo webhooks can even be managed. - /// The repo owner must be in `github_webhook_app.owners` list to be managed. - pub managed: bool, - /// Whether pushes to branch trigger refresh. Will always be false if managed is false. - pub refresh_enabled: bool, - /// Whether pushes to branch trigger stack execution. Will always be false if managed is false. - pub deploy_enabled: bool, -} diff --git a/client/core/rs/src/api/read/sync.rs b/client/core/rs/src/api/read/sync.rs index 54623c887..0bf6f8a59 100644 --- a/client/core/rs/src/api/read/sync.rs +++ b/client/core/rs/src/api/read/sync.rs @@ -116,32 +116,3 @@ pub struct GetResourceSyncsSummaryResponse { /// The number of syncs with unknown state. pub unknown: u32, } - -// - -/// Get a target Sync's configured webhooks. Response: [GetSyncWebhooksEnabledResponse]. -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoReadRequest)] -#[response(GetSyncWebhooksEnabledResponse)] -#[error(serror::Error)] -pub struct GetSyncWebhooksEnabled { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub sync: String, -} - -/// Response for [GetSyncWebhooksEnabled] -#[typeshare] -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct GetSyncWebhooksEnabledResponse { - /// Whether the repo webhooks can even be managed. - /// The repo owner must be in `github_webhook_app.owners` list to be managed. - pub managed: bool, - /// Whether pushes to branch trigger refresh. Will always be false if managed is false. - pub refresh_enabled: bool, - /// Whether pushes to branch trigger sync execution. Will always be false if managed is false. - pub sync_enabled: bool, -} diff --git a/client/core/rs/src/api/write/action.rs b/client/core/rs/src/api/write/action.rs index 853377a7b..0a101d782 100644 --- a/client/core/rs/src/api/write/action.rs +++ b/client/core/rs/src/api/write/action.rs @@ -4,7 +4,6 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - NoData, action::{_PartialActionConfig, Action}, update::Update, }; @@ -104,41 +103,3 @@ pub struct RenameAction { /// The new name. pub name: String, } - -/// Create a webhook on the github action attached to the Action resource. -/// passed in request. Response: [CreateActionWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(CreateActionWebhookResponse)] -#[error(serror::Error)] -pub struct CreateActionWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub action: String, -} - -#[typeshare] -pub type CreateActionWebhookResponse = NoData; - -// - -/// Delete the webhook on the github action attached to the Action resource. -/// passed in request. Response: [DeleteActionWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(DeleteActionWebhookResponse)] -#[error(serror::Error)] -pub struct DeleteActionWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub action: String, -} - -#[typeshare] -pub type DeleteActionWebhookResponse = NoData; diff --git a/client/core/rs/src/api/write/build.rs b/client/core/rs/src/api/write/build.rs index bd1030c3e..bc57e62fd 100644 --- a/client/core/rs/src/api/write/build.rs +++ b/client/core/rs/src/api/write/build.rs @@ -138,43 +138,3 @@ pub struct RefreshBuildCache { #[serde(alias = "id", alias = "name")] pub build: String, } - -// - -/// Create a webhook on the github repo attached to the build -/// passed in request. Response: [CreateBuildWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(CreateBuildWebhookResponse)] -#[error(serror::Error)] -pub struct CreateBuildWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub build: String, -} - -#[typeshare] -pub type CreateBuildWebhookResponse = NoData; - -// - -/// Delete a webhook on the github repo attached to the build -/// passed in request. Response: [CreateBuildWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(DeleteBuildWebhookResponse)] -#[error(serror::Error)] -pub struct DeleteBuildWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub build: String, -} - -#[typeshare] -pub type DeleteBuildWebhookResponse = NoData; diff --git a/client/core/rs/src/api/write/repo.rs b/client/core/rs/src/api/write/repo.rs index 60f11569d..1d9038593 100644 --- a/client/core/rs/src/api/write/repo.rs +++ b/client/core/rs/src/api/write/repo.rs @@ -133,45 +133,3 @@ pub enum RepoWebhookAction { Pull, Build, } - -/// Create a webhook on the github repo attached to the (Komodo) Repo resource. -/// passed in request. Response: [CreateRepoWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(CreateRepoWebhookResponse)] -#[error(serror::Error)] -pub struct CreateRepoWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub repo: String, - /// "Clone" or "Pull" or "Build" - pub action: RepoWebhookAction, -} - -#[typeshare] -pub type CreateRepoWebhookResponse = NoData; - -// - -/// Delete the webhook on the github repo attached to the (Komodo) Repo resource. -/// passed in request. Response: [DeleteRepoWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(DeleteRepoWebhookResponse)] -#[error(serror::Error)] -pub struct DeleteRepoWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub repo: String, - /// "Clone" or "Pull" or "Build" - pub action: RepoWebhookAction, -} - -#[typeshare] -pub type DeleteRepoWebhookResponse = NoData; diff --git a/client/core/rs/src/api/write/stack.rs b/client/core/rs/src/api/write/stack.rs index 8304f060d..ac504347a 100644 --- a/client/core/rs/src/api/write/stack.rs +++ b/client/core/rs/src/api/write/stack.rs @@ -155,45 +155,3 @@ pub enum StackWebhookAction { Refresh, Deploy, } - -/// Create a webhook on the github repo attached to the stack -/// passed in request. Response: [CreateStackWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(CreateStackWebhookResponse)] -#[error(serror::Error)] -pub struct CreateStackWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub stack: String, - /// "Refresh" or "Deploy" - pub action: StackWebhookAction, -} - -#[typeshare] -pub type CreateStackWebhookResponse = NoData; - -// - -/// Delete the webhook on the github repo attached to the stack -/// passed in request. Response: [DeleteStackWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(DeleteStackWebhookResponse)] -#[error(serror::Error)] -pub struct DeleteStackWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub stack: String, - /// "Refresh" or "Deploy" - pub action: StackWebhookAction, -} - -#[typeshare] -pub type DeleteStackWebhookResponse = NoData; diff --git a/client/core/rs/src/api/write/sync.rs b/client/core/rs/src/api/write/sync.rs index 38f895b32..f1cddae14 100644 --- a/client/core/rs/src/api/write/sync.rs +++ b/client/core/rs/src/api/write/sync.rs @@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize}; use typeshare::typeshare; use crate::entities::{ - NoData, sync::{_PartialResourceSyncConfig, ResourceSync}, update::Update, }; @@ -178,45 +177,3 @@ pub enum SyncWebhookAction { Refresh, Sync, } - -/// Create a webhook on the github repo attached to the sync -/// passed in request. Response: [CreateSyncWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(CreateSyncWebhookResponse)] -#[error(serror::Error)] -pub struct CreateSyncWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub sync: String, - /// "Refresh" or "Sync" - pub action: SyncWebhookAction, -} - -#[typeshare] -pub type CreateSyncWebhookResponse = NoData; - -// - -/// Delete the webhook on the github repo attached to the sync -/// passed in request. Response: [DeleteSyncWebhookResponse] -#[typeshare] -#[derive( - Serialize, Deserialize, Debug, Clone, Resolve, EmptyTraits, -)] -#[empty_traits(KomodoWriteRequest)] -#[response(DeleteSyncWebhookResponse)] -#[error(serror::Error)] -pub struct DeleteSyncWebhook { - /// Id or name - #[serde(alias = "id", alias = "name")] - pub sync: String, - /// "Refresh" or "Sync" - pub action: SyncWebhookAction, -} - -#[typeshare] -pub type DeleteSyncWebhookResponse = NoData; diff --git a/client/core/rs/src/entities/config/core.rs b/client/core/rs/src/entities/config/core.rs index 2455f3263..219fcf0d2 100644 --- a/client/core/rs/src/entities/config/core.rs +++ b/client/core/rs/src/entities/config/core.rs @@ -214,25 +214,6 @@ pub struct Env { /// Override `github_oauth.secret` from file pub komodo_github_oauth_secret_file: Option, - /// Override `github_webhook_app.app_id` - pub komodo_github_webhook_app_app_id: Option, - /// Override `github_webhook_app.app_id` from file - pub komodo_github_webhook_app_app_id_file: Option, - /// Override `github_webhook_app.installations[i].id`. Accepts comma seperated list. - /// - /// Note. Paired by index with values in `komodo_github_webhook_app_installations_namespaces` - pub komodo_github_webhook_app_installations_ids: Option>, - /// Override `github_webhook_app.installations[i].id` from file - pub komodo_github_webhook_app_installations_ids_file: - Option, - /// Override `github_webhook_app.installations[i].namespace`. Accepts comma seperated list. - /// - /// Note. Paired by index with values in `komodo_github_webhook_app_installations_ids` - pub komodo_github_webhook_app_installations_namespaces: - Option>, - /// Override `github_webhook_app.pk_path` - pub komodo_github_webhook_app_pk_path: Option, - /// Override `database.uri` #[serde(alias = "komodo_mongo_uri")] pub komodo_database_uri: Option, @@ -544,11 +525,6 @@ pub struct CoreConfig { #[serde(default)] pub webhook_base_url: String, - /// Configure a Github Webhook app. - /// Allows users to manage repo webhooks from within the Komodo UI. - #[serde(default)] - pub github_webhook_app: GithubWebhookAppConfig, - // =========== // = Logging = // =========== @@ -782,7 +758,6 @@ impl Default for CoreConfig { github_oauth: Default::default(), webhook_secret: Default::default(), webhook_base_url: Default::default(), - github_webhook_app: Default::default(), logging: Default::default(), pretty_startup_config: Default::default(), unsafe_unsanitized_startup_config: Default::default(), @@ -879,7 +854,6 @@ impl CoreConfig { }, webhook_secret: empty_or_redacted(&config.webhook_secret), webhook_base_url: config.webhook_base_url, - github_webhook_app: config.github_webhook_app, database: config.database.sanitized(), aws: AwsCredentials { access_key_id: empty_or_redacted(&config.aws.access_key_id), @@ -942,38 +916,3 @@ pub struct AwsCredentials { /// The aws SECRET_ACCESS_KEY pub secret_access_key: String, } - -/// Provide configuration for a Github Webhook app. -#[derive(Debug, Clone, Deserialize)] -pub struct GithubWebhookAppConfig { - /// Github app id - pub app_id: i64, - /// Configure the app installations on multiple accounts / organizations. - pub installations: Vec, - /// Private key path. Default: /github-private-key.pem. - #[serde(default = "default_private_key_path")] - pub pk_path: String, -} - -fn default_private_key_path() -> String { - String::from("/github/private-key.pem") -} - -impl Default for GithubWebhookAppConfig { - fn default() -> Self { - GithubWebhookAppConfig { - app_id: 0, - installations: Default::default(), - pk_path: default_private_key_path(), - } - } -} - -/// Provide configuration for a Github Webhook app installation. -#[derive(Debug, Clone, Deserialize)] -pub struct GithubWebhookAppInstallationConfig { - /// The installation ID - pub id: i64, - /// The user or organization name - pub namespace: String, -} diff --git a/client/core/ts/src/responses.ts b/client/core/ts/src/responses.ts index 8baba9f58..5f1e8ab90 100644 --- a/client/core/ts/src/responses.ts +++ b/client/core/ts/src/responses.ts @@ -85,7 +85,6 @@ export type ReadResponses = { GetStacksSummary: Types.GetStacksSummaryResponse; GetStack: Types.GetStackResponse; GetStackActionState: Types.GetStackActionStateResponse; - GetStackWebhooksEnabled: Types.GetStackWebhooksEnabledResponse; GetStackLog: Types.GetStackLogResponse; SearchStackLog: Types.SearchStackLogResponse; InspectStackContainer: Types.InspectStackContainerResponse; @@ -113,7 +112,6 @@ export type ReadResponses = { GetBuild: Types.GetBuildResponse; GetBuildActionState: Types.GetBuildActionStateResponse; GetBuildMonthlyStats: Types.GetBuildMonthlyStatsResponse; - GetBuildWebhookEnabled: Types.GetBuildWebhookEnabledResponse; ListBuilds: Types.ListBuildsResponse; ListFullBuilds: Types.ListFullBuildsResponse; ListBuildVersions: Types.ListBuildVersionsResponse; @@ -123,7 +121,6 @@ export type ReadResponses = { GetReposSummary: Types.GetReposSummaryResponse; GetRepo: Types.GetRepoResponse; GetRepoActionState: Types.GetRepoActionStateResponse; - GetRepoWebhooksEnabled: Types.GetRepoWebhooksEnabledResponse; ListRepos: Types.ListReposResponse; ListFullRepos: Types.ListFullReposResponse; @@ -131,7 +128,6 @@ export type ReadResponses = { GetResourceSyncsSummary: Types.GetResourceSyncsSummaryResponse; GetResourceSync: Types.GetResourceSyncResponse; GetResourceSyncActionState: Types.GetResourceSyncActionStateResponse; - GetSyncWebhooksEnabled: Types.GetSyncWebhooksEnabledResponse; ListResourceSyncs: Types.ListResourceSyncsResponse; ListFullResourceSyncs: Types.ListFullResourceSyncsResponse; @@ -234,8 +230,6 @@ export type WriteResponses = { RenameStack: Types.Update; WriteStackFileContents: Types.Update; RefreshStackCache: Types.NoData; - CreateStackWebhook: Types.CreateStackWebhookResponse; - DeleteStackWebhook: Types.DeleteStackWebhookResponse; // ==== DEPLOYMENT ==== CreateDeployment: Types.Deployment; @@ -253,8 +247,6 @@ export type WriteResponses = { RenameBuild: Types.Update; WriteBuildFileContents: Types.Update; RefreshBuildCache: Types.NoData; - CreateBuildWebhook: Types.CreateBuildWebhookResponse; - DeleteBuildWebhook: Types.DeleteBuildWebhookResponse; // ==== BUILDER ==== CreateBuilder: Types.Builder; @@ -270,8 +262,6 @@ export type WriteResponses = { UpdateRepo: Types.Repo; RenameRepo: Types.Update; RefreshRepoCache: Types.NoData; - CreateRepoWebhook: Types.CreateRepoWebhookResponse; - DeleteRepoWebhook: Types.DeleteRepoWebhookResponse; // ==== ALERTER ==== CreateAlerter: Types.Alerter; @@ -303,8 +293,6 @@ export type WriteResponses = { CommitSync: Types.Update; WriteSyncFileContents: Types.Update; RefreshResourceSyncPending: Types.ResourceSync; - CreateSyncWebhook: Types.CreateSyncWebhookResponse; - DeleteSyncWebhook: Types.DeleteSyncWebhookResponse; // ==== TAG ==== CreateTag: Types.Tag; diff --git a/client/core/ts/src/types.ts b/client/core/ts/src/types.ts index 07ccabf8c..0af847427 100644 --- a/client/core/ts/src/types.ts +++ b/client/core/ts/src/types.ts @@ -965,8 +965,6 @@ export type Procedure = Resource; export type CopyProcedureResponse = Procedure; -export type CreateActionWebhookResponse = NoData; - /** Response for [CreateApiKey]. */ export interface CreateApiKeyResponse { /** X-API-KEY */ @@ -982,8 +980,6 @@ export interface CreateApiKeyResponse { export type CreateApiKeyForServiceUserResponse = CreateApiKeyResponse; -export type CreateBuildWebhookResponse = NoData; - /** Configuration to access private image repositories on various registries. */ export interface DockerRegistryAccount { /** @@ -1101,14 +1097,8 @@ export type CreateLocalUserResponse = User; export type CreateProcedureResponse = Procedure; -export type CreateRepoWebhookResponse = NoData; - export type CreateServiceUserResponse = User; -export type CreateStackWebhookResponse = NoData; - -export type CreateSyncWebhookResponse = NoData; - /** * A non-secret global variable which can be interpolated into deployment * environment variable values and build argument values. @@ -1136,14 +1126,10 @@ export interface Variable { export type CreateVariableResponse = Variable; -export type DeleteActionWebhookResponse = NoData; - export type DeleteApiKeyForServiceUserResponse = NoData; export type DeleteApiKeyResponse = NoData; -export type DeleteBuildWebhookResponse = NoData; - export type DeleteDockerRegistryAccountResponse = DockerRegistryAccount; export type DeleteGitProviderAccountResponse = GitProviderAccount; @@ -1184,12 +1170,6 @@ export type DeleteOnboardingKeyResponse = OnboardingKey; export type DeleteProcedureResponse = Procedure; -export type DeleteRepoWebhookResponse = NoData; - -export type DeleteStackWebhookResponse = NoData; - -export type DeleteSyncWebhookResponse = NoData; - export type DeleteUserResponse = User; export type DeleteVariableResponse = Variable; @@ -5020,15 +5000,6 @@ export interface CreateAction { config?: _PartialActionConfig; } -/** - * Create a webhook on the github action attached to the Action resource. - * passed in request. Response: [CreateActionWebhookResponse] - */ -export interface CreateActionWebhook { - /** Id or name */ - action: string; -} - /** Create an alerter. Response: [Alerter]. */ export interface CreateAlerter { /** The name given to newly created alerter. */ @@ -5078,15 +5049,6 @@ export interface CreateBuild { config?: _PartialBuildConfig; } -/** - * Create a webhook on the github repo attached to the build - * passed in request. Response: [CreateBuildWebhookResponse] - */ -export interface CreateBuildWebhook { - /** Id or name */ - build: string; -} - /** Partial representation of [BuilderConfig] */ export type PartialBuilderConfig = | { type: "Url", params: _PartialUrlBuilderConfig } @@ -5218,23 +5180,6 @@ export interface CreateRepo { config?: _PartialRepoConfig; } -export enum RepoWebhookAction { - Clone = "Clone", - Pull = "Pull", - Build = "Build", -} - -/** - * Create a webhook on the github repo attached to the (Komodo) Repo resource. - * passed in request. Response: [CreateRepoWebhookResponse] - */ -export interface CreateRepoWebhook { - /** Id or name */ - repo: string; - /** "Clone" or "Pull" or "Build" */ - action: RepoWebhookAction; -} - /** Create a sync. Response: [ResourceSync]. */ export interface CreateResourceSync { /** The name given to newly created sync. */ @@ -5272,38 +5217,6 @@ export interface CreateStack { config?: _PartialStackConfig; } -export enum StackWebhookAction { - Refresh = "Refresh", - Deploy = "Deploy", -} - -/** - * Create a webhook on the github repo attached to the stack - * passed in request. Response: [CreateStackWebhookResponse] - */ -export interface CreateStackWebhook { - /** Id or name */ - stack: string; - /** "Refresh" or "Deploy" */ - action: StackWebhookAction; -} - -export enum SyncWebhookAction { - Refresh = "Refresh", - Sync = "Sync", -} - -/** - * Create a webhook on the github repo attached to the sync - * passed in request. Response: [CreateSyncWebhookResponse] - */ -export interface CreateSyncWebhook { - /** Id or name */ - sync: string; - /** "Refresh" or "Sync" */ - action: SyncWebhookAction; -} - /** Create a tag. Response: [Tag]. */ export interface CreateTag { /** The name of the tag. */ @@ -5383,15 +5296,6 @@ export interface DeleteAction { id: string; } -/** - * Delete the webhook on the github action attached to the Action resource. - * passed in request. Response: [DeleteActionWebhookResponse] - */ -export interface DeleteActionWebhook { - /** Id or name */ - action: string; -} - /** * Deletes the alerter at the given id, and returns the deleted alerter. * Response: [Alerter] @@ -5436,15 +5340,6 @@ export interface DeleteBuild { id: string; } -/** - * Delete a webhook on the github repo attached to the build - * passed in request. Response: [CreateBuildWebhookResponse] - */ -export interface DeleteBuildWebhook { - /** Id or name */ - build: string; -} - /** * Deletes the builder at the given id, and returns the deleted builder. * Response: [Builder] @@ -5532,17 +5427,6 @@ export interface DeleteRepo { id: string; } -/** - * Delete the webhook on the github repo attached to the (Komodo) Repo resource. - * passed in request. Response: [DeleteRepoWebhookResponse] - */ -export interface DeleteRepoWebhook { - /** Id or name */ - repo: string; - /** "Clone" or "Pull" or "Build" */ - action: RepoWebhookAction; -} - /** * Deletes the sync at the given id, and returns the deleted sync. * Response: [ResourceSync] @@ -5570,28 +5454,6 @@ export interface DeleteStack { id: string; } -/** - * Delete the webhook on the github repo attached to the stack - * passed in request. Response: [DeleteStackWebhookResponse] - */ -export interface DeleteStackWebhook { - /** Id or name */ - stack: string; - /** "Refresh" or "Deploy" */ - action: StackWebhookAction; -} - -/** - * Delete the webhook on the github repo attached to the sync - * passed in request. Response: [DeleteSyncWebhookResponse] - */ -export interface DeleteSyncWebhook { - /** Id or name */ - sync: string; - /** "Refresh" or "Sync" */ - action: SyncWebhookAction; -} - /** * Delete a tag, and return the deleted tag. Response: [Tag]. * @@ -6018,23 +5880,6 @@ export interface GetBuildMonthlyStatsResponse { days: BuildStatsDay[]; } -/** Get whether a Build's target repo has a webhook for the build configured. Response: [GetBuildWebhookEnabledResponse]. */ -export interface GetBuildWebhookEnabled { - /** Id or name */ - build: string; -} - -/** Response for [GetBuildWebhookEnabled] */ -export interface GetBuildWebhookEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger build. Will always be false if managed is false. */ - enabled: boolean; -} - /** Get a specific builder by id or name. Response: [Builder]. */ export interface GetBuilder { /** Id or name */ @@ -6119,8 +5964,6 @@ export interface GetCoreInfoResponse { disable_non_admin_create: boolean; /** Whether confirm dialog should be disabled */ disable_confirm_dialog: boolean; - /** The repo owners for which github webhook management api is available */ - github_webhook_owners: string[]; /** Whether to disable websocket automatic reconnect. */ disable_websocket_reconnect: boolean; /** Whether to enable fancy toml highlighting. */ @@ -6392,27 +6235,6 @@ export interface GetRepoActionState { repo: string; } -/** Get a target Repo's configured webhooks. Response: [GetRepoWebhooksEnabledResponse]. */ -export interface GetRepoWebhooksEnabled { - /** Id or name */ - repo: string; -} - -/** Response for [GetRepoWebhooksEnabled] */ -export interface GetRepoWebhooksEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger clone. Will always be false if managed is false. */ - clone_enabled: boolean; - /** Whether pushes to branch trigger pull. Will always be false if managed is false. */ - pull_enabled: boolean; - /** Whether pushes to branch trigger build. Will always be false if managed is false. */ - build_enabled: boolean; -} - /** * Gets a summary of data relating to all repos. * Response: [GetReposSummaryResponse]. @@ -6566,25 +6388,6 @@ export interface GetStackLog { timestamps?: boolean; } -/** Get a target stack's configured webhooks. Response: [GetStackWebhooksEnabledResponse]. */ -export interface GetStackWebhooksEnabled { - /** Id or name */ - stack: string; -} - -/** Response for [GetStackWebhooksEnabled] */ -export interface GetStackWebhooksEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger refresh. Will always be false if managed is false. */ - refresh_enabled: boolean; - /** Whether pushes to branch trigger stack execution. Will always be false if managed is false. */ - deploy_enabled: boolean; -} - /** * Gets a summary of data relating to all syncs. * Response: [GetStacksSummaryResponse]. @@ -6608,25 +6411,6 @@ export interface GetStacksSummaryResponse { unknown: number; } -/** Get a target Sync's configured webhooks. Response: [GetSyncWebhooksEnabledResponse]. */ -export interface GetSyncWebhooksEnabled { - /** Id or name */ - sync: string; -} - -/** Response for [GetSyncWebhooksEnabled] */ -export interface GetSyncWebhooksEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger refresh. Will always be false if managed is false. */ - refresh_enabled: boolean; - /** Whether pushes to branch trigger sync execution. Will always be false if managed is false. */ - sync_enabled: boolean; -} - /** * Get the system information of the target server. * Response: [SystemInformation]. @@ -8953,7 +8737,6 @@ export type ReadRequest = | { type: "GetStacksSummary", params: GetStacksSummary } | { type: "GetStack", params: GetStack } | { type: "GetStackActionState", params: GetStackActionState } - | { type: "GetStackWebhooksEnabled", params: GetStackWebhooksEnabled } | { type: "GetStackLog", params: GetStackLog } | { type: "SearchStackLog", params: SearchStackLog } | { type: "InspectStackContainer", params: InspectStackContainer } @@ -8978,20 +8761,17 @@ export type ReadRequest = | { type: "GetBuildActionState", params: GetBuildActionState } | { type: "GetBuildMonthlyStats", params: GetBuildMonthlyStats } | { type: "ListBuildVersions", params: ListBuildVersions } - | { type: "GetBuildWebhookEnabled", params: GetBuildWebhookEnabled } | { type: "ListBuilds", params: ListBuilds } | { type: "ListFullBuilds", params: ListFullBuilds } | { type: "ListCommonBuildExtraArgs", params: ListCommonBuildExtraArgs } | { type: "GetReposSummary", params: GetReposSummary } | { type: "GetRepo", params: GetRepo } | { type: "GetRepoActionState", params: GetRepoActionState } - | { type: "GetRepoWebhooksEnabled", params: GetRepoWebhooksEnabled } | { type: "ListRepos", params: ListRepos } | { type: "ListFullRepos", params: ListFullRepos } | { type: "GetResourceSyncsSummary", params: GetResourceSyncsSummary } | { type: "GetResourceSync", params: GetResourceSync } | { type: "GetResourceSyncActionState", params: GetResourceSyncActionState } - | { type: "GetSyncWebhooksEnabled", params: GetSyncWebhooksEnabled } | { type: "ListResourceSyncs", params: ListResourceSyncs } | { type: "ListFullResourceSyncs", params: ListFullResourceSyncs } | { type: "GetBuildersSummary", params: GetBuildersSummary } @@ -9018,6 +8798,12 @@ export type ReadRequest = | { type: "ListDockerRegistryAccounts", params: ListDockerRegistryAccounts } | { type: "ListOnboardingKeys", params: ListOnboardingKeys }; +export enum RepoWebhookAction { + Clone = "Clone", + Pull = "Pull", + Build = "Build", +} + /** The specific types of permission that a User or UserGroup can have on a resource. */ export enum SpecificPermission { /** @@ -9057,6 +8843,16 @@ export enum SpecificPermission { Processes = "Processes", } +export enum StackWebhookAction { + Refresh = "Refresh", + Deploy = "Deploy", +} + +export enum SyncWebhookAction { + Refresh = "Refresh", + Sync = "Sync", +} + export type UserRequest = | { type: "PushRecentlyViewed", params: PushRecentlyViewed } | { type: "SetLastSeenUpdate", params: SetLastSeenUpdate } @@ -9102,8 +8898,6 @@ export type WriteRequest = | { type: "RenameStack", params: RenameStack } | { type: "WriteStackFileContents", params: WriteStackFileContents } | { type: "RefreshStackCache", params: RefreshStackCache } - | { type: "CreateStackWebhook", params: CreateStackWebhook } - | { type: "DeleteStackWebhook", params: DeleteStackWebhook } | { type: "CreateDeployment", params: CreateDeployment } | { type: "CopyDeployment", params: CopyDeployment } | { type: "CreateDeploymentFromContainer", params: CreateDeploymentFromContainer } @@ -9117,8 +8911,6 @@ export type WriteRequest = | { type: "RenameBuild", params: RenameBuild } | { type: "WriteBuildFileContents", params: WriteBuildFileContents } | { type: "RefreshBuildCache", params: RefreshBuildCache } - | { type: "CreateBuildWebhook", params: CreateBuildWebhook } - | { type: "DeleteBuildWebhook", params: DeleteBuildWebhook } | { type: "CreateBuilder", params: CreateBuilder } | { type: "CopyBuilder", params: CopyBuilder } | { type: "DeleteBuilder", params: DeleteBuilder } @@ -9130,8 +8922,6 @@ export type WriteRequest = | { type: "UpdateRepo", params: UpdateRepo } | { type: "RenameRepo", params: RenameRepo } | { type: "RefreshRepoCache", params: RefreshRepoCache } - | { type: "CreateRepoWebhook", params: CreateRepoWebhook } - | { type: "DeleteRepoWebhook", params: DeleteRepoWebhook } | { type: "CreateAlerter", params: CreateAlerter } | { type: "CopyAlerter", params: CopyAlerter } | { type: "DeleteAlerter", params: DeleteAlerter } @@ -9155,8 +8945,6 @@ export type WriteRequest = | { type: "WriteSyncFileContents", params: WriteSyncFileContents } | { type: "CommitSync", params: CommitSync } | { type: "RefreshResourceSyncPending", params: RefreshResourceSyncPending } - | { type: "CreateSyncWebhook", params: CreateSyncWebhook } - | { type: "DeleteSyncWebhook", params: DeleteSyncWebhook } | { type: "CreateTag", params: CreateTag } | { type: "DeleteTag", params: DeleteTag } | { type: "RenameTag", params: RenameTag } diff --git a/frontend/public/client/responses.d.ts b/frontend/public/client/responses.d.ts index d83c23932..c0ac0d924 100644 --- a/frontend/public/client/responses.d.ts +++ b/frontend/public/client/responses.d.ts @@ -66,7 +66,6 @@ export type ReadResponses = { GetStacksSummary: Types.GetStacksSummaryResponse; GetStack: Types.GetStackResponse; GetStackActionState: Types.GetStackActionStateResponse; - GetStackWebhooksEnabled: Types.GetStackWebhooksEnabledResponse; GetStackLog: Types.GetStackLogResponse; SearchStackLog: Types.SearchStackLogResponse; InspectStackContainer: Types.InspectStackContainerResponse; @@ -90,7 +89,6 @@ export type ReadResponses = { GetBuild: Types.GetBuildResponse; GetBuildActionState: Types.GetBuildActionStateResponse; GetBuildMonthlyStats: Types.GetBuildMonthlyStatsResponse; - GetBuildWebhookEnabled: Types.GetBuildWebhookEnabledResponse; ListBuilds: Types.ListBuildsResponse; ListFullBuilds: Types.ListFullBuildsResponse; ListBuildVersions: Types.ListBuildVersionsResponse; @@ -98,13 +96,11 @@ export type ReadResponses = { GetReposSummary: Types.GetReposSummaryResponse; GetRepo: Types.GetRepoResponse; GetRepoActionState: Types.GetRepoActionStateResponse; - GetRepoWebhooksEnabled: Types.GetRepoWebhooksEnabledResponse; ListRepos: Types.ListReposResponse; ListFullRepos: Types.ListFullReposResponse; GetResourceSyncsSummary: Types.GetResourceSyncsSummaryResponse; GetResourceSync: Types.GetResourceSyncResponse; GetResourceSyncActionState: Types.GetResourceSyncActionStateResponse; - GetSyncWebhooksEnabled: Types.GetSyncWebhooksEnabledResponse; ListResourceSyncs: Types.ListResourceSyncsResponse; ListFullResourceSyncs: Types.ListFullResourceSyncsResponse; GetBuildersSummary: Types.GetBuildersSummaryResponse; @@ -173,8 +169,6 @@ export type WriteResponses = { RenameStack: Types.Update; WriteStackFileContents: Types.Update; RefreshStackCache: Types.NoData; - CreateStackWebhook: Types.CreateStackWebhookResponse; - DeleteStackWebhook: Types.DeleteStackWebhookResponse; CreateDeployment: Types.Deployment; CopyDeployment: Types.Deployment; CreateDeploymentFromContainer: Types.Deployment; @@ -188,8 +182,6 @@ export type WriteResponses = { RenameBuild: Types.Update; WriteBuildFileContents: Types.Update; RefreshBuildCache: Types.NoData; - CreateBuildWebhook: Types.CreateBuildWebhookResponse; - DeleteBuildWebhook: Types.DeleteBuildWebhookResponse; CreateBuilder: Types.Builder; CopyBuilder: Types.Builder; DeleteBuilder: Types.Builder; @@ -201,8 +193,6 @@ export type WriteResponses = { UpdateRepo: Types.Repo; RenameRepo: Types.Update; RefreshRepoCache: Types.NoData; - CreateRepoWebhook: Types.CreateRepoWebhookResponse; - DeleteRepoWebhook: Types.DeleteRepoWebhookResponse; CreateAlerter: Types.Alerter; CopyAlerter: Types.Alerter; DeleteAlerter: Types.Alerter; @@ -226,8 +216,6 @@ export type WriteResponses = { CommitSync: Types.Update; WriteSyncFileContents: Types.Update; RefreshResourceSyncPending: Types.ResourceSync; - CreateSyncWebhook: Types.CreateSyncWebhookResponse; - DeleteSyncWebhook: Types.DeleteSyncWebhookResponse; CreateTag: Types.Tag; DeleteTag: Types.Tag; RenameTag: Types.Tag; diff --git a/frontend/public/client/types.d.ts b/frontend/public/client/types.d.ts index 0c4cda5bc..7e13e15eb 100644 --- a/frontend/public/client/types.d.ts +++ b/frontend/public/client/types.d.ts @@ -1100,7 +1100,6 @@ export interface ProcedureConfig { */ export type Procedure = Resource; export type CopyProcedureResponse = Procedure; -export type CreateActionWebhookResponse = NoData; /** Response for [CreateApiKey]. */ export interface CreateApiKeyResponse { /** X-API-KEY */ @@ -1114,7 +1113,6 @@ export interface CreateApiKeyResponse { secret: string; } export type CreateApiKeyForServiceUserResponse = CreateApiKeyResponse; -export type CreateBuildWebhookResponse = NoData; /** Configuration to access private image repositories on various registries. */ export interface DockerRegistryAccount { /** @@ -1239,10 +1237,7 @@ export interface User { } export type CreateLocalUserResponse = User; export type CreateProcedureResponse = Procedure; -export type CreateRepoWebhookResponse = NoData; export type CreateServiceUserResponse = User; -export type CreateStackWebhookResponse = NoData; -export type CreateSyncWebhookResponse = NoData; /** * A non-secret global variable which can be interpolated into deployment * environment variable values and build argument values. @@ -1268,10 +1263,8 @@ export interface Variable { is_secret?: boolean; } export type CreateVariableResponse = Variable; -export type DeleteActionWebhookResponse = NoData; export type DeleteApiKeyForServiceUserResponse = NoData; export type DeleteApiKeyResponse = NoData; -export type DeleteBuildWebhookResponse = NoData; export type DeleteDockerRegistryAccountResponse = DockerRegistryAccount; export type DeleteGitProviderAccountResponse = GitProviderAccount; /** @@ -1307,9 +1300,6 @@ export interface OnboardingKey { } export type DeleteOnboardingKeyResponse = OnboardingKey; export type DeleteProcedureResponse = Procedure; -export type DeleteRepoWebhookResponse = NoData; -export type DeleteStackWebhookResponse = NoData; -export type DeleteSyncWebhookResponse = NoData; export type DeleteUserResponse = User; export type DeleteVariableResponse = Variable; export type DeploymentImage = @@ -4876,14 +4866,6 @@ export interface CreateAction { /** Optional partial config to initialize the action with. */ config?: _PartialActionConfig; } -/** - * Create a webhook on the github action attached to the Action resource. - * passed in request. Response: [CreateActionWebhookResponse] - */ -export interface CreateActionWebhook { - /** Id or name */ - action: string; -} /** Create an alerter. Response: [Alerter]. */ export interface CreateAlerter { /** The name given to newly created alerter. */ @@ -4929,14 +4911,6 @@ export interface CreateBuild { /** Optional partial config to initialize the build with. */ config?: _PartialBuildConfig; } -/** - * Create a webhook on the github repo attached to the build - * passed in request. Response: [CreateBuildWebhookResponse] - */ -export interface CreateBuildWebhook { - /** Id or name */ - build: string; -} /** Partial representation of [BuilderConfig] */ export type PartialBuilderConfig = { type: "Url"; @@ -5062,21 +5036,6 @@ export interface CreateRepo { /** Optional partial config to initialize the repo with. */ config?: _PartialRepoConfig; } -export declare enum RepoWebhookAction { - Clone = "Clone", - Pull = "Pull", - Build = "Build" -} -/** - * Create a webhook on the github repo attached to the (Komodo) Repo resource. - * passed in request. Response: [CreateRepoWebhookResponse] - */ -export interface CreateRepoWebhook { - /** Id or name */ - repo: string; - /** "Clone" or "Pull" or "Build" */ - action: RepoWebhookAction; -} /** Create a sync. Response: [ResourceSync]. */ export interface CreateResourceSync { /** The name given to newly created sync. */ @@ -5110,34 +5069,6 @@ export interface CreateStack { /** Optional partial config to initialize the stack with. */ config?: _PartialStackConfig; } -export declare enum StackWebhookAction { - Refresh = "Refresh", - Deploy = "Deploy" -} -/** - * Create a webhook on the github repo attached to the stack - * passed in request. Response: [CreateStackWebhookResponse] - */ -export interface CreateStackWebhook { - /** Id or name */ - stack: string; - /** "Refresh" or "Deploy" */ - action: StackWebhookAction; -} -export declare enum SyncWebhookAction { - Refresh = "Refresh", - Sync = "Sync" -} -/** - * Create a webhook on the github repo attached to the sync - * passed in request. Response: [CreateSyncWebhookResponse] - */ -export interface CreateSyncWebhook { - /** Id or name */ - sync: string; - /** "Refresh" or "Sync" */ - action: SyncWebhookAction; -} /** Create a tag. Response: [Tag]. */ export interface CreateTag { /** The name of the tag. */ @@ -5210,14 +5141,6 @@ export interface DeleteAction { /** The id or name of the action to delete. */ id: string; } -/** - * Delete the webhook on the github action attached to the Action resource. - * passed in request. Response: [DeleteActionWebhookResponse] - */ -export interface DeleteActionWebhook { - /** Id or name */ - action: string; -} /** * Deletes the alerter at the given id, and returns the deleted alerter. * Response: [Alerter] @@ -5257,14 +5180,6 @@ export interface DeleteBuild { /** The id or name of the build to delete. */ id: string; } -/** - * Delete a webhook on the github repo attached to the build - * passed in request. Response: [CreateBuildWebhookResponse] - */ -export interface DeleteBuildWebhook { - /** Id or name */ - build: string; -} /** * Deletes the builder at the given id, and returns the deleted builder. * Response: [Builder] @@ -5343,16 +5258,6 @@ export interface DeleteRepo { /** The id or name of the repo to delete. */ id: string; } -/** - * Delete the webhook on the github repo attached to the (Komodo) Repo resource. - * passed in request. Response: [DeleteRepoWebhookResponse] - */ -export interface DeleteRepoWebhook { - /** Id or name */ - repo: string; - /** "Clone" or "Pull" or "Build" */ - action: RepoWebhookAction; -} /** * Deletes the sync at the given id, and returns the deleted sync. * Response: [ResourceSync] @@ -5377,26 +5282,6 @@ export interface DeleteStack { /** The id or name of the stack to delete. */ id: string; } -/** - * Delete the webhook on the github repo attached to the stack - * passed in request. Response: [DeleteStackWebhookResponse] - */ -export interface DeleteStackWebhook { - /** Id or name */ - stack: string; - /** "Refresh" or "Deploy" */ - action: StackWebhookAction; -} -/** - * Delete the webhook on the github repo attached to the sync - * passed in request. Response: [DeleteSyncWebhookResponse] - */ -export interface DeleteSyncWebhook { - /** Id or name */ - sync: string; - /** "Refresh" or "Sync" */ - action: SyncWebhookAction; -} /** * Delete a tag, and return the deleted tag. Response: [Tag]. * @@ -5788,21 +5673,6 @@ export interface GetBuildMonthlyStatsResponse { total_count: number; days: BuildStatsDay[]; } -/** Get whether a Build's target repo has a webhook for the build configured. Response: [GetBuildWebhookEnabledResponse]. */ -export interface GetBuildWebhookEnabled { - /** Id or name */ - build: string; -} -/** Response for [GetBuildWebhookEnabled] */ -export interface GetBuildWebhookEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger build. Will always be false if managed is false. */ - enabled: boolean; -} /** Get a specific builder by id or name. Response: [Builder]. */ export interface GetBuilder { /** Id or name */ @@ -5880,8 +5750,6 @@ export interface GetCoreInfoResponse { disable_non_admin_create: boolean; /** Whether confirm dialog should be disabled */ disable_confirm_dialog: boolean; - /** The repo owners for which github webhook management api is available */ - github_webhook_owners: string[]; /** Whether to disable websocket automatic reconnect. */ disable_websocket_reconnect: boolean; /** Whether to enable fancy toml highlighting. */ @@ -6127,25 +5995,6 @@ export interface GetRepoActionState { /** Id or name */ repo: string; } -/** Get a target Repo's configured webhooks. Response: [GetRepoWebhooksEnabledResponse]. */ -export interface GetRepoWebhooksEnabled { - /** Id or name */ - repo: string; -} -/** Response for [GetRepoWebhooksEnabled] */ -export interface GetRepoWebhooksEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger clone. Will always be false if managed is false. */ - clone_enabled: boolean; - /** Whether pushes to branch trigger pull. Will always be false if managed is false. */ - pull_enabled: boolean; - /** Whether pushes to branch trigger build. Will always be false if managed is false. */ - build_enabled: boolean; -} /** * Gets a summary of data relating to all repos. * Response: [GetReposSummaryResponse]. @@ -6282,23 +6131,6 @@ export interface GetStackLog { /** Enable `--timestamps` */ timestamps?: boolean; } -/** Get a target stack's configured webhooks. Response: [GetStackWebhooksEnabledResponse]. */ -export interface GetStackWebhooksEnabled { - /** Id or name */ - stack: string; -} -/** Response for [GetStackWebhooksEnabled] */ -export interface GetStackWebhooksEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger refresh. Will always be false if managed is false. */ - refresh_enabled: boolean; - /** Whether pushes to branch trigger stack execution. Will always be false if managed is false. */ - deploy_enabled: boolean; -} /** * Gets a summary of data relating to all syncs. * Response: [GetStacksSummaryResponse]. @@ -6320,23 +6152,6 @@ export interface GetStacksSummaryResponse { /** The number of stacks with Unknown state. */ unknown: number; } -/** Get a target Sync's configured webhooks. Response: [GetSyncWebhooksEnabledResponse]. */ -export interface GetSyncWebhooksEnabled { - /** Id or name */ - sync: string; -} -/** Response for [GetSyncWebhooksEnabled] */ -export interface GetSyncWebhooksEnabledResponse { - /** - * Whether the repo webhooks can even be managed. - * The repo owner must be in `github_webhook_app.owners` list to be managed. - */ - managed: boolean; - /** Whether pushes to branch trigger refresh. Will always be false if managed is false. */ - refresh_enabled: boolean; - /** Whether pushes to branch trigger sync execution. Will always be false if managed is false. */ - sync_enabled: boolean; -} /** * Get the system information of the target server. * Response: [SystemInformation]. @@ -8725,9 +8540,6 @@ export type ReadRequest = { } | { type: "GetStackActionState"; params: GetStackActionState; -} | { - type: "GetStackWebhooksEnabled"; - params: GetStackWebhooksEnabled; } | { type: "GetStackLog"; params: GetStackLog; @@ -8800,9 +8612,6 @@ export type ReadRequest = { } | { type: "ListBuildVersions"; params: ListBuildVersions; -} | { - type: "GetBuildWebhookEnabled"; - params: GetBuildWebhookEnabled; } | { type: "ListBuilds"; params: ListBuilds; @@ -8821,9 +8630,6 @@ export type ReadRequest = { } | { type: "GetRepoActionState"; params: GetRepoActionState; -} | { - type: "GetRepoWebhooksEnabled"; - params: GetRepoWebhooksEnabled; } | { type: "ListRepos"; params: ListRepos; @@ -8839,9 +8645,6 @@ export type ReadRequest = { } | { type: "GetResourceSyncActionState"; params: GetResourceSyncActionState; -} | { - type: "GetSyncWebhooksEnabled"; - params: GetSyncWebhooksEnabled; } | { type: "ListResourceSyncs"; params: ListResourceSyncs; @@ -8918,6 +8721,11 @@ export type ReadRequest = { type: "ListOnboardingKeys"; params: ListOnboardingKeys; }; +export declare enum RepoWebhookAction { + Clone = "Clone", + Pull = "Pull", + Build = "Build" +} /** The specific types of permission that a User or UserGroup can have on a resource. */ export declare enum SpecificPermission { /** @@ -8956,6 +8764,14 @@ export declare enum SpecificPermission { */ Processes = "Processes" } +export declare enum StackWebhookAction { + Refresh = "Refresh", + Deploy = "Deploy" +} +export declare enum SyncWebhookAction { + Refresh = "Refresh", + Sync = "Sync" +} export type UserRequest = { type: "PushRecentlyViewed"; params: PushRecentlyViewed; @@ -9083,12 +8899,6 @@ export type WriteRequest = { } | { type: "RefreshStackCache"; params: RefreshStackCache; -} | { - type: "CreateStackWebhook"; - params: CreateStackWebhook; -} | { - type: "DeleteStackWebhook"; - params: DeleteStackWebhook; } | { type: "CreateDeployment"; params: CreateDeployment; @@ -9128,12 +8938,6 @@ export type WriteRequest = { } | { type: "RefreshBuildCache"; params: RefreshBuildCache; -} | { - type: "CreateBuildWebhook"; - params: CreateBuildWebhook; -} | { - type: "DeleteBuildWebhook"; - params: DeleteBuildWebhook; } | { type: "CreateBuilder"; params: CreateBuilder; @@ -9167,12 +8971,6 @@ export type WriteRequest = { } | { type: "RefreshRepoCache"; params: RefreshRepoCache; -} | { - type: "CreateRepoWebhook"; - params: CreateRepoWebhook; -} | { - type: "DeleteRepoWebhook"; - params: DeleteRepoWebhook; } | { type: "CreateAlerter"; params: CreateAlerter; @@ -9242,12 +9040,6 @@ export type WriteRequest = { } | { type: "RefreshResourceSyncPending"; params: RefreshResourceSyncPending; -} | { - type: "CreateSyncWebhook"; - params: CreateSyncWebhook; -} | { - type: "DeleteSyncWebhook"; - params: DeleteSyncWebhook; } | { type: "CreateTag"; params: CreateTag; diff --git a/frontend/public/client/types.js b/frontend/public/client/types.js index 1150e64e1..54279842d 100644 --- a/frontend/public/client/types.js +++ b/frontend/public/client/types.js @@ -568,22 +568,6 @@ export var StackState; /** Server not reachable for status */ StackState["Unknown"] = "unknown"; })(StackState || (StackState = {})); -export var RepoWebhookAction; -(function (RepoWebhookAction) { - RepoWebhookAction["Clone"] = "Clone"; - RepoWebhookAction["Pull"] = "Pull"; - RepoWebhookAction["Build"] = "Build"; -})(RepoWebhookAction || (RepoWebhookAction = {})); -export var StackWebhookAction; -(function (StackWebhookAction) { - StackWebhookAction["Refresh"] = "Refresh"; - StackWebhookAction["Deploy"] = "Deploy"; -})(StackWebhookAction || (StackWebhookAction = {})); -export var SyncWebhookAction; -(function (SyncWebhookAction) { - SyncWebhookAction["Refresh"] = "Refresh"; - SyncWebhookAction["Sync"] = "Sync"; -})(SyncWebhookAction || (SyncWebhookAction = {})); /** * Configures the behavior of [CreateTerminal] if the * specified terminal name already exists. @@ -717,6 +701,12 @@ export var IanaTimezone; /** UTC+14:00 */ IanaTimezone["PacificKiritimati"] = "Pacific/Kiritimati"; })(IanaTimezone || (IanaTimezone = {})); +export var RepoWebhookAction; +(function (RepoWebhookAction) { + RepoWebhookAction["Clone"] = "Clone"; + RepoWebhookAction["Pull"] = "Pull"; + RepoWebhookAction["Build"] = "Build"; +})(RepoWebhookAction || (RepoWebhookAction = {})); /** The specific types of permission that a User or UserGroup can have on a resource. */ export var SpecificPermission; (function (SpecificPermission) { @@ -756,3 +746,13 @@ export var SpecificPermission; */ SpecificPermission["Processes"] = "Processes"; })(SpecificPermission || (SpecificPermission = {})); +export var StackWebhookAction; +(function (StackWebhookAction) { + StackWebhookAction["Refresh"] = "Refresh"; + StackWebhookAction["Deploy"] = "Deploy"; +})(StackWebhookAction || (StackWebhookAction = {})); +export var SyncWebhookAction; +(function (SyncWebhookAction) { + SyncWebhookAction["Refresh"] = "Refresh"; + SyncWebhookAction["Sync"] = "Sync"; +})(SyncWebhookAction || (SyncWebhookAction = {})); diff --git a/frontend/src/components/resources/build/config.tsx b/frontend/src/components/resources/build/config.tsx index 3fccb8af0..0f327db06 100644 --- a/frontend/src/components/resources/build/config.tsx +++ b/frontend/src/components/resources/build/config.tsx @@ -13,7 +13,6 @@ import { } from "@components/config/util"; import { getWebhookIntegration, - useInvalidate, useLocalStorage, usePermissions, useRead, @@ -22,12 +21,10 @@ import { useWrite, } from "@lib/hooks"; import { Types } from "komodo_client"; -import { Ban, CirclePlus, PlusCircle } from "lucide-react"; +import { PlusCircle } from "lucide-react"; import { ReactNode } from "react"; import { CopyWebhook, ResourceLink, ResourceSelector } from "../common"; -import { useToast } from "@ui/use-toast"; -import { text_color_class_by_intention } from "@lib/color"; -import { ConfirmButton, ShowHideButton } from "@components/util"; +import { ShowHideButton } from "@components/util"; import { Link } from "react-router-dom"; import { SecretsSearch } from "@components/config/env_vars"; import { MonacoEditor } from "@components/monaco"; @@ -74,7 +71,6 @@ export const BuildConfig = ({ const build = useRead("GetBuild", { build: id }).data; const config = build?.config; const name = build?.name; - const webhook = useRead("GetBuildWebhookEnabled", { build: id }).data; const global_disabled = useRead("GetCoreInfo", {}).data?.ui_write_disabled ?? false; const [update, set] = useLocalStorage>( @@ -607,72 +603,12 @@ export const BuildConfig = ({ /> ), - webhook_enabled: webhook !== undefined && !webhook.managed, + webhook_enabled: true, webhook_secret: { description: "Provide a custom webhook secret for this resource, or use the global default.", placeholder: "Input custom secret", }, - ["managed" as any]: () => { - const inv = useInvalidate(); - const { toast } = useToast(); - const { mutate: createWebhook, isPending: createPending } = - useWrite("CreateBuildWebhook", { - onSuccess: () => { - toast({ title: "Webhook Created" }); - inv(["GetBuildWebhookEnabled", { build: id }]); - }, - }); - const { mutate: deleteWebhook, isPending: deletePending } = - useWrite("DeleteBuildWebhook", { - onSuccess: () => { - toast({ title: "Webhook Deleted" }); - inv(["GetBuildWebhookEnabled", { build: id }]); - }, - }); - if (!webhook || !webhook.managed) return; - return ( - - {webhook.enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
-
- } - variant="destructive" - onClick={() => deleteWebhook({ build: id })} - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhook.enabled && ( -
-
- Incoming webhook is{" "} -
- DISABLED -
-
- } - onClick={() => createWebhook({ build: id })} - loading={createPending} - disabled={disabled || createPending} - /> -
- )} -
- ); - }, }, }, ], diff --git a/frontend/src/components/resources/repo/config.tsx b/frontend/src/components/resources/repo/config.tsx index 185d06e72..fe8b96507 100644 --- a/frontend/src/components/resources/repo/config.tsx +++ b/frontend/src/components/resources/repo/config.tsx @@ -9,7 +9,6 @@ import { } from "@components/config/util"; import { getWebhookIntegration, - useInvalidate, useLocalStorage, usePermissions, useRead, @@ -19,10 +18,7 @@ import { } from "@lib/hooks"; import { Types } from "komodo_client"; import { CopyWebhook, ResourceLink, ResourceSelector } from "../common"; -import { useToast } from "@ui/use-toast"; -import { text_color_class_by_intention } from "@lib/color"; -import { ConfirmButton } from "@components/util"; -import { Ban, CirclePlus, PlusCircle } from "lucide-react"; +import { PlusCircle } from "lucide-react"; import { Button } from "@ui/button"; import { SecretsSearch } from "@components/config/env_vars"; import { MonacoEditor } from "@components/monaco"; @@ -32,7 +28,6 @@ export const RepoConfig = ({ id }: { id: string }) => { const repo = useRead("GetRepo", { repo: id }).data; const config = repo?.config; const name = repo?.name; - const webhooks = useRead("GetRepoWebhooksEnabled", { repo: id }).data; const global_disabled = useRead("GetCoreInfo", {}).data?.ui_write_disabled ?? false; const [update, set] = useLocalStorage>( @@ -286,186 +281,12 @@ export const RepoConfig = ({ id }: { id: string }) => { /> ), - webhook_enabled: webhooks !== undefined && !webhooks.managed, + webhook_enabled: true, webhook_secret: { description: "Provide a custom webhook secret for this resource, or use the global default.", placeholder: "Input custom secret", }, - ["managed" as any]: () => { - const inv = useInvalidate(); - const { toast } = useToast(); - const { mutate: createWebhook, isPending: createPending } = - useWrite("CreateRepoWebhook", { - onSuccess: () => { - toast({ title: "Webhook Created" }); - inv(["GetRepoWebhooksEnabled", { repo: id }]); - }, - }); - const { mutate: deleteWebhook, isPending: deletePending } = - useWrite("DeleteRepoWebhook", { - onSuccess: () => { - toast({ title: "Webhook Deleted" }); - inv(["GetRepoWebhooksEnabled", { repo: id }]); - }, - }); - if (!webhooks || !webhooks.managed) return; - return ( - - {webhooks.clone_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- CLONE -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - repo: id, - action: Types.RepoWebhookAction.Clone, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhooks.clone_enabled && webhooks.pull_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- PULL -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - repo: id, - action: Types.RepoWebhookAction.Pull, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {webhooks.build_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- BUILD -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - repo: id, - action: Types.RepoWebhookAction.Build, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhooks.clone_enabled && - !webhooks.pull_enabled && - !webhooks.build_enabled && ( -
-
- Incoming webhook is{" "} -
- DISABLED -
-
- {(update.server_id ?? config.server_id) && ( - } - onClick={() => - createWebhook({ - repo: id, - action: Types.RepoWebhookAction.Clone, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> - )} - {(update.server_id ?? config.server_id) && ( - } - onClick={() => - createWebhook({ - repo: id, - action: Types.RepoWebhookAction.Pull, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> - )} - {(update.builder_id ?? config.builder_id) && ( - } - onClick={() => - createWebhook({ - repo: id, - action: Types.RepoWebhookAction.Build, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> - )} -
- )} -
- ); - }, }, }, { diff --git a/frontend/src/components/resources/resource-sync/config.tsx b/frontend/src/components/resources/resource-sync/config.tsx index 157147bbf..045461e2e 100644 --- a/frontend/src/components/resources/resource-sync/config.tsx +++ b/frontend/src/components/resources/resource-sync/config.tsx @@ -9,7 +9,6 @@ import { } from "@components/config/util"; import { getWebhookIntegration, - useInvalidate, useLocalStorage, usePermissions, useRead, @@ -20,10 +19,7 @@ import { import { Types } from "komodo_client"; import { ReactNode } from "react"; import { CopyWebhook, TagSelector } from "../common"; -import { useToast } from "@ui/use-toast"; -import { text_color_class_by_intention } from "@lib/color"; -import { ConfirmButton, ShowHideButton } from "@components/util"; -import { Ban, CirclePlus } from "lucide-react"; +import { ShowHideButton } from "@components/util"; import { MonacoEditor } from "@components/monaco"; import { Select, @@ -67,7 +63,6 @@ export const ResourceSyncConfig = ({ const sync = useRead("GetResourceSync", { sync: id }).data; const config = sync?.config; const name = sync?.name; - const webhooks = useRead("GetSyncWebhooksEnabled", { sync: id }).data; const global_disabled = useRead("GetCoreInfo", {}).data?.ui_write_disabled ?? false; const [update, set] = useLocalStorage>( @@ -373,127 +368,12 @@ export const ResourceSyncConfig = ({ /> ), - webhook_enabled: webhooks !== undefined && !webhooks.managed, + webhook_enabled: true, webhook_secret: { description: "Provide a custom webhook secret for this resource, or use the global default.", placeholder: "Input custom secret", }, - ["managed" as any]: () => { - const inv = useInvalidate(); - const { toast } = useToast(); - const { mutate: createWebhook, isPending: createPending } = useWrite( - "CreateSyncWebhook", - { - onSuccess: () => { - toast({ title: "Webhook Created" }); - inv(["GetSyncWebhooksEnabled", { sync: id }]); - }, - } - ); - const { mutate: deleteWebhook, isPending: deletePending } = useWrite( - "DeleteSyncWebhook", - { - onSuccess: () => { - toast({ title: "Webhook Deleted" }); - inv(["GetSyncWebhooksEnabled", { sync: id }]); - }, - } - ); - if (!webhooks || !webhooks.managed) return; - return ( - - {webhooks.sync_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- SYNC EXECUTION -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - sync: id, - action: Types.SyncWebhookAction.Sync, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhooks.sync_enabled && webhooks.refresh_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- PENDING REFRESH -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - sync: id, - action: Types.SyncWebhookAction.Refresh, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhooks.sync_enabled && !webhooks.refresh_enabled && ( -
-
- Incoming webhook is{" "} -
- DISABLED -
-
- } - onClick={() => - createWebhook({ - sync: id, - action: Types.SyncWebhookAction.Refresh, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> - } - onClick={() => - createWebhook({ - sync: id, - action: Types.SyncWebhookAction.Sync, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> -
- )} -
- ); - }, }, }; components = { diff --git a/frontend/src/components/resources/stack/config.tsx b/frontend/src/components/resources/stack/config.tsx index 2af22c910..14efd02cd 100644 --- a/frontend/src/components/resources/stack/config.tsx +++ b/frontend/src/components/resources/stack/config.tsx @@ -13,7 +13,6 @@ import { import { Types } from "komodo_client"; import { getWebhookIntegration, - useInvalidate, useLocalStorage, usePermissions, useRead, @@ -31,14 +30,10 @@ import { SelectValue, } from "@ui/select"; import { SecretsSearch } from "@components/config/env_vars"; -import { ConfirmButton, ShowHideButton } from "@components/util"; +import { ShowHideButton } from "@components/util"; import { MonacoEditor } from "@components/monaco"; -import { useToast } from "@ui/use-toast"; -import { text_color_class_by_intention } from "@lib/color"; import { - Ban, ChevronsUpDown, - CirclePlus, MinusCircle, PlusCircle, SearchX, @@ -94,7 +89,6 @@ export const StackConfig = ({ const stack = useRead("GetStack", { stack: id }).data; const config = stack?.config; const name = stack?.name; - const webhooks = useRead("GetStackWebhooksEnabled", { stack: id }).data; const global_disabled = useRead("GetCoreInfo", {}).data?.ui_write_disabled ?? false; const [update, set] = useLocalStorage>( @@ -713,140 +707,12 @@ export const StackConfig = ({ description: "Usually the Stack won't deploy unless there are changes to the files. Use this to force deploy.", }, - webhook_enabled: - !!(update.branch ?? config.branch) && - webhooks !== undefined && - !webhooks.managed, + webhook_enabled: true, webhook_secret: { description: "Provide a custom webhook secret for this resource, or use the global default.", placeholder: "Input custom secret", }, - ["managed" as any]: () => { - const inv = useInvalidate(); - const { toast } = useToast(); - const { mutate: createWebhook, isPending: createPending } = - useWrite("CreateStackWebhook", { - onSuccess: () => { - toast({ title: "Webhook Created" }); - inv(["GetStackWebhooksEnabled", { stack: id }]); - }, - }); - const { mutate: deleteWebhook, isPending: deletePending } = - useWrite("DeleteStackWebhook", { - onSuccess: () => { - toast({ title: "Webhook Deleted" }); - inv(["GetStackWebhooksEnabled", { stack: id }]); - }, - }); - - if ( - !(update.branch ?? config.branch) || - !webhooks || - !webhooks.managed - ) { - return null; - } - - return ( - - {webhooks.deploy_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- DEPLOY -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - stack: id, - action: Types.StackWebhookAction.Deploy, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhooks.deploy_enabled && webhooks.refresh_enabled && ( -
-
- Incoming webhook is{" "} -
- ENABLED -
- and will trigger -
- REFRESH -
-
- } - variant="destructive" - onClick={() => - deleteWebhook({ - stack: id, - action: Types.StackWebhookAction.Refresh, - }) - } - loading={deletePending} - disabled={disabled || deletePending} - /> -
- )} - {!webhooks.deploy_enabled && !webhooks.refresh_enabled && ( -
-
- Incoming webhook is{" "} -
- DISABLED -
-
- } - onClick={() => - createWebhook({ - stack: id, - action: Types.StackWebhookAction.Deploy, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> - } - onClick={() => - createWebhook({ - stack: id, - action: Types.StackWebhookAction.Refresh, - }) - } - loading={createPending} - disabled={disabled || createPending} - /> -
- )} -
- ); - }, }, }, ],