@@ -37,7 +37,7 @@ def build_service_binding_k8s
37
37
@service_bindings . select ( &:create_succeeded? ) . each do |service_binding |
38
38
sb_hash = ServiceBindingPresenter . new ( service_binding , include_instance : true ) . to_hash
39
39
name = sb_hash [ :name ]
40
- raise IncompatibleBindings . new ( "Invalid binding name: '#{ name } '. Name must match #{ binding_naming_convention . inspect } " ) unless valid_name ?( name )
40
+ raise IncompatibleBindings . new ( "Invalid binding name: '#{ name } '. Name must match #{ binding_naming_convention . inspect } " ) unless valid_binding_name ?( name )
41
41
raise IncompatibleBindings . new ( "Duplicate binding name: #{ name } " ) if names . add? ( name ) . nil?
42
42
43
43
# add the credentials first
@@ -72,13 +72,17 @@ def binding_naming_convention
72
72
/^[a-z0-9\- .]{1,253}$/
73
73
end
74
74
75
+ def file_naming_convention
76
+ /^[a-z0-9\- ._]{1,253}$/
77
+ end
78
+
75
79
# - adds a Diego::Bbs::Models::File object to the service_binding_files hash
76
80
# - binding name is used as the directory name, key is used as the file name
77
81
# - returns the bytesize of the path and content
78
82
# - skips (and returns 0) if the value is nil or an empty array or hash
79
83
# - serializes the value to JSON if it is a non-string object
80
84
def add_file ( service_binding_files , name , key , value )
81
- raise IncompatibleBindings . new ( "Invalid file name: #{ key } " ) unless valid_name ?( key )
85
+ raise IncompatibleBindings . new ( "Invalid file name: #{ key } " ) unless valid_file_name ?( key )
82
86
83
87
path = "#{ name } /#{ key } "
84
88
content = if value . nil?
@@ -95,10 +99,14 @@ def add_file(service_binding_files, name, key, value)
95
99
path . bytesize + content . bytesize
96
100
end
97
101
98
- def valid_name ?( name )
102
+ def valid_binding_name ?( name )
99
103
name . match? ( binding_naming_convention )
100
104
end
101
105
106
+ def valid_file_name? ( name )
107
+ name . match? ( file_naming_convention )
108
+ end
109
+
102
110
def transform_vcap_services_attribute ( name )
103
111
if %w[ binding_guid binding_name instance_guid instance_name syslog_drain_url volume_mounts ] . include? ( name )
104
112
name . tr ( '_' , '-' )
0 commit comments