capitalize file type strings

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman 2021-03-26 17:32:17 -04:00
parent 772613647c
commit 8551168702
No known key found for this signature in database
GPG Key ID: 5CB45AE22BAB7EA7
2 changed files with 18 additions and 16 deletions

View File

@ -1,33 +1,35 @@
package source package source
import "archive/tar"
const ( const (
UnknownFileType FileType = "unknownFileType" UnknownFileType FileType = "UnknownFileType"
RegularFile FileType = "regularFile" RegularFile FileType = "RegularFile"
HardLink FileType = "hardLink" HardLink FileType = "HardLink"
SymbolicLink FileType = "symbolicLink" SymbolicLink FileType = "SymbolicLink"
CharacterDevice FileType = "characterDevice" CharacterDevice FileType = "CharacterDevice"
BlockDevice FileType = "blockDevice" BlockDevice FileType = "BlockDevice"
Directory FileType = "directory" Directory FileType = "Directory"
FIFONode FileType = "fifoNode" FIFONode FileType = "FIFONode"
) )
type FileType string type FileType string
func newFileTypeFromTarHeaderTypeFlag(flag byte) FileType { func newFileTypeFromTarHeaderTypeFlag(flag byte) FileType {
switch flag { switch flag {
case '0', '\x00': case tar.TypeReg, tar.TypeRegA:
return RegularFile return RegularFile
case '1': case tar.TypeLink:
return HardLink return HardLink
case '2': case tar.TypeSymlink:
return SymbolicLink return SymbolicLink
case '3': case tar.TypeChar:
return CharacterDevice return CharacterDevice
case '4': case tar.TypeBlock:
return BlockDevice return BlockDevice
case '5': case tar.TypeDir:
return Directory return Directory
case '6': case tar.TypeFifo:
return FIFONode return FIFONode
} }
return UnknownFileType return UnknownFileType

View File

@ -26,7 +26,7 @@ func TestPowerUserCmdFlags(t *testing.T) {
args: []string{"power-user", request}, args: []string{"power-user", request},
assertions: []traitAssertion{ assertions: []traitAssertion{
assertNotInOutput(" command is deprecated"), // only the root command should be deprecated assertNotInOutput(" command is deprecated"), // only the root command should be deprecated
assertInOutput(`"type": "regularFile"`), // proof of file-metadata data assertInOutput(`"type": "RegularFile"`), // proof of file-metadata data
assertInOutput(`"algorithm": "sha256"`), // proof of file-metadata default digest algorithm of sha256 assertInOutput(`"algorithm": "sha256"`), // proof of file-metadata default digest algorithm of sha256
assertInOutput(`"metadataType": "ApkMetadata"`), // proof of package artifacts data assertInOutput(`"metadataType": "ApkMetadata"`), // proof of package artifacts data
assertSuccessfulReturnCode, assertSuccessfulReturnCode,