Skip to content

Commit f13e106

Browse files
authored
Add make target to fetch the default kernel (apple#33)
Replaces the `--install-dependencies` flag with the `(enable/disable)-kernel-install` flag. If the flag is not passed - the default behavior is prompting the user for a response. Also adds a make target `install-kernel` ``` ➜ bin/container system start Verifying apiserver is running... Installing base container filesystem... No default kernel configured. Install the recommended default kernel from [https://github.com/kata-containers/kata-containers/releases/download/3.17.0/kata-static-3.17.0-arm64.tar.xz]? [Y/n]: n Please use the `container system kernel set --recommended` command to configure the default kernel ➜ bin/container system start --disable-kernel-install Verifying apiserver is running... ➜ bin/container system start --enable-kernel-install Verifying apiserver is running... Installing kernel... ➜ bin/container system start --help USAGE: container system start ... [--enable-kernel-install] [--disable-kernel-install] ... --enable-kernel-install/--disable-kernel-install Specify if the default kernel should be installed or not. ``` --------- Signed-off-by: Aditya Ramani <a_ramani@apple.com>
1 parent c4ae517 commit f13e106

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

.github/workflows/common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- name: Test the container project
6464
run: |
6565
launchctl setenv HTTP_PROXY $HTTP_PROXY
66-
make test integration
66+
make test cleancontent install-kernel integration
6767
env:
6868
CONTAINER_REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6969
CONTAINER_REGISTRY_USER: ${{ github.actor }}

Makefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,18 @@ dsym:
128128
test:
129129
@$(SWIFT) test -c $(BUILD_CONFIGURATION) $(CURRENT_SDK_ARGS) --skip TestCLI
130130

131+
.PHONY: install-kernel
132+
install-kernel:
133+
@bin/container system stop || true
134+
@bin/container system start --enable-kernel-install
135+
131136
.PHONY: integration
132-
integration: cleancontent init-block
137+
integration: init-block
133138
@echo Ensuring apiserver stopped before the CLI integration tests...
134139
@bin/container system stop
135140
@scripts/ensure-container-stopped.sh
136141
@echo Running the integration tests...
137-
@bin/container system start --install-dependencies
142+
@bin/container system start
138143
@echo "Removing any existing containers"
139144
@bin/container rm --all
140145
@echo "Starting CLI integration tests"

Sources/CLI/System/SystemStart.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ extension Application {
3434
@Flag(name: .long, help: "Enable debug logging for the runtime daemon.")
3535
var debug = false
3636

37-
@Flag(name: .long, help: "Do not prompt for confirmation before installing runtime dependencies")
38-
var installDependencies: Bool = false
37+
@Flag(
38+
name: .long, inversion: .prefixedEnableDisable,
39+
help: "Specify whether the default kernel should be installed or not. The default behavior is to prompt the user for a response.")
40+
var kernelInstall: Bool?
3941

4042
func run() async throws {
4143
// Without the true path to the binary in the plist, `container-apiserver` won't launch properly.
@@ -110,16 +112,23 @@ extension Application {
110112
let defaultKernelURL = kernelDependency.source
111113
let defaultKernelBinaryPath = ClientDefaults.get(key: .defaultKernelBinaryPath)
112114

113-
print("No default kernel configured.")
114-
print("Install the recommended default kernel from [\(kernelDependency.source)]? [Y/n]: ", terminator: "")
115-
if !installDependencies {
115+
var shouldInstallKernel = false
116+
if kernelInstall == nil {
117+
print("No default kernel configured.")
118+
print("Install the recommended default kernel from [\(kernelDependency.source)]? [Y/n]: ", terminator: "")
116119
guard let read = readLine(strippingNewline: true) else {
117120
throw ContainerizationError(.internalError, message: "Failed to read user input")
118121
}
119122
guard read.lowercased() == "y" || read.count == 0 else {
120123
print("Please use the `container system kernel set --recommended` command to configure the default kernel")
121124
return
122125
}
126+
shouldInstallKernel = true
127+
} else {
128+
shouldInstallKernel = kernelInstall ?? false
129+
}
130+
guard shouldInstallKernel else {
131+
return
123132
}
124133
print("Installing kernel...")
125134
try await KernelSet.downloadAndInstallWithProgressBar(tarRemoteURL: defaultKernelURL, kernelFilePath: defaultKernelBinaryPath)

0 commit comments

Comments
 (0)