Skip to content

Commit

Permalink
Merge pull request rancher#5 from crobby/0803-migration
Browse files Browse the repository at this point in the history
Make sure annotations/labels are not nil
  • Loading branch information
nflynt committed Aug 4, 2023
2 parents b9aa392 + 72895b4 commit 30c9f64
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/agent/clean/active_directory.go
Expand Up @@ -754,8 +754,14 @@ func migrateCRTBs(workunit *migrateUserWorkUnit, sc *config.ScaledContext, dryRu
logrus.Infof("Dry Run: Would migrate CRTB '%v' from GUID principal '%v' to DN principal '%v'", oldCrtb.Name, oldCrtb.UserPrincipalName, dnPrincipalID)
} else {
newAnnotations := oldCrtb.Annotations
if newAnnotations == nil {
newAnnotations = make(map[string]string)
}
newAnnotations[adGUIDMigrationAnnotation] = oldCrtb.UserPrincipalName
newLabels := oldCrtb.Labels
if newLabels == nil {
newLabels = make(map[string]string)
}
newLabels[adGUIDMigrationLabel] = migratedLabelValue
newCrtb := &v3.ClusterRoleTemplateBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -788,8 +794,14 @@ func migrateCRTBs(workunit *migrateUserWorkUnit, sc *config.ScaledContext, dryRu
logrus.Infof("Dry Run: Would migrate CRTB '%v' from duplicate local user '%v' to original user '%v'", oldCrtb.Name, oldCrtb.UserPrincipalName, localPrincipalID)
} else {
newAnnotations := oldCrtb.Annotations
if newAnnotations == nil {
newAnnotations = make(map[string]string)
}
newAnnotations[adGUIDMigrationAnnotation] = oldCrtb.UserPrincipalName
newLabels := oldCrtb.Labels
if newLabels == nil {
newLabels = make(map[string]string)
}
newLabels[adGUIDMigrationLabel] = migratedLabelValue
newCrtb := &v3.ClusterRoleTemplateBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -826,8 +838,14 @@ func migratePRTBs(workunit *migrateUserWorkUnit, sc *config.ScaledContext, dryRu
logrus.Infof("Dry Run: Would migrate PRTB '%v' from GUID principal '%v' to DN principal '%v'", oldPrtb.Name, oldPrtb.UserPrincipalName, dnPrincipalID)
} else {
newAnnotations := oldPrtb.Annotations
if newAnnotations == nil {
newAnnotations = make(map[string]string)
}
newAnnotations[adGUIDMigrationAnnotation] = oldPrtb.UserPrincipalName
newLabels := oldPrtb.Labels
if newLabels == nil {
newLabels = make(map[string]string)
}
newLabels[adGUIDMigrationLabel] = migratedLabelValue
newPrtb := &v3.ProjectRoleTemplateBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -860,8 +878,14 @@ func migratePRTBs(workunit *migrateUserWorkUnit, sc *config.ScaledContext, dryRu
logrus.Infof("Dry Run: Would migrate PRTB '%v' from duplicate local user '%v' to original user '%v'", oldPrtb.Name, oldPrtb.UserPrincipalName, localPrincipalID)
} else {
newAnnotations := oldPrtb.Annotations
if newAnnotations == nil {
newAnnotations = make(map[string]string)
}
newAnnotations[adGUIDMigrationAnnotation] = oldPrtb.UserPrincipalName
newLabels := oldPrtb.Labels
if newLabels == nil {
newLabels = make(map[string]string)
}
newLabels[adGUIDMigrationLabel] = migratedLabelValue
newPrtb := &v3.ProjectRoleTemplateBinding{
ObjectMeta: metav1.ObjectMeta{
Expand Down

0 comments on commit 30c9f64

Please sign in to comment.