-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: node updates (must manually check for updates) (#613)
* feat: check for node updates. only checking part completed * release notes url. update detailed changes modal start * checkin: rename check to getCheckForControllerUpdate. modal ready for spec diff message * check-in: add node spec diff tool and modal with changes * feat: appy node update with result notification * injectDefaultControllerConfig for controllers * fix client update notifications. client release urls * cleanup controller api and add env var * couple missing js endings on file imports * feat: developer mode for dev info in app
- Loading branch information
Showing
45 changed files
with
1,089 additions
and
108 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
52 changes: 52 additions & 0 deletions
52
src/common/node-spec-tool/injectDefaultControllerConfig.ts
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,52 @@ | ||
import type { | ||
NodeSpecification, | ||
DockerExecution as PodmanExecution, | ||
} from '../nodeSpec.js'; | ||
|
||
/** | ||
* Injects default controller configuration (cliInput, serviceVersion, etc.) | ||
* into the nodeSpec. It does NOT overwrite existing values. | ||
* Always updated is the default serviceVersion value to spec.excution.defaultImageTag | ||
* For example, if `cliInput` is defined, it does NOT get overwritten. | ||
* @param nodeSpec | ||
*/ | ||
export const injectDefaultControllerConfig = (nodeSpec: NodeSpecification) => { | ||
// "inject" serviceVersion and dataDir (todo) here. Universal for all nodes. | ||
const execution = nodeSpec.execution as PodmanExecution; | ||
let defaultImageTag = 'latest'; | ||
// if the defaultImageTag is set in the spec use that, otherwise 'latest' | ||
if (execution.defaultImageTag !== undefined) { | ||
defaultImageTag = execution.defaultImageTag; | ||
} | ||
|
||
if (!nodeSpec.configTranslation) { | ||
nodeSpec.configTranslation = {}; | ||
} | ||
|
||
if (!nodeSpec.configTranslation.cliInput) { | ||
nodeSpec.configTranslation.cliInput = { | ||
displayName: `${nodeSpec.displayName} CLI input`, | ||
uiControl: { | ||
type: 'text', | ||
}, | ||
defaultValue: '', | ||
addNodeFlow: 'advanced', | ||
infoDescription: 'Additional CLI input', | ||
}; | ||
} | ||
if (!nodeSpec.configTranslation.serviceVersion) { | ||
nodeSpec.configTranslation.serviceVersion = { | ||
displayName: `${nodeSpec.displayName} version`, | ||
uiControl: { | ||
type: 'text', | ||
}, | ||
defaultValue: defaultImageTag, | ||
addNodeFlow: 'advanced', | ||
infoDescription: | ||
'Possible values: latest, v1.0.0, or stable. Check service documenation.', | ||
}; | ||
} | ||
|
||
// always update the default serviceVersion value to the latest excution.defaultImageTag | ||
nodeSpec.configTranslation.serviceVersion.defaultValue = defaultImageTag; | ||
}; |
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,118 @@ | ||
import type { SelectControl, SelectTranslation } from '../nodeConfig.js'; | ||
import type { DockerExecution, NodeSpecification } from '../nodeSpec.js'; | ||
import { assert, compareObjects } from './util.js'; | ||
|
||
export type UserSpecDiff = { | ||
message: string; | ||
}; | ||
|
||
// Only time a user default would be overridden is if the user default is not in the new spec as | ||
// an option on a select config. In that case, the default should be used. So we should highlight any | ||
// removal of select options. | ||
// returns a list of changes | ||
export const calcUserSpecDiff = ( | ||
oldSpec: NodeSpecification, | ||
newSpec: NodeSpecification, | ||
): UserSpecDiff[] => { | ||
assert(oldSpec.specId === newSpec.specId, 'specId mismatch'); | ||
assert( | ||
oldSpec.version < newSpec.version, | ||
'newSpec version is not greater than oldSpec version', | ||
); | ||
|
||
const diffs: UserSpecDiff[] = []; | ||
diffs.push({ | ||
message: `Controller version: ${oldSpec.version} -> ${newSpec.version}`, | ||
}); | ||
if (oldSpec.displayName !== newSpec.displayName) { | ||
diffs.push({ | ||
message: `Name: ${oldSpec.displayName} -> ${newSpec.displayName}`, | ||
}); | ||
} | ||
|
||
/////// [start] Execution | ||
const oldSpecExecution = oldSpec.execution as DockerExecution; | ||
const newSpecExecution = newSpec.execution as DockerExecution; | ||
if (oldSpecExecution.imageName !== newSpecExecution.imageName) { | ||
diffs.push({ | ||
message: `Download URL: ${oldSpecExecution.imageName} -> ${newSpecExecution.imageName}`, | ||
}); | ||
} | ||
if (oldSpecExecution.defaultImageTag !== newSpecExecution.defaultImageTag) { | ||
diffs.push({ | ||
message: `${newSpec.displayName} Version: ${oldSpecExecution.defaultImageTag} -> ${newSpecExecution.defaultImageTag}`, | ||
}); | ||
} | ||
/////// [end] Execution | ||
|
||
/////// [start] System Requirements | ||
const oldSysReq = oldSpec.systemRequirements; | ||
const newSysReq = newSpec.systemRequirements; | ||
if (!compareObjects(oldSysReq, newSysReq)) { | ||
let oldSysReqString = ''; | ||
let newSysReqString = ''; | ||
if (!compareObjects(oldSysReq?.cpu, newSysReq?.cpu)) { | ||
oldSysReqString += ` CPU: ${JSON.stringify(oldSysReq?.cpu)}`; | ||
newSysReqString += ` CPU: ${JSON.stringify(newSysReq?.cpu)}`; | ||
} | ||
if (!compareObjects(oldSysReq?.memory, newSysReq?.memory)) { | ||
oldSysReqString += ` Memory: ${JSON.stringify(oldSysReq?.memory)}`; | ||
newSysReqString += ` Memory: ${JSON.stringify(newSysReq?.memory)}`; | ||
} | ||
if (!compareObjects(oldSysReq?.storage, newSysReq?.storage)) { | ||
oldSysReqString += ` Storage: ${JSON.stringify(oldSysReq?.storage)}`; | ||
newSysReqString += ` Storage: ${JSON.stringify(newSysReq?.storage)}`; | ||
} | ||
if (!compareObjects(oldSysReq?.internet, newSysReq?.internet)) { | ||
oldSysReqString += ` Internet: ${JSON.stringify(oldSysReq?.internet)}`; | ||
newSysReqString += ` Internet: ${JSON.stringify(newSysReq?.internet)}`; | ||
} | ||
|
||
diffs.push({ | ||
message: `System requirements: ${oldSysReqString} -> ${newSysReqString}`, | ||
}); | ||
} | ||
/////// [end] System Requirements | ||
|
||
/////// [start] Config Tralsations | ||
const oldTranslations = oldSpec.configTranslation ?? {}; | ||
const newTranslations = newSpec.configTranslation ?? {}; | ||
const oldTranslationKeys = Object.keys(oldTranslations); | ||
const newTranslationKeys = Object.keys(newTranslations); | ||
for (const key of oldTranslationKeys) { | ||
if (!newTranslationKeys.includes(key)) { | ||
diffs.push({ | ||
message: `Removed setting: ${oldTranslations[key]?.displayName}`, | ||
}); | ||
} else { | ||
if (oldTranslations[key]?.uiControl?.type.includes('select')) { | ||
const oldSelectOptions = ( | ||
oldTranslations[key].uiControl as SelectControl | ||
)?.controlTranslations as SelectTranslation[]; | ||
const newSelectOptions = ( | ||
newTranslations[key].uiControl as SelectControl | ||
)?.controlTranslations as SelectTranslation[]; | ||
if (!compareObjects(oldSelectOptions, newSelectOptions)) { | ||
diffs.push({ | ||
message: `Changed setting options: ${JSON.stringify( | ||
oldSelectOptions, | ||
)} -> ${JSON.stringify(newSelectOptions)}`, | ||
}); | ||
} | ||
} | ||
|
||
// else, they're the same | ||
} | ||
} | ||
for (const key of newTranslationKeys) { | ||
if (!oldTranslationKeys.includes(key)) { | ||
diffs.push({ | ||
message: `New setting: ${newTranslations[key]?.displayName}`, | ||
}); | ||
} | ||
// else, they were compared when iterating over oldTranslationKeys | ||
} | ||
/////// [end] Config Tralsations | ||
|
||
return diffs; | ||
}; |
Oops, something went wrong.