Skip to content

Commit

Permalink
fix: workaround dockerode incorrect auth config encoding
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Golovin <[email protected]>
  • Loading branch information
dgolovin committed Jul 12, 2023
1 parent e21e76a commit 4b43336
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
},
"dependencies": {
"@kubernetes/client-node": "^0.18.1",
"@podman-desktop/api": "^0.15.0",
"@podman-desktop/api": "^1.1.0",
"base64url": "^3.0.1",
"fs-extra": "^10.1.0",
"got": "^12.6.0",
"js-yaml": "^4.1.0"
Expand Down
8 changes: 7 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import { KubeConfig } from '@kubernetes/client-node';
import * as extensionApi from '@podman-desktop/api';
import base64url from 'base64url';
import got from 'got';
import * as kubeconfig from './kubeconfig';

Expand Down Expand Up @@ -151,7 +152,12 @@ export async function pushImageToOpenShiftRegistry(image: ImageInfo): Promise<vo
resolve(undefined);
}
},
{ password: registryInfo.token, username: registryInfo.username, serveraddress: registryInfo.host },
// To work correctly docker-modem >v3.0.3 should be used to encode auth config using base64url
// Upgrading docker-modem to required version leads to segfaut during the build
// { username: registryInfo.username, password: registryInfo.token, serveraddress: registryInfo.host },

// Manual encoding required to avoid image push error for
{ base64: base64url(JSON.stringify({ username: registryInfo.username, password: registryInfo.token, serveraddress: registryInfo.host }))} as any as extensionApi.AuthConfig,
);
} catch (err: unknown) {
reject(err);
Expand Down
13 changes: 9 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,10 @@
optionalDependencies:
openid-client "^5.3.0"

"@podman-desktop/api@^0.15.0":
version "0.15.0"
resolved "https://registry.npmjs.org/@podman-desktop/api/-/api-0.15.0.tgz"
integrity sha512-ZK/nr5MUgSeG65d51oagh0WjLhatLeWjfuj6JHG+WHEjHyNT3xLtRj1033IM64p2PHHKTazh5TTOqZjQ1ijhhQ==
"@podman-desktop/api@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@podman-desktop/api/-/api-1.1.0.tgz#b1f6441cf68cda03bce1030ef9622168b397a50a"
integrity sha512-hwoPZjLkT1fIMG2IXkTSwK1Xnl381/YfM0vEQHXsT2pA36j8MiloOn4PeoCynk+wZPO5jLJUccOS7WFrqC5xeg==

"@sindresorhus/is@^5.2.0":
version "5.3.0"
Expand Down Expand Up @@ -286,6 +286,11 @@ balanced-match@^1.0.0:
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==

base64url@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/base64url/-/base64url-3.0.1.tgz#6399d572e2bc3f90a9a8b22d5dbb0a32d33f788d"
integrity sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==

bcrypt-pbkdf@^1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz"
Expand Down

0 comments on commit 4b43336

Please sign in to comment.