-
Notifications
You must be signed in to change notification settings - Fork 85
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
[v3] Zos files attributes #2319
Merged
Merged
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
52cb3f1
poc
jace-roell 9d45406
start unit test
jace-roell dc7028a
changelog, fixed existing unit tests
jace-roell 9ac3e76
changelog
jace-roell 4b291d6
unit test and snapshot
jace-roell ad41911
snapshot
jace-roell 6ec2809
system tests
jace-roell ddbaa20
system test
jace-roell d024149
fixed unintentionally changed file
jace-roell e5cef09
removed unused variables in previous tests
jace-roell 764d533
exit shell line
jace-roell cdcb02e
removed unused function
jace-roell eb489d7
unused import
jace-roell 5717a75
Merge branch 'master' into zos-files-attributes
awharn 1403c08
Merge branch 'master' into zos-files-attributes
jace-roell 7eeddb7
expanded on encodingCheck.txt file, consolidated import lines, privat…
jace-roell 761d960
duplicate import lines
jace-roell 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
8 changes: 6 additions & 2 deletions
8
...es/__integration__/upload/ftu/__snapshots__/cli.files.upload.ftu.integration.test.ts.snap
Large diffs are not rendered by default.
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
27 changes: 27 additions & 0 deletions
27
.../__tests__/zosfiles/__unit__/upload/ftu/__snapshots__/FileToUSS.handler.unit.test.ts.snap
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
91 changes: 71 additions & 20 deletions
91
packages/cli/src/zosfiles/upload/ftu/FileToUSS.handler.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 |
---|---|---|
@@ -1,42 +1,93 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
* | ||
*/ | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
* | ||
*/ | ||
|
||
import { AbstractSession, IHandlerParameters, ITaskWithStatus, TaskStage, TextUtils } from "@zowe/imperative"; | ||
import { | ||
AbstractSession, | ||
IHandlerParameters, | ||
ITaskWithStatus, | ||
TaskStage, | ||
TextUtils, | ||
} from "@zowe/imperative"; | ||
import { Upload, IZosFilesResponse } from "@zowe/zos-files-for-zowe-sdk"; | ||
import { ZosFilesBaseHandler } from "../../ZosFilesBase.handler"; | ||
import { IUploadOptions } from "@zowe/zos-files-for-zowe-sdk"; | ||
import { ZosFilesAttributes } from "@zowe/zos-files-for-zowe-sdk"; | ||
jace-roell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { IUploadMap } from "@zowe/zos-files-for-zowe-sdk"; | ||
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved
Hide resolved
|
||
|
||
/** | ||
* Handler to upload content from a local file to a USS file | ||
* @export | ||
*/ | ||
export default class FileToUSSHandler extends ZosFilesBaseHandler { | ||
public async processWithSession(commandParameters: IHandlerParameters, | ||
session: AbstractSession): Promise<IZosFilesResponse> { | ||
public async processWithSession( | ||
commandParameters: IHandlerParameters, | ||
session: AbstractSession | ||
): Promise<IZosFilesResponse> { | ||
const task: ITaskWithStatus = { | ||
percentComplete: 0, | ||
statusMessage: "Uploading USS file", | ||
stageName: TaskStage.IN_PROGRESS | ||
stageName: TaskStage.IN_PROGRESS, | ||
}; | ||
commandParameters.response.progress.startBar({ task }); | ||
|
||
const response = await Upload.fileToUssFile(session, commandParameters.arguments.inputfile, | ||
commandParameters.arguments.USSFileName, { | ||
binary: commandParameters.arguments.binary, | ||
encoding: commandParameters.arguments.encoding, | ||
task, | ||
responseTimeout: commandParameters.arguments.responseTimeout | ||
}); | ||
const uploadOptions: IUploadOptions = { | ||
binary: commandParameters.arguments.binary, | ||
maxConcurrentRequests: | ||
commandParameters.arguments.maxConcurrentRequests, | ||
task: task, | ||
responseTimeout: commandParameters.arguments.responseTimeout, | ||
includeHidden: commandParameters.arguments.includeHidden, | ||
}; | ||
|
||
const attributes = ZosFilesAttributes.loadFromFile( | ||
commandParameters.arguments.attributes, | ||
commandParameters.arguments.inputDir | ||
); | ||
if (attributes != null) { | ||
uploadOptions.attributes = attributes; | ||
} else { | ||
uploadOptions.filesMap = this.buildFilesMap(commandParameters); | ||
} | ||
|
||
const response = await Upload.uploadFile( | ||
session, | ||
commandParameters.arguments.inputfile, | ||
commandParameters.arguments.USSFileName, | ||
uploadOptions | ||
); | ||
|
||
const formatMessage = TextUtils.prettyJson(response.apiResponse); | ||
commandParameters.response.console.log(formatMessage); | ||
return response; | ||
} | ||
private buildFilesMap(commandParameters: IHandlerParameters) { | ||
let filesMap: IUploadMap = null; | ||
|
||
// checking if binary-files or ascii-files are used, and update filesMap argument | ||
if (commandParameters.arguments.binaryFiles) { | ||
jace-roell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
filesMap = { | ||
binary: true, | ||
fileNames: commandParameters.arguments.binaryFiles | ||
.split(",") | ||
.map((fileName: string) => fileName.trim()), | ||
}; | ||
} | ||
if (commandParameters.arguments.asciiFiles) { | ||
filesMap = { | ||
binary: false, | ||
fileNames: commandParameters.arguments.asciiFiles | ||
.split(",") | ||
.map((fileName: string) => fileName.trim()), | ||
}; | ||
} | ||
return filesMap; | ||
} | ||
} |
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
Oops, something went wrong.
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.
curious how this happens since running
npm run build
seems to take those extra spaces away 🤔This makes me wonder if we should implement prettier (or similar tools) as pre-commit hooks (like husky) 😋
👀 @t1m0thyj, any thoughts?
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 saying that this needs to be updated as part of this PR 😋