func()

in fast-build-update-tool/internal/tools/zip_validator.go [21:39]


func (z *ZipValidator) ValidateZip(ctx context.Context, fleet *gamelift.Fleet) error {
	zipReader, zipErr := zip.OpenReader(z.buildZipPath)
	if zipErr != nil {
		return fmt.Errorf("error opening zip file %w", zipErr)
	}
	defer zipReader.Close()

	for _, executablePath := range fleet.ExecutablePaths {
		normalizedFileToFind := strings.ReplaceAll(executablePath, "C:\\game\\", "")
		normalizedFileToFind = strings.ReplaceAll(normalizedFileToFind, "/local/game/", "")
		normalizedFileToFind = strings.ReplaceAll(normalizedFileToFind, "\\", "/")

		if !isFileInZip(zipReader, normalizedFileToFind) {
			return fmt.Errorf("zip file does not contain executable %s", normalizedFileToFind)
		}
	}

	return nil
}