Skip to content

Commit

Permalink
Merge pull request #7 from docat-org/bugfix/enable-zip-compression
Browse files Browse the repository at this point in the history
fix: enable zip compression
  • Loading branch information
fliiiix authored Aug 26, 2022
2 parents 7ccd177 + af45e5b commit 745362c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
lint:
strategy:
matrix:
go-version: ["1.17"]
go-version: ["1.19"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

Expand All @@ -31,7 +31,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go-version: ["1.17"]
go-version: ["1.19"]
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}

Expand All @@ -54,7 +54,7 @@ jobs:

strategy:
matrix:
go-version: ["1.17"]
go-version: ["1.19"]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}

Expand All @@ -63,10 +63,10 @@ jobs:
with:
fetch-depth: 0

- name: Set up Go 1.17
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.17
go-version: 1.19

- name: Docker Login
uses: docker/login-action@v1
Expand Down
10 changes: 5 additions & 5 deletions pkg/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"archive/zip"
"fmt"
"io"
"io/ioutil"
"log"
"os"
"path/filepath"

util "github.com/docat-org/docatl/internal"
Expand All @@ -29,7 +29,7 @@ func Build(docsPath string, meta BuildMetadata) (string, error) {
docsPath = util.ResolvePath(docsPath)

// NOTE(TF): the `archiver` package does not have an option to not create a top-level directory
filesInDocsPath, err := ioutil.ReadDir(docsPath)
filesInDocsPath, err := os.ReadDir(docsPath)
if err != nil {
return "", fmt.Errorf("cannot list the contents within the given documentation directory: %w", err)
}
Expand All @@ -48,7 +48,7 @@ func Build(docsPath string, meta BuildMetadata) (string, error) {

outputPath := generateArtifactFileName(docsPath, meta)

z := archiver.Zip{OverwriteExisting: true}
z := archiver.Zip{OverwriteExisting: true, FileMethod: archiver.BZIP2}
err = z.Archive(filesToArchive, outputPath)
if err != nil {
return "", fmt.Errorf("failed to archive docs: %w", err)
Expand All @@ -70,7 +70,7 @@ func generateArtifactFileName(docsPath string, meta BuildMetadata) string {
}

func generateMetadataFile(meta BuildMetadata) (string, error) {
tmpDir, err := ioutil.TempDir("", "docatl-*")
tmpDir, err := os.MkdirTemp("", "docatl-*")
if err != nil {
return "", fmt.Errorf("unable to create temp directory for metadatafile: %w", err)
}
Expand All @@ -81,7 +81,7 @@ func generateMetadataFile(meta BuildMetadata) (string, error) {
return "", fmt.Errorf("unable to generate metadata file for data: %v: %w", meta, err)
}

err = ioutil.WriteFile(metadataFile, doc, 0755)
err = os.WriteFile(metadataFile, doc, 0755)
if err != nil {
return "", fmt.Errorf("unabel to write metadata to file %s: %w", metadataFile, err)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package docatl

import (
"fmt"
"io/ioutil"
"os"

"gopkg.in/yaml.v3"
)
Expand All @@ -18,7 +18,7 @@ func WriteConfig(configPath string, config Config) error {
return fmt.Errorf("unable to marshal config '%v' to YAML: %w", config, err)
}

err = ioutil.WriteFile(configPath, doc, 0644)
err = os.WriteFile(configPath, doc, 0644)
if err != nil {
return fmt.Errorf("unable to write config to '%s': %w", configPath, err)
}
Expand Down
9 changes: 4 additions & 5 deletions pkg/docat.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
Expand Down Expand Up @@ -58,7 +57,7 @@ func (docat *Docat) Post(project string, version string, docsPath string) error
defer response.Body.Close()

if response.StatusCode != http.StatusCreated {
bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return fmt.Errorf("unable to upload documentation and read it's response (status code: %d", response.StatusCode)
}
Expand All @@ -84,7 +83,7 @@ func (docat *Docat) Delete(project string, version string) error {
defer response.Body.Close()

if response.StatusCode != http.StatusOK {
bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return fmt.Errorf("unable to delete documentation and read it's response (status code: %d", response.StatusCode)
}
Expand All @@ -102,7 +101,7 @@ func (docat *Docat) Claim(project string) (ProjectClaim, error) {
}
defer response.Body.Close()

bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return ProjectClaim{}, fmt.Errorf("unable to claim project and read it's response (status code: %d", response.StatusCode)
}
Expand Down Expand Up @@ -133,7 +132,7 @@ func (docat *Docat) Tag(project string, version string, tag string) error {
defer response.Body.Close()

if response.StatusCode != http.StatusCreated {
bodyBytes, err := ioutil.ReadAll(response.Body)
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return fmt.Errorf("unable to tag documentation and read it's response (status code: %d", response.StatusCode)
}
Expand Down

0 comments on commit 745362c

Please sign in to comment.