-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Adding support for function #156
Conversation
51cc60c
to
d702a7d
Compare
@@ -59,4 +89,4 @@ | |||
} | |||
} | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a new line here.
Please do not merge without adding tests. |
src/functions/function-type.ts
Outdated
@@ -3,10 +3,23 @@ | |||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | |||
*-----------------------------------------------------------------------------------------------*/ | |||
|
|||
import * as vscode from 'vscode'; | |||
import { WorkspaceFolder } from 'vscode'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why import all and a specific thing?
a2e1b24
to
3e14a77
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I provide wrong docker image name(with not valid docker registry path), build pass successfully but when I run deploy I got Deploying Function...
notification which load never replace with error notification.
Another feedback, I think we need to stream logs on function build
command, as that process can take a while, and I as user want to track build progress.
package.json
Outdated
@@ -382,4 +420,4 @@ | |||
} | |||
} | |||
} | |||
} | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add new line.
src/functions/function-tree-view.ts
Outdated
if (functionCheck.test(result.stdout)) { | ||
return [new FunctionNodeImpl(null, 'No Function Found', FunctionContextType.NONE, TreeItemCollapsibleState.None, null)]; | ||
} | ||
window.showErrorMessage(`Fail to parse Json Error: ${getStderrString(error)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this error when my cluster doesn't contains any functions. The func
CLI ignore -o json
and provide output:
No functions found
null
for func list -o json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the func cli
version they have done changes in the output.
apple@Apples-MacBook-Pro vscode-knative % func list -o json
No functions found in knative-serving namespace
apple@Apples-MacBook-Pro vscode-knative % ~/.vs-func/func list -o json
No functions found
null
I think we can run the build and deploy command on the terminal so that we can see the stream logs |
@sudhirverma can you please have a look at the failed GH builds, if we can fix them. |
@mohitsuman @sudhirverma Fixes for failing builds could be solved in #148. |
Rebase this PR please. |
Codecov Report
@@ Coverage Diff @@
## main #156 +/- ##
==========================================
- Coverage 96.55% 93.73% -2.82%
==========================================
Files 51 70 +19
Lines 2233 2841 +608
Branches 336 452 +116
==========================================
+ Hits 2156 2663 +507
- Misses 77 178 +101
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i started playing with it. The major problem i faced is that it asks me to download cli
s (kubectl and func) multiple times.
E.g I have a function opened in workspace, it is displayed fine on the tree.
I create a new function using the wizard and open it in same workspace, the tree is not refreshed correctly and i notice it asks me to download the cli again... but i already downloaded it before otherwise it would not have worked.
src/cli/cli-config.ts
Outdated
// Change the file permissions if on Linux or Mac | ||
if (Platform.OS !== 'win32') { | ||
fs.chmodSync(toolCacheLocation, 0o755); | ||
} else { | ||
fs.chmodSync(toolCacheLocation, '+x'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure about it... is it executing chmod necessary in windows? isn't .exe already executable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it only read and write -rw-r--r--@ 1 apple staff 66777600 Dec 20 18:18 func_windows_amd64.exe
import { CliCommand, CmdCli, createCliCommand } from './cmdCli'; | ||
|
||
function funcCliCommand(cmdArguments: string[]): CliCommand { | ||
return createCliCommand('func', ...cmdArguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be func.exe in windows?
src/cli/cli-config.ts
Outdated
if (toolDlLocation.endsWith('.zip') || toolDlLocation.endsWith('.tar.gz')) { | ||
await Archive.unzip( | ||
toolDlLocation, | ||
path.resolve(Platform.getUserHomePath(), cliFile), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't you use toolCacheLocation
as the other else if branch and merge both?
src/cli/cli-config.ts
Outdated
@@ -67,41 +64,10 @@ async function getVersion(location: string): Promise<string> { | |||
if (cmd === 'kubectl') { | |||
version = KubectlAPI.getKubectlVersion(location); | |||
} | |||
if (cmd === 'func') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Putting this here as i can't comment above but it's about line ~48.
The interface Config
is
export interface Config {
cmd?: CliConfig;
kn?: CliConfig;
kubectl?: CliConfig;
}
Why cmd?
? What does that represent?
Shouldn't you add func?: CliConfig
there as well?
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
startTelemetry(extensionContext); | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
setCommandContext(CommandContext.funcDisableRun, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add it? I cannot find any way to change it to true, missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for localFunctionsEnablement context or node
it will be disabled and always false.
id: string, | ||
items: ValidatorResponseItem[], | ||
): ValidatorResponse { | ||
if (fs.existsSync(pathValue) && pathValue) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not this be the opposite order? So if pathValue is null you don't execute existsSync?
} | ||
if (context.functionStatus === FunctionStatus.CLUSTERLOCALBOTH || context.functionStatus === FunctionStatus.LOCALONLY) { | ||
const funcYaml = path.join(context.contextPath.fsPath, 'func.yaml'); | ||
await fsExtra.remove(funcYaml); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you deleting the function locally? Maybe users want to delete it on the current namespace only.
I would completely remove the delete
action for local functions. What are we going to delete? Only the func.yaml
? All the code? How can we decide? If users wants to delete something locally they can do it manually or we need to be extra clear about what we are going to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will wait till we get confirmation on what should we do with the local function whether we should delete the function or not.
if (!context) { | ||
return null; | ||
} | ||
await knExecutor.executeInTerminal(FuncAPI.runFunc(context.contextPath.fsPath)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add a guard for contextPath or it contains a valid value in all cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it will contain the valid value I will test it on windows.
src/functions/function-type.ts
Outdated
} | ||
|
||
export interface Namespace { | ||
Kind?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need Kind?
src/functions/functionsExplorer.ts
Outdated
async reveal(item: FunctionNode): Promise<void> { | ||
await this.refresh(item.getParent()); | ||
await this.treeView.reveal(item); | ||
await this.treeView.reveal(item); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this row is a duplicate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix: #155
Fix: #165
Fix: #166
Fix: #159