-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare secret storage host binary for 0.2.7 release
- Loading branch information
1 parent
69e224e
commit d9f40aa
Showing
7 changed files
with
210 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// From secrets.yaml | ||
|
||
import { v1 } from "@docker/extension-api-client-types"; | ||
import { CatalogItemWithName } from "./components/PromptCard"; | ||
|
||
namespace Secrets { | ||
export type Secret = { | ||
name: string; | ||
value: string; | ||
policies: string[]; | ||
} | ||
|
||
export type StoredSecret = { | ||
name: string; | ||
policies: string[]; | ||
} | ||
|
||
export type Policy = { | ||
name: string; | ||
images: string[]; | ||
} | ||
|
||
export async function getSecrets(client: v1.DockerDesktopClient): Promise<Secret[]> { | ||
const response = await client.extension.host?.cli.exec('host-binary', ['list']); | ||
return JSON.parse(response?.stdout || '[]'); | ||
} | ||
|
||
export async function addSecret(client: v1.DockerDesktopClient, secret: Secret): Promise<void> { | ||
const response = await client.extension.host?.cli.exec('host-binary', ['add', secret.name, secret.value]); | ||
console.log(response); | ||
} | ||
|
||
// Get all relevant secrets for a given set of catalog items | ||
export function getAllSecretNames(catalogItems: CatalogItemWithName[]): string[] { | ||
return catalogItems.map((item) => item.secrets || []).flat().map((secret) => secret.name); | ||
} | ||
|
||
// Whether or not each secret has been assigned for a given catalog item | ||
export function getAssignedSecrets(catalogItem: CatalogItemWithName, secrets: Secret[]): { name: string, assigned: boolean }[] { | ||
return catalogItem.secrets?.map((secret) => ({ name: secret.name, assigned: secrets.some((s) => s.name === secret.name) })) || []; | ||
} | ||
} | ||
|
||
export default Secrets; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.