Skip to content

Commit

Permalink
feat: default to podman v5 for new users
Browse files Browse the repository at this point in the history
if you have an existing podman installation, you need to enable
a flag but without a previous podman installation you can
install v5

fixes podman-desktop#6523
Signed-off-by: Florent Benoit <[email protected]>
  • Loading branch information
benoitf committed Mar 27, 2024
1 parent 3fcdb8e commit 0bd8f73
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
27 changes: 27 additions & 0 deletions extensions/podman/src/podman-install.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,33 @@ describe('getBundledPodmanVersion', () => {
// should have called the get with the property for experimental install
expect(getMock).toHaveBeenCalledWith('experimental.install.v5');
});

test('should return the podman 5 version if experimental podman 5 flag is not enabled but first install', async () => {
vi.mocked(extensionApi.configuration.getConfiguration).mockReset();
const getMock = vi.fn();
getMock.mockReturnValue(false);

// exist sync is false
vi.mock('node:fs');
vi.mocked(fs.existsSync).mockReturnValue(false);

vi.mocked(extensionApi.configuration.getConfiguration).mockReturnValue({
get: getMock,
has: vi.fn(),
update: vi.fn(),
});
const version = getBundledPodmanVersion();
expect(version.startsWith('4')).toBeFalsy();
expect(version.startsWith('5')).toBeTruthy();

// check existSync has been called
expect(vi.mocked(fs.existsSync)).toHaveBeenCalled();

// check first argument of the call to getMock
expect(getMock).toHaveBeenCalled();
// should have called the get with the property for experimental install
expect(getMock).toHaveBeenCalledWith('experimental.install.v5');
});
});

class TestPodmanInstall extends PodmanInstall {
Expand Down
10 changes: 9 additions & 1 deletion extensions/podman/src/podman-install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ export function getBundledPodmanVersion(): string {
.getConfiguration('podman')
.get<boolean>(PODMAN5_EXPERIMENTAL_MODE_CONFIG_KEY);

if (podman5ExperimentalModeEnabled) {
// also check if the user has never installed podman (for example there is no configuration folder for Podman)
// no ~/.config/containers/podman and ~/.local/share/containers/podman folders on Windows or macOS
let noPreviousPodmanInstallation = false;
if (extensionApi.env.isWindows || extensionApi.env.isMac) {
noPreviousPodmanInstallation =
!fs.existsSync(path.resolve(os.homedir(), '.config/containers/podman')) &&
!fs.existsSync(path.resolve(os.homedir(), '.local/share/containers/podman'));
}
if (podman5ExperimentalModeEnabled || noPreviousPodmanInstallation) {
return podman5JSON.version;
}

Expand Down

0 comments on commit 0bd8f73

Please sign in to comment.