Skip to content

Commit

Permalink
bump to use req meta
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme committed Jan 14, 2023
1 parent 83920e5 commit 0f17395
Show file tree
Hide file tree
Showing 6 changed files with 334 additions and 117 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/bufbuild/connect-go v1.4.1
github.com/cli/safeexec v1.0.1
github.com/humanlogio/api/go v0.0.0-20230108030320-eda29f98df5a
github.com/humanlogio/api/go v0.0.0-20230114032924-720377a9d5df
github.com/mattn/go-colorable v0.1.13
github.com/urfave/cli v1.22.10
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/humanlogio/api/go v0.0.0-20230108030320-eda29f98df5a h1:mrmfNfqW8wvOmTvPs3/ReRN9v8Tf+UFmFvh312XtqYA=
github.com/humanlogio/api/go v0.0.0-20230108030320-eda29f98df5a/go.mod h1:DkpFdPohT0dBEJvo9lYEHJZ7qdGNQpsw89an+GXqMUU=
github.com/humanlogio/api/go v0.0.0-20230114032924-720377a9d5df h1:9bmj8HQZgeLfDkEadqQVcKsMOM9M3YCIFwoHgqJJ8MI=
github.com/humanlogio/api/go v0.0.0-20230114032924-720377a9d5df/go.mod h1:DkpFdPohT0dBEJvo9lYEHJZ7qdGNQpsw89an+GXqMUU=
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
Expand Down
47 changes: 27 additions & 20 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,24 @@ func newApp() *cli.App {
res, err := updateClient.GetNextUpdate(ctx, connect.NewRequest(&cliupdatepb.GetNextUpdateRequest{
ProjectName: cctx.String(flagProjectName),
CurrentVersion: version,
AccountId: accountId,
MachineId: machineId,
MachineArchitecture: cctx.String(flagArtifactArchitecture),
MachineOperatingSystem: cctx.String(flagArtifactOperatingSystem),
Meta: &typesv1.ReqMeta{
AccountId: accountId,
MachineId: machineId,
},
}))
if err != nil {
return err
}
msg := res.Msg
meta := msg.Meta

if msg.Account != nil && accountId != msg.Account.Id {
log.Printf("an account id was assigned: %d", msg.Account.Id)
if accountId != meta.AccountId {
log.Printf("an account id was assigned: %d", meta.AccountId)
}
if msg.Machine != nil && machineId != msg.Machine.Id {
log.Printf("a machine id was assigned: %d", msg.Machine.Id)
if machineId != meta.MachineId {
log.Printf("a machine id was assigned: %d", meta.MachineId)
}
sv, err := msg.NextVersion.AsSemver()
if err != nil {
Expand Down Expand Up @@ -514,21 +517,23 @@ func newApp() *cli.App {
res, err := updateClient.GetNextUpdate(ctx, connect.NewRequest(&cliupdatepb.GetNextUpdateRequest{
ProjectName: "apictl",
CurrentVersion: version,
AccountId: accountId,
MachineId: machineId,
MachineArchitecture: runtime.GOARCH,
MachineOperatingSystem: runtime.GOOS,
Meta: &typesv1.ReqMeta{
AccountId: accountId,
MachineId: machineId,
},
}))
if err != nil {
return err
}
msg := res.Msg

if msg.Account != nil && accountId != msg.Account.Id {
log.Printf("an account id was assigned: %d", msg.Account.Id)
meta := msg.Meta
if accountId != meta.AccountId {
log.Printf("an account id was assigned: %d", meta.AccountId)
}
if msg.Machine != nil && machineId != msg.Machine.Id {
log.Printf("a machine id was assigned: %d", msg.Machine.Id)
if machineId != meta.MachineId {
log.Printf("a machine id was assigned: %d", meta.MachineId)
}

currentSV, err := version.AsSemver()
Expand Down Expand Up @@ -566,21 +571,23 @@ func newApp() *cli.App {
res, err := updateClient.GetNextUpdate(ctx, connect.NewRequest(&cliupdatepb.GetNextUpdateRequest{
ProjectName: "apictl",
CurrentVersion: version,
AccountId: accountId,
MachineId: machineId,
MachineArchitecture: runtime.GOARCH,
MachineOperatingSystem: runtime.GOOS,
Meta: &typesv1.ReqMeta{
AccountId: accountId,
MachineId: machineId,
},
}))
if err != nil {
return err
}
msg := res.Msg

if msg.Account != nil && accountId != msg.Account.Id {
log.Printf("an account id was assigned: %d", msg.Account.Id)
meta := msg.Meta
if accountId != meta.AccountId {
log.Printf("an account id was assigned: %d", meta.AccountId)
}
if msg.Machine != nil && machineId != msg.Machine.Id {
log.Printf("a machine id was assigned: %d", msg.Machine.Id)
if machineId != meta.MachineId {
log.Printf("a machine id was assigned: %d", meta.MachineId)
}

currentSV, err := version.AsSemver()
Expand Down
Loading

0 comments on commit 0f17395

Please sign in to comment.