Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1056 from xunpan/enable
Browse files Browse the repository at this point in the history
check if federated type is referred by an existing FTC
  • Loading branch information
k8s-ci-robot authored Jul 31, 2019
2 parents 5247f78 + 05269ba commit cf27d73
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions pkg/kubefedctl/enable/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,25 @@ func CreateResources(cmdOut io.Writer, config *rest.Config, resources *typeResou
} else if err != nil {
return errors.Wrapf(err, "Error getting CRD %q", resources.CRD.Name)
} else {
ftcs := &fedv1b1.FederatedTypeConfigList{}
err := client.List(context.TODO(), ftcs, namespace)
if err != nil {
return errors.Wrap(err, "Error getting FederatedTypeConfig list")
}

for _, ftc := range ftcs.Items {
if concreteTypeConfig.Name == ftc.Name {
continue
}

fedType := ftc.Spec.FederatedType
name := typeconfig.GroupQualifiedName(metav1.APIResource{Name: fedType.PluralName, Group: fedType.Group})
if name == existingCRD.Name {
return errors.Errorf("Failed to enable federation of %q due to the FederatedTypeConfig for %q already referencing a federated type CRD named %q. If these target types are distinct despite sharing the same kind, specifying a non-default --federation-group should allow %q to be enabled.",
concreteTypeConfig.Name, ftc.Name, name, concreteTypeConfig.Name)
}
}

existingCRD.Spec = resources.CRD.Spec
_, err = crdClient.CustomResourceDefinitions().Update(existingCRD)
if err != nil {
Expand Down

0 comments on commit cf27d73

Please sign in to comment.