Skip to content

Commit

Permalink
fix: avoid generating duplicate namespaces (KusionStack#477)
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 authored Aug 22, 2023
1 parent ef88f2a commit de8d64d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pkg/generator/appconfiguration/generator/namespace_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,13 @@ func (g *namespaceGenerator) Generate(spec *models.Spec) error {
ObjectMeta: metav1.ObjectMeta{Name: g.projectName},
}

return appconfiguration.AppendToSpec(models.Kubernetes, appconfiguration.KubernetesResourceID(ns.TypeMeta, ns.ObjectMeta), spec, ns)
// Avoid generating duplicate namespaces with the same ID.
id := appconfiguration.KubernetesResourceID(ns.TypeMeta, ns.ObjectMeta)
for _, res := range spec.Resources {
if res.ID == id {
return nil
}
}

return appconfiguration.AppendToSpec(models.Kubernetes, id, spec, ns)
}

0 comments on commit de8d64d

Please sign in to comment.