-
Notifications
You must be signed in to change notification settings - Fork 208
/
file_parameter.go
50 lines (42 loc) · 1.86 KB
/
file_parameter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cnab
const (
// FileParameterExtensionShortHand is the short suffix of the FileParameterExtensionKey.
FileParameterExtensionShortHand = "file-parameters"
// FileParameterExtensionKey represents the full key for the File Parameter extension.
// This uses the legacy porter domain and cannot be changed to use our new domain.
// Going forward extensions should use org.getporter instead.
FileParameterExtensionKey = "sh.porter." + FileParameterExtensionShortHand
)
// FileParameterExtension represents a required extension that indicates that the bundle
// requires support for parameters of type "file"
var FileParameterExtension = RequiredExtension{
Shorthand: FileParameterExtensionShortHand,
Key: FileParameterExtensionKey,
Reader: FileParameterReader,
}
// FileParameterReader is a Reader for the FileParameterExtension.
// The extension does not have any data, its presence indicates that
// parameters of type "file" should be supported by the tooling.
func FileParameterReader(b ExtendedBundle) (interface{}, error) {
return b.FileParameterReader()
}
// FileParameterReader is a Reader for the FileParameterExtension.
// The extension does not have any data, its presence indicates that
// parameters of type "file" should be supported by the tooling.
func (b ExtendedBundle) FileParameterReader() (interface{}, error) {
return nil, nil
}
// SupportsFileParameters checks if the bundle supports file parameters.
func (b ExtendedBundle) SupportsFileParameters() bool {
if b.SupportsExtension(FileParameterExtensionKey) {
return true
}
// Porter has always supported this but didn't have the extension declared.
return b.IsPorterBundle()
}
// FileParameterSupport checks if the file parameter extension
// is present.
func (e ProcessedExtensions) FileParameterSupport() bool {
_, extensionRequired := e[FileParameterExtensionKey]
return extensionRequired
}