Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

Commit

Permalink
Merge pull request #754 from dexhorthy/github-debug
Browse files Browse the repository at this point in the history
Add better debug output on proxied github pull failure.
  • Loading branch information
dexhorthy committed Dec 10, 2018
2 parents 64ea658 + ae57100 commit 830f127
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 12 deletions.
20 changes: 20 additions & 0 deletions pkg/api/spec.go
@@ -1,6 +1,7 @@
package api

import (
"fmt"
"regexp"
"strings"

Expand Down Expand Up @@ -31,6 +32,19 @@ type GithubContent struct {
Files []GithubFile `json:"files" yaml:"files" hcl:"files" meta:"files"`
}

// Not using json.Marshal because I want to omit the file data, and don't feel like
// writing a custom marshaller
func (g GithubContent) String() string {

fileStr := "["
for _, file := range g.Files {
fileStr += fmt.Sprintf("%s, ", file.String())
}
fileStr += "]"

return fmt.Sprintf("GithubContent{ repo:%s path:%s ref:%s files:%s }", g.Repo, g.Path, g.Ref, fileStr)
}

// GithubFile
type GithubFile struct {
Name string `json:"name" yaml:"name" hcl:"name" meta:"name"`
Expand All @@ -40,6 +54,12 @@ type GithubFile struct {
Data string `json:"data" yaml:"data" hcl:"data" meta:"data"`
}

func (file GithubFile) String() string {
return fmt.Sprintf("GitHubFile{ name:%s path:%s sha:%s size:%d dataLen:%d }",
file.Name, file.Path, file.Sha, file.Size, len(file.Data))

}

type ShipAppMetadata struct {
Description string `json:"description" yaml:"description" hcl:"description" meta:"description"`
Version string `json:"version" yaml:"version" hcl:"version" meta:"version"`
Expand Down
20 changes: 19 additions & 1 deletion pkg/lifecycle/render/github/render.go
Expand Up @@ -3,6 +3,7 @@ package github
import (
"context"
"encoding/base64"
"fmt"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -90,7 +91,8 @@ func (r *LocalRenderer) Execute(
debug.Log("event", "resolveProxyGithubAssets")
files := filterGithubContents(meta.GithubContents, asset)
if len(files) == 0 {
level.Info(r.Logger).Log("msg", "no files for asset", "repo", asset.Repo, "path", asset.Path)
level.Info(r.Logger).Log("msg", "no proxy files for asset", "repo", asset.Repo, "path", asset.Path)
r.debugDumpKnownGithubFiles(meta, asset)

if asset.Source == "public" || !asset.Proxy {
debug.Log("event", "resolveNoProxyGithubAssets")
Expand All @@ -107,6 +109,22 @@ func (r *LocalRenderer) Execute(
}
}

func (r *LocalRenderer) debugDumpKnownGithubFiles(meta api.ReleaseMetadata, asset api.GitHubAsset) {
debugStr := "["
for _, content := range meta.GithubContents {
debugStr += fmt.Sprintf("%s, ", content.String())

}
debugStr += "]"

level.Debug(r.Logger).Log(
"msg", "github contents",
"repo", asset.Repo,
"path", asset.Path,
"releaseMeta", debugStr,
)
}

func filterGithubContents(githubContents []api.GithubContent, asset api.GitHubAsset) []api.GithubFile {
var filtered []api.GithubFile
for _, c := range githubContents {
Expand Down
4 changes: 1 addition & 3 deletions pkg/lifecycle/render/local/render.go
Expand Up @@ -4,11 +4,9 @@ import (
"context"
"path/filepath"

"github.com/pkg/errors"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"

"github.com/pkg/errors"
"github.com/replicatedhq/libyaml"
"github.com/replicatedhq/ship/pkg/api"
"github.com/spf13/afero"
Expand Down
3 changes: 1 addition & 2 deletions pkg/lifecycle/unfork/unforker.go
Expand Up @@ -9,8 +9,6 @@ import (
"strings"
"time"

"github.com/replicatedhq/ship/pkg/util"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
Expand All @@ -20,6 +18,7 @@ import (
"github.com/replicatedhq/ship/pkg/lifecycle/daemon/daemontypes"
"github.com/replicatedhq/ship/pkg/patch"
"github.com/replicatedhq/ship/pkg/state"
"github.com/replicatedhq/ship/pkg/util"
"github.com/spf13/afero"
yaml "gopkg.in/yaml.v2"
"k8s.io/client-go/kubernetes/scheme"
Expand Down
3 changes: 1 addition & 2 deletions pkg/patch/patcher.go
Expand Up @@ -8,14 +8,13 @@ import (
"reflect"
"strconv"

"github.com/replicatedhq/ship/pkg/util"

"github.com/ghodss/yaml"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/replicatedhq/ship/pkg/api"
"github.com/replicatedhq/ship/pkg/constants"
"github.com/replicatedhq/ship/pkg/util"
"github.com/spf13/afero"
"k8s.io/apimachinery/pkg/util/strategicpatch"
"k8s.io/client-go/kubernetes/scheme"
Expand Down
3 changes: 1 addition & 2 deletions pkg/specs/interface.go
Expand Up @@ -8,15 +8,14 @@ import (
"os"
"path/filepath"

"gopkg.in/yaml.v2"

"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/pkg/errors"
"github.com/replicatedhq/ship/pkg/api"
"github.com/replicatedhq/ship/pkg/constants"
"github.com/replicatedhq/ship/pkg/specs/replicatedapp"
"github.com/replicatedhq/ship/pkg/util"
"gopkg.in/yaml.v2"
)

func (r *Resolver) ResolveUnforkRelease(ctx context.Context, upstream string, forked string) (*api.Release, error) {
Expand Down
3 changes: 1 addition & 2 deletions pkg/util/kubernetes_resource.go
Expand Up @@ -3,10 +3,9 @@ package util
import (
"bytes"

k8syaml "k8s.io/apimachinery/pkg/util/yaml"

"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
"sigs.k8s.io/kustomize/pkg/resource"
)

Expand Down

0 comments on commit 830f127

Please sign in to comment.