Skip to content

Commit

Permalink
use starlark run package id again
Browse files Browse the repository at this point in the history
  • Loading branch information
tedim52 committed Apr 30, 2024
1 parent 59d12fe commit f06a88e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type EnclavesState = {
starlarkRunsByEnclave: Record<string, Result<GetStarlarkRunResponse, string>>;
starlarkRunningInEnclaves: RemoveFunctions<EnclaveInfo>[];
enclaveInitialSubmissionData: Record<string, Record<string, any>>;
enclaveInitialPackageId: Record<string, string>;

// Methods
refreshEnclaves: () => Promise<Result<RemoveFunctions<EnclaveInfo>[], string>>;
Expand Down Expand Up @@ -89,7 +88,6 @@ export const EnclavesContextProvider = ({ skipInitialLoad, children }: EnclavesC
starlarkRunsByEnclave: {},
starlarkRunningInEnclaves: [],
enclaveInitialSubmissionData: {},
enclaveInitialPackageId: {},
});
const kurtosisClient = useKurtosisClient();

Expand Down Expand Up @@ -255,10 +253,6 @@ export const EnclavesContextProvider = ({ skipInitialLoad, children }: EnclavesC
...state,
enclaveInitialSubmissionData: { ...state.enclaveInitialSubmissionData, [enclave.shortenedUuid]: args },
}));
setState((state) => ({
...state,
enclaveInitialPackageId: { ...state.enclaveInitialPackageId, [enclave.shortenedUuid]: packageId },
}));
assertDefined(enclave.apiContainerInfo, `apic info not defined in enclave ${enclave.name}`);
const resp = await kurtosisClient.runStarlarkPackage(enclave.apiContainerInfo, packageId, args, dryRun);
return resp;
Expand Down Expand Up @@ -344,7 +338,6 @@ export const useFullEnclave = (enclaveUUID: string): Result<EnclaveFullInfo, str
filesAndArtifactsByEnclave,
starlarkRunsByEnclave,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
refreshServices,
refreshStarlarkRun,
refreshFilesAndArtifacts,
Expand All @@ -356,7 +349,6 @@ export const useFullEnclave = (enclaveUUID: string): Result<EnclaveFullInfo, str
const filesAndArtifacts = filesAndArtifactsByEnclave[enclaveUUID];
const starlarkRun = starlarkRunsByEnclave[enclaveUUID];
const initialSubmissionData = enclaveInitialSubmissionData[enclaveUUID];
const initialPackageId = enclaveInitialPackageId[enclaveUUID];

const result = useMemo<Result<EnclaveFullInfo, string>>(() => {
if (!isDefined(enclave)) {
Expand All @@ -373,7 +365,6 @@ export const useFullEnclave = (enclaveUUID: string): Result<EnclaveFullInfo, str
filesAndArtifacts,
starlarkRun,
initialSubmissionData,
initialPackageId,
});
}, [
enclaveUUID,
Expand All @@ -383,7 +374,6 @@ export const useFullEnclave = (enclaveUUID: string): Result<EnclaveFullInfo, str
filesAndArtifacts,
starlarkRun,
initialSubmissionData,
initialPackageId,
]);

useEffect(() => {
Expand Down Expand Up @@ -414,7 +404,6 @@ export const useFullEnclaves = (): Result<EnclaveFullInfo[], string> => {
filesAndArtifactsByEnclave,
starlarkRunsByEnclave,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
refreshServices,
refreshStarlarkRun,
refreshFilesAndArtifacts,
Expand Down Expand Up @@ -474,7 +463,6 @@ export const useFullEnclaves = (): Result<EnclaveFullInfo[], string> => {
filesAndArtifacts: cachedFilesAndArtifactsByEnclave[enclave.shortenedUuid],
starlarkRun: cachedStarlarkRunsByEnclave[enclave.shortenedUuid],
initialSubmissionData: enclaveInitialSubmissionData[enclave.shortenedUuid],
initialPackageId: enclaveInitialPackageId[enclave.shortenedUuid],
})),
),
[
Expand All @@ -483,7 +471,6 @@ export const useFullEnclaves = (): Result<EnclaveFullInfo[], string> => {
cachedStarlarkRunsByEnclave,
cachedFilesAndArtifactsByEnclave,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
],
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export const KurtosisEnclavesBreadcrumbs = ({ matches }: KurtosisEnclavesBreadcr
servicesByEnclave,
starlarkRunningInEnclaves,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
} = useEnclavesContext();

const matchCrumbs = useMemo(
Expand All @@ -41,7 +40,6 @@ export const KurtosisEnclavesBreadcrumbs = ({ matches }: KurtosisEnclavesBreadcr
servicesByEnclave,
starlarkRunningInEnclaves,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
},
match.params,
);
Expand All @@ -57,7 +55,6 @@ export const KurtosisEnclavesBreadcrumbs = ({ matches }: KurtosisEnclavesBreadcr
servicesByEnclave,
starlarkRunningInEnclaves,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
],
);

Expand All @@ -74,7 +71,6 @@ export const KurtosisEnclavesBreadcrumbs = ({ matches }: KurtosisEnclavesBreadcr
servicesByEnclave,
starlarkRunningInEnclaves,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
},
match.params,
)
Expand All @@ -89,10 +85,8 @@ export const KurtosisEnclavesBreadcrumbs = ({ matches }: KurtosisEnclavesBreadcr
starlarkRunsByEnclave,
servicesByEnclave,
starlarkRunningInEnclaves,
enclaveInitialSubmissionData,
enclaveInitialPackageId,
],
);
enclaveInitialSubmissionData
]);

return <KurtosisBreadcrumbsImpl matchCrumbs={matchCrumbs} extraControls={extraControls} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ type EnclaveTableRow = {
};

const enclaveToRow = (enclave: EnclaveFullInfo, catalog?: Result<GetPackagesResponse, string>): EnclaveTableRow => {
const starlarkRun = enclave.starlarkRun;
return {
uuid: enclave.shortenedUuid,
name: enclave.name,
status: enclave.containersStatus,
created: enclave.creationTime ? DateTime.fromJSDate(enclave.creationTime.toDate()) : null,
source: !isDefined(catalog)
? "loading"
: catalog.isOk
? catalog.value.packages.find((kurtosisPackage) => kurtosisPackage.name === enclave.initialPackageId) || null
: null,
source:
!isDefined(starlarkRun) || !isDefined(catalog)
? "loading"
: starlarkRun.isOk && catalog.isOk
? catalog.value.packages.find((kurtosisPackage) => kurtosisPackage.name === starlarkRun.value.packageId) || null
: null,
services: !isDefined(enclave.services)
? "loading"
: enclave.services.isOk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,9 @@ export const SetImageModel = ({ isOpen, onClose, currentImage, serviceName, encl
return;
}

if (!enclave.initialPackageId) {
setError("Error: No package id found that was run in this enclave.");
return;
}
const packageId = enclave.initialPackageId;
const packageId = starlarkRun.value.packageId;

const initialArgs = objectToStarlark(enclave.initialSubmissionData, 8);
console.log(enclave.initialSubmissionData);
console.log(`initial args used to start package:\n${initialArgs}`);

const updateImageStarlarkScript = `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ export type EnclaveFullInfo = RemoveFunctions<EnclaveInfo> & {
services?: Result<RemoveFunctions<GetServicesResponse>, string>;
filesAndArtifacts?: Result<RemoveFunctions<ListFilesArtifactNamesAndUuidsResponse>, string>;
initialSubmissionData?: Record<string, any>;
initialPackageId?: string;
};

0 comments on commit f06a88e

Please sign in to comment.