@@ -207,31 +207,75 @@ func resourceTencentCloudScfFunction() *schema.Resource {
207207 "cos_bucket_name" : {
208208 Type : schema .TypeString ,
209209 Optional : true ,
210- ConflictsWith : []string {"zip_file" },
210+ ConflictsWith : []string {"zip_file" , "image_config" },
211211 Description : "Cos bucket name of the SCF function, such as `cos-1234567890`, conflict with `zip_file`." ,
212212 },
213213 "cos_object_name" : {
214214 Type : schema .TypeString ,
215215 Optional : true ,
216- ConflictsWith : []string {"zip_file" },
216+ ConflictsWith : []string {"zip_file" , "image_config" },
217217 ValidateFunc : validateStringSuffix (".zip" , ".jar" ),
218218 Description : "Cos object name of the SCF function, should have suffix `.zip` or `.jar`, conflict with `zip_file`." ,
219219 },
220220 "cos_bucket_region" : {
221221 Type : schema .TypeString ,
222222 Optional : true ,
223- ConflictsWith : []string {"zip_file" },
223+ ConflictsWith : []string {"zip_file" , "image_config" },
224224 Description : "Cos bucket region of the SCF function, conflict with `zip_file`." ,
225225 },
226226
227227 // zip upload
228228 "zip_file" : {
229229 Type : schema .TypeString ,
230230 Optional : true ,
231- ConflictsWith : []string {"cos_bucket_name" , "cos_object_name" , "cos_bucket_region" },
231+ ConflictsWith : []string {"cos_bucket_name" , "cos_object_name" , "cos_bucket_region" , "image_config" },
232232 Description : "Zip file of the SCF function, conflict with `cos_bucket_name`, `cos_object_name`, `cos_bucket_region`." ,
233233 },
234234
235+ // image
236+ "image_config" : {
237+ Type : schema .TypeList ,
238+ Optional : true ,
239+ ConflictsWith : []string {"cos_bucket_name" , "cos_object_name" , "cos_bucket_region" , "zip_file" },
240+ Description : "Image of the SCF function, conflict with ``." ,
241+ Elem : & schema.Resource {
242+ Schema : map [string ]* schema.Schema {
243+ "image_type" : {
244+ Type : schema .TypeString ,
245+ Required : true ,
246+ ValidateFunc : validateAllowedStringValue ([]string {"personal" , "enterprise" }),
247+ Description : "The image type. personal or enterprise." ,
248+ },
249+ "image_uri" : {
250+ Type : schema .TypeString ,
251+ Required : true ,
252+ Description : "The uri of image." ,
253+ },
254+ "registry_id" : {
255+ Type : schema .TypeString ,
256+ Optional : true ,
257+ Description : "The registry id of TCR. When image type is enterprise, it must be set." ,
258+ },
259+ "entry_point" : {
260+ Type : schema .TypeString ,
261+ Optional : true ,
262+ Description : "The entrypoint of app." ,
263+ },
264+ "command" : {
265+ Type : schema .TypeString ,
266+ Optional : true ,
267+ Description : "The command of entrypoint." ,
268+ },
269+ "args" : {
270+ Type : schema .TypeString ,
271+ Optional : true ,
272+ Description : "the parameters of command." ,
273+ },
274+
275+ },
276+ },
277+ },
278+
235279 "triggers" : {
236280 Type : schema .TypeSet ,
237281 Optional : true ,
@@ -423,6 +467,7 @@ func resourceTencentCloudScfFunctionCreate(d *schema.ResourceData, m interface{}
423467 const (
424468 scfFunctionCosCode scfFunctionCodeType = iota + 1 // start at 1 so we can check if codeType set or not
425469 scfFunctionZipFileCode
470+ scfFunctionImageCode
426471 )
427472
428473 var codeType scfFunctionCodeType
@@ -496,14 +541,42 @@ func resourceTencentCloudScfFunctionCreate(d *schema.ResourceData, m interface{}
496541 functionInfo .zipFile = & content
497542 }
498543
544+ var imageConfigs = make ([]* scf.ImageConfig , 0 )
545+
546+ if raw , ok := d .GetOk ("image_config" ); ok {
547+ configs := raw .([]interface {})
548+ for _ , v := range configs {
549+ value := v .(map [string ]interface {})
550+ imageType := value ["image_type" ].(string )
551+ imageUri := value ["image_uri" ].(string )
552+ registryId := value ["registry_id" ].(string )
553+ entryPoint := value ["entry_point" ].(string )
554+ command := value ["command" ].(string )
555+ args := value ["args" ].(string )
556+
557+ config := & scf.ImageConfig {
558+ ImageType : & imageType ,
559+ ImageUri : & imageUri ,
560+ RegistryId : & registryId ,
561+ EntryPoint : & entryPoint ,
562+ Command : & command ,
563+ Args : & args ,
564+ }
565+ imageConfigs = append (imageConfigs , config )
566+ }
567+ codeType = scfFunctionImageCode
568+ }
569+
570+ functionInfo .imageConfig = imageConfigs [0 ]
571+
499572 switch codeType {
500573 case scfFunctionCosCode :
501574 if err := helper .CheckIfSetTogether (d , "cos_bucket_name" , "cos_object_name" , "cos_bucket_region" ); err != nil {
502575 return err
503576 }
504577
505578 case scfFunctionZipFileCode :
506-
579+ case scfFunctionImageCode :
507580 default :
508581 return errors .New ("no function code set" )
509582 }
@@ -764,6 +837,34 @@ func resourceTencentCloudScfFunctionUpdate(d *schema.ResourceData, m interface{}
764837 functionInfo .zipFile = & content
765838 }
766839
840+ if d .HasChange ("image_config" ) {
841+ updateAttrs = append (updateAttrs , "image_config" )
842+ if raw , ok := d .GetOk ("image_config" ); ok {
843+ var imageConfigs = make ([]* scf.ImageConfig , 0 )
844+ configs := raw .([]interface {})
845+ for _ , v := range configs {
846+ value := v .(map [string ]interface {})
847+ imageType := value ["image_type" ].(string )
848+ imageUri := value ["image_uri" ].(string )
849+ registryId := value ["registry_id" ].(string )
850+ entryPoint := value ["entry_point" ].(string )
851+ command := value ["command" ].(string )
852+ args := value ["args" ].(string )
853+
854+ config := & scf.ImageConfig {
855+ ImageType : & imageType ,
856+ ImageUri : & imageUri ,
857+ RegistryId : & registryId ,
858+ EntryPoint : & entryPoint ,
859+ Command : & command ,
860+ Args : & args ,
861+ }
862+ imageConfigs = append (imageConfigs , config )
863+ }
864+ functionInfo .imageConfig = imageConfigs [0 ]
865+ }
866+ }
867+
767868 // update function code
768869 if len (updateAttrs ) > 0 {
769870 if len (updateAttrs ) == 0 && updateAttrs [0 ] == "handler" {
0 commit comments