Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Nov 20, 2022
1 parent 6af9ece commit 1ee60f8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 62 deletions.
7 changes: 1 addition & 6 deletions cmd/depot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,12 @@ func checkForUpdate(currentVersion string) (*api.ReleaseResponse, error) {
return nil, nil
}

client, err := api.NewDepotFromEnv(config.GetApiToken())
if err != nil {
return nil, err
}

stateFilePath, err := config.StateFile()
if err != nil {
return nil, err
}

return update.CheckForUpdate(client, stateFilePath, currentVersion)
return update.CheckForUpdate(stateFilePath, currentVersion)
}

func shouldCheckForUpdate() bool {
Expand Down
4 changes: 2 additions & 2 deletions internal/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ type StateEntry struct {
LatestRelease *api.ReleaseResponse `yaml:"latestRelease"`
}

func CheckForUpdate(client *api.Depot, stateFilePath, currentVersion string) (*api.ReleaseResponse, error) {
func CheckForUpdate(stateFilePath, currentVersion string) (*api.ReleaseResponse, error) {
state, _ := readStateFile(stateFilePath)
if state != nil && time.Since(state.CheckedForUpdateAt) < time.Hour*1 {
return nil, nil
}

release, err := client.LatestRelease()
release, err := api.LatestRelease()
if err != nil {
return nil, err
}
Expand Down
41 changes: 0 additions & 41 deletions pkg/api/api.go

This file was deleted.

13 changes: 0 additions & 13 deletions pkg/api/context.go

This file was deleted.

23 changes: 23 additions & 0 deletions pkg/api/updates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package api

import (
"fmt"
"runtime"
"time"
)

type ReleaseResponse struct {
OK bool `json:"ok"`
Version string `json:"version"`
URL string `json:"url"`
PublishedAt time.Time `json:"publishedAt"`
}

func LatestRelease() (*ReleaseResponse, error) {
return apiRequest[ReleaseResponse](
"GET",
fmt.Sprintf("https://dl.depot.dev/cli/release/%s/%s/latest", runtime.GOOS, runtime.GOARCH),
"",
nil,
)
}

0 comments on commit 1ee60f8

Please sign in to comment.