@@ -204,10 +204,13 @@ func (ci *ClusterInfo) retrieveProxy() error {
204204 if err != nil {
205205 return err
206206 }
207+ // Remove any duplicates in noProxy
208+ noProxy := ci .removeDuplicates (proxy .Spec .NoProxy )
209+
207210 ci .Proxy = & types.Proxy {
208211 HTTPProxy : proxy .Spec .HTTPProxy ,
209212 HTTPSProxy : proxy .Spec .HTTPSProxy ,
210- NoProxy : proxy . Spec . NoProxy ,
213+ NoProxy : noProxy ,
211214 }
212215
213216 return nil
@@ -688,3 +691,31 @@ func (ci *ClusterInfo) reportResult(ctx context.Context) error {
688691
689692 return workflowreport .GetReport (ctx ).StageResult (workflow .StageClusterInspection , string (data ))
690693}
694+
695+ func (ci * ClusterInfo ) removeDuplicates (input string ) string {
696+ entries := strings .Split (strings .TrimSpace (input ), "," )
697+
698+ duplicates := []string {}
699+ uniqueMap := make (map [string ]bool )
700+ var uniqueList []string
701+ for _ , entry := range entries {
702+ trimmedEntry := strings .TrimSpace (entry )
703+
704+ // Check if the entry is not empty and hasn't been added to the map yet
705+ if trimmedEntry == "" {
706+ continue
707+ }
708+ if _ , exists := uniqueMap [trimmedEntry ]; ! exists {
709+ // If it doesn't exist, add it to the map and the unique list
710+ uniqueMap [trimmedEntry ] = true
711+ uniqueList = append (uniqueList , trimmedEntry )
712+ } else {
713+ duplicates = append (duplicates , trimmedEntry )
714+ }
715+ }
716+
717+ if len (duplicates ) > 0 {
718+ logrus .Infof ("Duplicates detected in noProxy: %v" , duplicates )
719+ }
720+ return strings .Join (uniqueList , "," )
721+ }
0 commit comments