Przeglądaj źródła

fix string slice error

Mohammed Nafees 4 lat temu
rodzic
commit
0c51df214c
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8 3
      internal/integrations/ci/gitlab/ci.go

+ 8 - 3
internal/integrations/ci/gitlab/ci.go

@@ -102,16 +102,21 @@ func (g *GitlabCI) Setup() 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")
 		}
 
 		stageExists := false
 
 		for _, stage := range stages {
-			if stage == jobName {
+			stageStr, ok := stage.(string)
+			if !ok {
+				return fmt.Errorf("error converting from interface to string")
+			}
+
+			if stageStr == jobName {
 				stageExists = true
 				break
 			}