Skip to content

fix: `INSTALLATION FAILED: Can't evaluate field ApiVersion#71

Open
fResult wants to merge 1 commit into
tim-koehler:masterfrom
fResult:fix/chart-api-version-cannot-be-evaluated
Open

fix: `INSTALLATION FAILED: Can't evaluate field ApiVersion#71
fResult wants to merge 1 commit into
tim-koehler:masterfrom
fResult:fix/chart-api-version-cannot-be-evaluated

Conversation

@fResult
Copy link
Copy Markdown

@fResult fResult commented Sep 21, 2024

From the issue #70.
Fixed an error INSTALLATION FAILED: Can't evaluate field ApiVersion in type interface {}.

After updating code result:
image

P.S. Indeed, if it can be more than 1 specific key, we might be able to do something like this.

// NOTE: Some keys are not just a PascalCase, they can be...
const SPECIAL_KEY_REPLACEMENT: Record<string, string> = {
    apiVersion: 'APIVersion',
    SpecialKey1: 'SPECIALKey1',
    SpecialKey2: 'SPECIALKey2',
    // More special key goes here...
}

export class ChartCompletionItemProvider implements vscode.CompletionItemProvider {
    .
    .
    private getCompletionItemList(currentKey: any): vscode.CompletionItem[] {
        const keys = [];
        for (const key in currentKey) {
            switch (typeof currentKey[key]) {
                .
                .
                case 'number':
                    // NOTE: APIVersion is a special case, as it is not camelCase for `{{ .Chart.APIVersion }}`.
                    const specialText = SPECIAL_KEY_REPLACEMENT[key]
                    const completionText = specialText ?? key.charAt(0).toUpperCase() + key.slice(1);
                    const valueItem = new vscode.CompletionItem(completionText, vscode.CompletionItemKind.Field);
                    valueItem.detail = currentKey[key].toString();
                    keys.push(valueItem);
                    break;
            }
        }
    }
}

@fResult fResult force-pushed the fix/chart-api-version-cannot-be-evaluated branch from 1ac055d to ed17293 Compare September 21, 2024 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant