Skip to content

Commit d51080f

Browse files
committed
cleaned up and ready
1 parent 11ef58f commit d51080f

11 files changed

+160
-517
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
buildmeta_*
2-
*.zst
2+
*.zst
3+
.vscode
4+
.DS_Store

cmd/buildmeta.go

+15-20
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ import (
2828
"github.com/runpod/rplog"
2929
)
3030

31-
//go:embed uuid7.js
32-
var uuid7js []byte
33-
3431
//go:embed uuid7.py
3532
var uuid7py []byte
3633

@@ -147,30 +144,28 @@ def as_rfc3339(dt: datetime.datetime) -> str:
147144
return dt.astimezone(datetime.timezone.utc).strftime("%%Y-%%m-%%dT%%H:%%M:%%S.%%f")[:-4]+"Z"
148145
metadata = {
149146
"instance_id": str(uuid7()),
150-
"service_name": %q,
151-
"service_env": %q,
152-
"service_vcs_commit": %q,
153-
"service_vcs_tag": %q,
154-
"service_vcs_time": as_rfc3339(datetime.datetime.fromisoformat(%q)),
155-
"service_vcs_name": %q,
147+
"service": %q,
148+
"env": %q,
149+
"vcs_commit": %q,
150+
"vcs_tag": %q,
151+
"vcs_time": as_rfc3339(datetime.datetime.fromisoformat(%q)),
152+
"vcs_name": %q,
156153
}
157154
`
158155
fmt.Printf(format, uuid7py, o.Service, o.Env, o.VCSCommit, o.VCSTag, o.VCSTime, o.VCSName)
159156
case "js", "javascript":
160-
// first, we inline the uuid7.js file, then we print the metadata as a javascript object.
161-
const format = `%s
162-
import { uuidv7 } from "uuidv7"
157+
const format = `import {randomUUID } from "crypto"
163158
export const metadata = {
164-
instance_id: uuidv7(),
165-
service_name: %q,
166-
service_env: %q,
167-
service_vcs_commit: %q,
168-
service_vcs_tag: %q,
169-
service_vcs_time: (new Date(%q)).toISOString(),
170-
service_vcs_name: %q,
159+
instance_id: randomUUID(),
160+
service: %q,
161+
env: %q,
162+
vcs_commit: %q,
163+
vcs_tag: %q,
164+
vcs_time: (new Date(%q)).toISOString(),
165+
vcs_name: %q,
171166
}
172167
`
173-
fmt.Printf(format, uuid7js, o.Service, o.Env, o.VCSCommit, o.VCSTag, o.VCSTime, o.VCSName)
168+
fmt.Printf(format, o.Service, o.Env, o.VCSCommit, o.VCSTag, o.VCSTime, o.VCSName)
174169
default:
175170
log.Fatalf("unknown output format %q", outputFormat)
176171
}

0 commit comments

Comments
 (0)