Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Break dependencies among git, job, event packages #1027

Merged
merged 1 commit into from
Apr 3, 2018

Conversation

squaremo
Copy link
Member

These all use each others types, and that makes it difficult to
refactor other packages without introducing cycles. To break the
dependencies, I needed to:

  • make git accept any (JSON serialisable) value as a note
  • stop referring to an event type in the job package, and thereby the
    API and client

@squaremo squaremo requested a review from samb1729 March 28, 2018 09:13
daemon/daemon.go Outdated
@@ -152,30 +152,30 @@ func (d *Daemon) ListImages(ctx context.Context, spec update.ResourceSpec) ([]v6
// Let's use the CommitEventMetadata as a convenient transport for the
// results of a job; if no commit was made (e.g., if it was a dry
// run), leave the revision field empty.
type DaemonJobFunc func(ctx context.Context, jobID job.ID, working *git.Checkout, logger log.Logger) (*event.CommitEventMetadata, error)
type DaemonJobFunc func(ctx context.Context, jobID job.ID, working *git.Checkout, logger log.Logger) (job.Result, error)

This comment was marked as abuse.

@@ -1,4 +1,4 @@
package git
package daemon

This comment was marked as abuse.

This comment was marked as abuse.

b, err := json.Marshal(note)
if err != nil {
return err
}
return execGitCmd(ctx, workingDir, nil, "notes", "--ref", notesRef, "add", "-m", string(b), rev)
}

// NB return values (*Note, nil), (nil, error), (nil, nil)
func getNote(ctx context.Context, workingDir, notesRef, rev string) (*Note, error) {
// NB first return value indicates whether there was a note; second was an error

This comment was marked as abuse.

@squaremo
Copy link
Member Author

Thanks Sam. I've adjusted as requested.

Copy link
Contributor

@samb1729 samb1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Squash the second commit though please.

These all use each others types, and that makes it difficult to
refactor other packages without introducing cycles. To break the
dependencies, I needed to:

 - make git accept any (JSON serialisable) value as a note

 - stop referring to an event type in the job package, and thereby the
   API and client
@squaremo squaremo force-pushed the issue/1026-look-at-git-not-cluster branch from 3bc19d0 to 25bbcd4 Compare April 3, 2018 11:16
@squaremo squaremo merged commit 353bcc3 into master Apr 3, 2018
@squaremo squaremo deleted the issue/1026-look-at-git-not-cluster branch April 3, 2018 11:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants