Skip to content

Commit 408228b

Browse files
committed
Replace Current.allowBuildTriggers() with @dependency
1 parent db2509c commit 408228b

File tree

6 files changed

+340
-317
lines changed

6 files changed

+340
-317
lines changed

Sources/App/Commands/TriggerBuilds.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
import Dependencies
1516
import Fluent
1617
import PostgresKit
1718
import SQLKit
@@ -175,7 +176,8 @@ func triggerBuilds(on database: Database,
175176
client: Client,
176177
packages: [Package.Id],
177178
force: Bool = false) async throws {
178-
guard Current.allowBuildTriggers() else {
179+
@Dependency(\.environment) var environment
180+
guard environment.allowBuildTriggers() else {
179181
Current.logger().info("Build trigger override switch OFF - no builds are being triggered")
180182
return
181183
}

Sources/App/Core/AppEnvironment.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import FoundationNetworking
2323

2424

2525
struct AppEnvironment: Sendable {
26-
var allowBuildTriggers: @Sendable () -> Bool
2726
var allowTwitterPosts: @Sendable () -> Bool
2827
var apiSigningKey: @Sendable () -> String?
2928
var appVersion: @Sendable () -> String?
@@ -111,11 +110,6 @@ extension AppEnvironment {
111110
nonisolated(unsafe) static var logger: Logger!
112111

113112
static let live = AppEnvironment(
114-
allowBuildTriggers: {
115-
Environment.get("ALLOW_BUILD_TRIGGERS")
116-
.flatMap(\.asBool)
117-
?? Constants.defaultAllowBuildTriggering
118-
},
119113
allowTwitterPosts: {
120114
Environment.get("ALLOW_TWITTER_POSTS")
121115
.flatMap(\.asBool)

Sources/App/Core/Dependencies/EnvironmentClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Vapor
2121
struct EnvironmentClient {
2222
// See https://swiftpackageindex.com/pointfreeco/swift-dependencies/main/documentation/dependenciesmacros/dependencyclient()#Restrictions
2323
// regarding the use of XCTFail here.
24-
var allowBuildTriggers: @Sendable () -> Bool = { XCTFail(#function); return false }
24+
var allowBuildTriggers: @Sendable () -> Bool = { XCTFail(#function); return true }
2525
}
2626

2727

0 commit comments

Comments
 (0)