Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #30 from stealthrocket/describe
Browse files Browse the repository at this point in the history
timecraft: add describe command
  • Loading branch information
achille-roussel committed May 29, 2023
2 parents 9fb247d + 72d16a9 commit 787a667
Show file tree
Hide file tree
Showing 12 changed files with 774 additions and 123 deletions.
18 changes: 13 additions & 5 deletions format/timecraft.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,20 @@ func SHA256(b []byte) Hash {
}
}

func ParseHash(s string) (h Hash, err error) {
var ok bool
h.Algorithm, h.Digest, ok = strings.Cut(s, ":")
func ParseHash(s string) Hash {
algorithm, digest, ok := strings.Cut(s, ":")
if !ok {
err = fmt.Errorf("malformed hash: %s", s)
algorithm, digest = "sha256", s
}
return h, err
return Hash{Algorithm: algorithm, Digest: digest}
}

func (h Hash) Short() string {
s := h.Digest
if len(s) > 12 {
s = s[:12]
}
return s
}

func (h Hash) String() string {
Expand Down Expand Up @@ -123,6 +130,7 @@ func (m *Module) UnmarshalResource(b []byte) error {
}

type Runtime struct {
Runtime string `json:"runtime" yaml:"runtime"`
Version string `json:"version" yaml:"version"`
}

Expand Down
Loading

0 comments on commit 787a667

Please sign in to comment.