Bläddra i källkod

fix string slice convertion

Mohammed Nafees 4 år sedan
förälder
incheckning
2cdf7f2498
1 ändrade filer med 9 tillägg och 4 borttagningar
  1. 9 4
      internal/integrations/ci/gitlab/ci.go

+ 9 - 4
internal/integrations/ci/gitlab/ci.go

@@ -190,17 +190,22 @@ func (g *GitlabCI) Cleanup() error {
 		return fmt.Errorf("error unmarshalling existing .gitlab-ci.yml: %w", err)
 	}
 
-	stages, ok := ciFileContentsMap["stages"].([]string)
+	stages, ok := ciFileContentsMap["stages"].([]interface{})
 
 	if !ok {
-		return fmt.Errorf("error converting stages to string slice")
+		return fmt.Errorf("error converting stages to interface slice")
 	}
 
 	var newStages []string
 
 	for _, stage := range stages {
-		if stage != jobName {
-			newStages = append(newStages, stage)
+		stageStr, ok := stage.(string)
+		if !ok {
+			return fmt.Errorf("error converting from interface to string")
+		}
+
+		if stageStr != jobName {
+			newStages = append(newStages, stageStr)
 		}
 	}