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

View File

@ -26,7 +26,7 @@ func TestPowerUserCmdFlags(t *testing.T) {
args: []string{"power-user", request},
assertions: []traitAssertion{
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(`"metadataType": "ApkMetadata"`), // proof of package artifacts data
assertSuccessfulReturnCode,