@@ -46,6 +46,14 @@ func ResourceNamespace() *schema.Resource {
4646 Optional : true ,
4747 Description : "The description of the container namespace" ,
4848 },
49+ "tags" : {
50+ Type : schema .TypeList ,
51+ Elem : & schema.Schema {
52+ Type : schema .TypeString ,
53+ },
54+ Optional : true ,
55+ Description : "List of tags [\" tag1\" , \" tag2\" , ...] attached to the container namespace" ,
56+ },
4957 "environment_variables" : {
5058 Type : schema .TypeMap ,
5159 Optional : true ,
@@ -97,14 +105,21 @@ func ResourceContainerNamespaceCreate(ctx context.Context, d *schema.ResourceDat
97105 return diag .FromErr (err )
98106 }
99107
100- ns , err := api . CreateNamespace ( & container.CreateNamespaceRequest {
108+ createReq := & container.CreateNamespaceRequest {
101109 Description : types .ExpandStringPtr (d .Get ("description" ).(string )),
102110 EnvironmentVariables : types .ExpandMapPtrStringString (d .Get ("environment_variables" )),
103111 SecretEnvironmentVariables : expandContainerSecrets (d .Get ("secret_environment_variables" )),
104112 Name : types .ExpandOrGenerateString (d .Get ("name" ).(string ), "ns" ),
105113 ProjectID : d .Get ("project_id" ).(string ),
106114 Region : region ,
107- }, scw .WithContext (ctx ))
115+ }
116+
117+ rawTag , tagExist := d .GetOk ("tags" )
118+ if tagExist {
119+ createReq .Tags = types .ExpandStrings (rawTag )
120+ }
121+
122+ ns , err := api .CreateNamespace (createReq , scw .WithContext (ctx ))
108123 if err != nil {
109124 return diag .FromErr (err )
110125 }
@@ -135,6 +150,7 @@ func ResourceContainerNamespaceRead(ctx context.Context, d *schema.ResourceData,
135150 }
136151
137152 _ = d .Set ("description" , types .FlattenStringPtr (ns .Description ))
153+ _ = d .Set ("tags" , types .FlattenSliceString (ns .Tags ))
138154 _ = d .Set ("environment_variables" , ns .EnvironmentVariables )
139155 _ = d .Set ("name" , ns .Name )
140156 _ = d .Set ("organization_id" , ns .OrganizationID )
@@ -166,6 +182,10 @@ func ResourceContainerNamespaceUpdate(ctx context.Context, d *schema.ResourceDat
166182 req .Description = types .ExpandUpdatedStringPtr (d .Get ("description" ))
167183 }
168184
185+ if d .HasChange ("tags" ) {
186+ req .Tags = types .ExpandUpdatedStringsPtr (d .Get ("tags" ))
187+ }
188+
169189 if d .HasChanges ("environment_variables" ) {
170190 req .EnvironmentVariables = types .ExpandMapPtrStringString (d .Get ("environment_variables" ))
171191 }
0 commit comments