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