-
Notifications
You must be signed in to change notification settings - Fork 413
Labels sync targets with the SyncTargetKey for reverse lookup #1672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
35e855d
0cdb69b
7053477
9effac7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and | |
limitations under the License. | ||
*/ | ||
|
||
package virtualworkspaceurls | ||
package synctarget | ||
|
||
import ( | ||
"net/url" | ||
|
@@ -34,6 +34,13 @@ import ( | |
func (c *Controller) reconcile(syncTarget *workloadv1alpha1.SyncTarget, workspaceShards []*v1alpha1.ClusterWorkspaceShard) (*workloadv1alpha1.SyncTarget, error) { | ||
syncTargetCopy := syncTarget.DeepCopy() | ||
|
||
labels := syncTargetCopy.GetLabels() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can edit There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that panics. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no. Of course you have to create the map if it is nil. But no need for calling setter and getter. |
||
if labels == nil { | ||
labels = map[string]string{} | ||
} | ||
labels[workloadv1alpha1.InternalSyncTargetKeyLabel] = workloadv1alpha1.ToSyncTargetKey(logicalcluster.From(syncTargetCopy), syncTargetCopy.Name) | ||
syncTargetCopy.SetLabels(labels) | ||
|
||
desiredURLs := sets.NewString() | ||
for _, workspaceShard := range workspaceShards { | ||
if workspaceShard.Spec.ExternalURL != "" { | ||
|
@@ -53,6 +60,17 @@ func (c *Controller) reconcile(syncTarget *workloadv1alpha1.SyncTarget, workspac | |
} | ||
} | ||
|
||
if syncTargetCopy.Status.VirtualWorkspaces != nil { | ||
currentURLs := sets.NewString() | ||
for _, virtualWorkspace := range syncTargetCopy.Status.VirtualWorkspaces { | ||
currentURLs = currentURLs.Insert(virtualWorkspace.URL) | ||
} | ||
|
||
if desiredURLs.Equal(currentURLs) { | ||
return syncTargetCopy, nil | ||
} | ||
} | ||
|
||
syncTargetCopy.Status.VirtualWorkspaces = nil | ||
for _, url := range desiredURLs.List() { | ||
syncTargetCopy.Status.VirtualWorkspaces = append( | ||
|
Uh oh!
There was an error while loading. Please reload this page.