-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace odo analyze command #4330
Merged
datho7561
merged 17 commits into
redhat-developer:main
from
msivasubramaniaan:added-alizer-analyze-command
Aug 16, 2024
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3f34d5c
chaged the image path and removed (formerly Red Hat CodeReady Contain…
msivasubramaniaan 23e0616
removed odo analyze command
msivasubramaniaan 1b01f49
Merge branch 'main' into added-alizer-analyze-command
msivasubramaniaan 6338174
addressed review comments
msivasubramaniaan 8a9264e
added alizer test
msivasubramaniaan f8dcc69
fixed no-unused-vars error
msivasubramaniaan 71031a3
fixed no-unused-vars error
msivasubramaniaan 265507d
fixed no-unused-vars error
msivasubramaniaan e42fd0c
fixed no-unused-vars error
msivasubramaniaan 3be7b53
fixed no-unused-vars error
msivasubramaniaan c614dd5
fixed no-unused-vars error
msivasubramaniaan 6a3ca0b
fixed test case fails
msivasubramaniaan e105c2d
added deleteComponentConfiguration
msivasubramaniaan ddbb56b
fixed mapping component description
msivasubramaniaan f57469b
Merge branch 'main' into added-alizer-analyze-command
msivasubramaniaan c82fa22
addressed review comments
msivasubramaniaan 7b2a13b
addressed review comments
msivasubramaniaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/*----------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*-----------------------------------------------------------------------------------------------*/ | ||
|
||
import { CommandText } from '../base/command'; | ||
import { CliChannel } from '../cli'; | ||
import { Uri } from 'vscode'; | ||
import { CliExitData } from '../util/childProcessUtil'; | ||
import { AlizerAnalyzeResponse } from './types'; | ||
|
||
/** | ||
* A wrapper around the `alizer` CLI tool. | ||
* | ||
* This class is a stateless singleton. | ||
* This makes it easier to stub its methods than if it were a bunch of directly exported functions. | ||
*/ | ||
export class Alizer { | ||
private static INSTANCE = new Alizer(); | ||
|
||
static get Instance() { | ||
return Alizer.INSTANCE; | ||
} | ||
|
||
public async alizerAnalyze(currentFolderPath: Uri): Promise<AlizerAnalyzeResponse> { | ||
const cliData: CliExitData = await CliChannel.getInstance().executeTool( | ||
new CommandText('alizer', `devfile ${currentFolderPath.fsPath}`), undefined, false | ||
); | ||
if (cliData.error || cliData.stderr.length > 0) { | ||
return undefined; | ||
} | ||
const parse = JSON.parse(cliData.stdout) as AlizerAnalyzeResponse[]; | ||
return parse[0]; | ||
} | ||
} |
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,19 @@ | ||
/*----------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*-----------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
interface Version { | ||
SchemaVersion: number; | ||
Default: boolean; | ||
Version: string; | ||
} | ||
|
||
export interface AlizerAnalyzeResponse { | ||
Name: string; | ||
Language: string; | ||
ProjectType: string; | ||
Tags: string[]; | ||
Versions: Version[]; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { Uri, workspace } from 'vscode'; | |
import { Oc } from '../../src/oc/ocWrapper'; | ||
import { Odo } from '../../src/odo/odoWrapper'; | ||
import { LoginUtil } from '../../src/util/loginUtil'; | ||
import { Alizer } from '../../src/alizer/alizerWrapper'; | ||
|
||
suite('./odo/odoWrapper.ts', function () { | ||
const isOpenShift: boolean = Boolean(parseInt(process.env.IS_OPENSHIFT, 10)) || false; | ||
|
@@ -100,12 +101,12 @@ suite('./odo/odoWrapper.ts', function () { | |
}); | ||
|
||
test('analyze()', async function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @msivasubramaniaan The |
||
const analysis1 = await Odo.Instance.analyze(tmpFolder1.fsPath); | ||
const analysis1 = await Alizer.Instance.alizerAnalyze(tmpFolder1); | ||
expect(analysis1).to.exist; | ||
expect(analysis1[0].devfile).to.equal('nodejs'); | ||
const analysis2 = await Odo.Instance.analyze(tmpFolder2.fsPath); | ||
expect(analysis1[0].Name).to.equal('nodejs'); | ||
const analysis2 = await Alizer.Instance.alizerAnalyze(tmpFolder2); | ||
expect(analysis2).to.exist; | ||
expect(analysis2[0].devfile).to.equal('go'); | ||
expect(analysis2[0].Name).to.equal('go'); | ||
}); | ||
}); | ||
|
||
|
@@ -208,9 +209,8 @@ suite('./odo/odoWrapper.ts', function () { | |
}); | ||
|
||
test('analyze()', async function() { | ||
const [analysis] = await Odo.Instance.analyze(tmpFolder); | ||
expect(analysis.name).to.equal(path.basename(tmpFolder).toLocaleLowerCase()); | ||
expect(analysis.devfile).to.equal(COMPONENT_TYPE); | ||
const analysis = await Alizer.Instance.alizerAnalyze(Uri.file(tmpFolder)); | ||
expect(analysis.Name).to.equal(COMPONENT_TYPE); | ||
}); | ||
|
||
test('deleteComponentConfiguration()', async function() { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
is the same as
If you find the first version easier to understand feel free to keep it, but I personally tend to prefer the second version.