Skip to content

Commit d96b2d4

Browse files
authored
Add workspaceId to policy_yaml (#629)
Signed-off-by: Eswar Rajan Subramanian <eswar@accuknox.com>
1 parent 9c436a7 commit d96b2d4

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

src/networkpolicy/networkPolicy.go

+16-14
Original file line numberDiff line numberDiff line change
@@ -2247,13 +2247,14 @@ func writeNetworkPoliciesYamlToDB(policies []types.KnoxNetworkPolicy) {
22472247
}
22482248

22492249
policyYaml := types.PolicyYaml{
2250-
Type: types.PolicyTypeNetwork,
2251-
Kind: np.Kind,
2252-
Name: np.Name,
2253-
Namespace: np.Namespace,
2254-
Cluster: clusters[i],
2255-
Labels: np.Labels,
2256-
Yaml: yamlBytes,
2250+
Type: types.PolicyTypeNetwork,
2251+
Kind: np.Kind,
2252+
Name: np.Name,
2253+
Namespace: np.Namespace,
2254+
WorkspaceId: cfg.GetCfgWorkspaceId(),
2255+
Cluster: clusters[i],
2256+
Labels: np.Labels,
2257+
Yaml: yamlBytes,
22572258
}
22582259
res = append(res, policyYaml)
22592260

@@ -2285,13 +2286,14 @@ func writeNetworkPoliciesYamlToDB(policies []types.KnoxNetworkPolicy) {
22852286
}
22862287

22872288
policyYaml := types.PolicyYaml{
2288-
Type: types.PolicyTypeNetwork,
2289-
Kind: ciliumPolicy.Kind,
2290-
Name: ciliumPolicy.Metadata["name"],
2291-
Namespace: ciliumPolicy.Metadata["namespace"],
2292-
Cluster: clusters[i],
2293-
Labels: labels,
2294-
Yaml: yamlBytes,
2289+
Type: types.PolicyTypeNetwork,
2290+
Kind: ciliumPolicy.Kind,
2291+
Name: ciliumPolicy.Metadata["name"],
2292+
Namespace: ciliumPolicy.Metadata["namespace"],
2293+
Cluster: clusters[i],
2294+
WorkspaceId: cfg.GetCfgWorkspaceId(),
2295+
Labels: labels,
2296+
Yaml: yamlBytes,
22952297
}
22962298
res = append(res, policyYaml)
22972299

src/systempolicy/systemPolicy.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -1398,13 +1398,14 @@ func insertSysPoliciesYamlToDB(policies []types.KnoxSystemPolicy) {
13981398
}
13991399

14001400
policyYaml := types.PolicyYaml{
1401-
Type: types.PolicyTypeSystem,
1402-
Kind: kubearmorPolicy.Kind,
1403-
Name: kubearmorPolicy.Metadata["name"],
1404-
Namespace: kubearmorPolicy.Metadata["namespace"],
1405-
Cluster: clusters[i],
1406-
Labels: kubearmorPolicy.Spec.Selector.MatchLabels,
1407-
Yaml: yamlBytes,
1401+
Type: types.PolicyTypeSystem,
1402+
Kind: kubearmorPolicy.Kind,
1403+
Name: kubearmorPolicy.Metadata["name"],
1404+
Namespace: kubearmorPolicy.Metadata["namespace"],
1405+
Cluster: clusters[i],
1406+
WorkspaceId: cfg.GetCfgWorkspaceId(),
1407+
Labels: kubearmorPolicy.Spec.Selector.MatchLabels,
1408+
Yaml: yamlBytes,
14081409
}
14091410
res = append(res, policyYaml)
14101411

src/types/policyData.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,12 @@ type PolicyFilter struct {
322322

323323
// PolicyYaml stores a policy in YAML format along with its metadata
324324
type PolicyYaml struct {
325-
Type string `json:"type,omitempty"`
326-
Kind string `json:"kind,omitempty"`
327-
Name string `json:"name,omitempty"`
328-
Namespace string `json:"namespace,omitempty"`
329-
Cluster string `json:"cluster,omitempty"`
330-
Labels LabelMap `json:"labels,omitempty"`
331-
Yaml []byte `json:"yaml,omitempty"`
325+
Type string `json:"type,omitempty"`
326+
Kind string `json:"kind,omitempty"`
327+
Name string `json:"name,omitempty"`
328+
Namespace string `json:"namespace,omitempty"`
329+
Cluster string `json:"cluster,omitempty"`
330+
WorkspaceId int32 `json:"workspace_id,omitempty"`
331+
Labels LabelMap `json:"labels,omitempty"`
332+
Yaml []byte `json:"yaml,omitempty"`
332333
}

0 commit comments

Comments
 (0)