Skip to content

Commit

Permalink
Changed folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jlehtimaki committed Feb 20, 2020
1 parent f9f1405 commit 8996194
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion cmd/api/api.go → pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
)

func apiRequest(subUrlPath string) (string, error) {
func ApiRequest(subUrlPath string) (string, error) {

droneUrl := os.Getenv("DRONE_URL")
token := os.Getenv("TOKEN")
Expand Down
File renamed without changes.
20 changes: 6 additions & 14 deletions main.go → pkg/repository/repository.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package main
package repository

import (
"encoding/json"
"fmt"
"github.com/jlehtimaki/drone-exporter/cmd/api"
//"github.com/jlehtimaki/drone_exporter@initial/cmd/drivers/influxdb"
"github.com/jlehtimaki/drone-exporter/pkg/api"
)

type Repo struct {
Id int `json:"Id"`
Name string `json:"Name"`
Active bool `json:"Active"`
Active bool `json:"Active"`
Namespace string `json:"Namespace"`
}

Expand Down Expand Up @@ -40,9 +39,9 @@ func (rwb *RepoWithBuilds) AddBuild(build Build){
rwb.Builds = append(rwb.Builds, build)
}

func getRepos() error {
func GetRepos() error {
var subUrlPath = "/api/user/repos"
data, err := api.apiRequest(subUrlPath)
data, err := api.ApiRequest(subUrlPath)
if err != nil {
return fmt.Errorf("could not get repos: %w", err)
}
Expand Down Expand Up @@ -71,7 +70,7 @@ func getBuilds(repos Repo, rbw RepoWithBuilds) (RepoWithBuilds, error) {
subUrlPath := fmt.Sprintf("/api/repos/%s" +
"/%s/builds", repos.Namespace, repos.Name)

data, err := api.apiRequest(subUrlPath)
data, err := api.ApiRequest(subUrlPath)
if err != nil {
return rbw, fmt.Errorf("could not get builds: %w", err)
}
Expand All @@ -87,10 +86,3 @@ func getBuilds(repos Repo, rbw RepoWithBuilds) (RepoWithBuilds, error) {

return rbw, nil
}

func main() {
err := getRepos()
if err != nil {
fmt.Printf("error: %s", err)
}
}

0 comments on commit 8996194

Please sign in to comment.