Skip to content

Commit

Permalink
Fix Fleet GitRepo initial target mode
Browse files Browse the repository at this point in the history
- `fleet.cattle.io.GitRepo` `spec.targets` can contain multiple selectors per target
  - https://fleet.rancher.io/gitrepo-targets/#target-matching
- UI handles this use case by an 'advanced' mode where user can enter free text (otherwise `target` can only contain a single selector type)
- When attempting to edit a GitRepo that has a multi-selector target now we now correctly identify it and start in 'advanced' mode
- Addresses rancher#4788
  • Loading branch information
richard-cox committed Jan 6, 2022
1 parent 513ac19 commit b34b9c6
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions models/fleet.cattle.io.gitrepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,20 +241,20 @@ export default class GitRepo extends SteveModel {
} else if ( targets.length === 1) {
const target = targets[0];

if ( target.clusterGroup ) {
if (Object.keys(target).length > 1) {
// There are multiple properties in a single target, so use the 'advanced' mode
// (otherwise any existing content is nuked for what we provide)
mode = 'advanced';
} else if ( target.clusterGroup ) {
clusterGroup = target.clusterGroup;

if ( !mode ) {
mode = 'clusterGroup';
}
}

if ( target.clusterName ) {
} else if ( target.clusterName ) {
mode = 'cluster';
cluster = target.clusterName;
}

if ( target.clusterSelector ) {
} else if ( target.clusterSelector ) {
if ( Object.keys(target.clusterSelector).length === 0 ) {
mode = 'all';
} else {
Expand Down

0 comments on commit b34b9c6

Please sign in to comment.