Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
4234f96
Allow for easy creating of custom tasks to be created allowing fields…
Oct 20, 2023
f7bfa50
Export validateParamCount function
Oct 20, 2023
899c701
Update go.mod file
Oct 22, 2023
80215ea
Update README.md
MartinSimango Oct 22, 2023
93d4560
Update README.md
MartinSimango Oct 27, 2023
48c5904
featredesign generation logic
MartinSimango Dec 1, 2023
12413aa
refactor config and how generation works
MartinSimango Dec 10, 2023
6708da8
add support for custom types allowing dates to be generated
MartinSimango Dec 11, 2023
7799838
Add more documentation
MartinSimango Jun 24, 2024
a060bc2
Document the config package
MartinSimango Jun 25, 2024
20c6bf1
Clean up interface for generated struct and implement
MartinSimango Aug 27, 2024
bc8473b
Fix bug where unexported fields were not intially being set
MartinSimango Aug 29, 2024
633d207
refactor generation function code
MartinSimango Oct 5, 2024
35a411f
fix bug where generation function was not restting after function hol…
MartinSimango Oct 13, 2024
5b00273
Update README.md
MartinSimango Oct 13, 2024
73d8503
fix config propagation bug
MartinSimango Oct 16, 2024
ec007f9
document drelect package
MartinSimango Oct 16, 2024
c04125b
Document function
MartinSimango Oct 17, 2024
8b5f20b
add builder examples and fix bugs within builder
MartinSimango Oct 17, 2024
afa438e
rename folders and clean up some code
MartinSimango Oct 17, 2024
57a1a35
finish adding examples for builder
MartinSimango Oct 18, 2024
a557af8
fix bugs when generating pointers and custom types
MartinSimango Oct 27, 2024
7a949a0
OA
MartinSimango Oct 27, 2024
373c905
fix bugs - improve task code and add task example code
MartinSimango Nov 5, 2024
7c78b49
Update README
MartinSimango Nov 5, 2024
d59277f
Update README.md
MartinSimango Nov 5, 2024
46df1e6
feat: update generation settings
MartinSimango Nov 9, 2024
74c0699
chore: update dagger engine version and nsv version
MartinSimango Nov 23, 2024
7938f5f
chore: start adding changes for automating releases with dagger and s…
MartinSimango Dec 12, 2024
3c00643
feat: modify dagger release code
MartinSimango Jan 12, 2025
f2e6df5
Merge branch 'main' into feat/update-generation-settings
MartinSimango Jan 12, 2025
42e7477
feat: use type hashes for custom types
MartinSimango Feb 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release

on:
push:
branches:
- '**'


jobs:
dagger-go-flow:
name: dagger-go-flow
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/Checkout@v3
- name: Dagger Go Flow
uses: dagger/dagger-for-github@v6
with:
version: "latest"
verb: call
module: github.com/felipecruz91/daggerverse/go
args: test --source=. --go-version=1.23 stdout
#args: --help

15 changes: 15 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
branches:
- "feat/update-generation-settings"
plugins:
- - "@semantic-release/commit-analyzer"
- preset: conventionalcommits
- - "@semantic-release/release-notes-generator"
- preset: conventionalcommits
- "@semantic-release/github"
- - "@semantic-release/changelog"
- assets:
- CHANGELOG.md
- - "@semantic-release/git"
- assets:
- CHANGELOG.md
tagFormat: ${version}
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ bench:

task-example:
go run examples/task/main.go

### ACT ###
act:
act -P ubuntu-latest=catthehacker/ubuntu:act-latest

23 changes: 23 additions & 0 deletions dagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "dagger",
"engineVersion": "v0.15.1",
"sdk": "go",
"dependencies": [
{
"name": "node",
"source": "github.com/dagger/dagger/sdk/typescript/dev/node",
"pin": "180573cf2a1359a7ce371f92a6b6d5fdde62c5a4"
},
{
"name": "goreleaser",
"source": "github.com/goreleaser/goreleaser@v2.4.8",
"pin": "377981ebd76e1bbb0dbe07d5428239ec8c5381a8"
},
{
"name": "nsv",
"source": "github.com/purpleclay/daggerverse/nsv@nsv/v0.10.1",
"pin": "424af485b7e79437e0a0f799d083edd3e843128e"
}
],
"source": "dagger"
}
4 changes: 4 additions & 0 deletions dagger/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/dagger.gen.go linguist-generated
/internal/dagger/** linguist-generated
/internal/querybuilder/** linguist-generated
/internal/telemetry/** linguist-generated
4 changes: 4 additions & 0 deletions dagger/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/dagger.gen.go
/internal/dagger
/internal/querybuilder
/internal/telemetry
50 changes: 50 additions & 0 deletions dagger/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
module dagger/dagger

go 1.23.2

require (
github.com/99designs/gqlgen v0.17.55
github.com/Khan/genqlient v0.7.0
github.com/vektah/gqlparser/v2 v2.5.17
go.opentelemetry.io/otel v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
go.opentelemetry.io/otel/log v0.3.0
go.opentelemetry.io/otel/metric v1.27.0
go.opentelemetry.io/otel/sdk v1.27.0
go.opentelemetry.io/otel/sdk/log v0.3.0
go.opentelemetry.io/otel/sdk/metric v1.27.0
go.opentelemetry.io/otel/trace v1.27.0
go.opentelemetry.io/proto/otlp v1.3.1
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
golang.org/x/sync v0.8.0
google.golang.org/grpc v1.65.0
)

require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
github.com/sosodev/duration v1.3.1 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.18.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
google.golang.org/protobuf v1.34.2 // indirect
)

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88

replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0

replace go.opentelemetry.io/otel/log => go.opentelemetry.io/otel/log v0.3.0

replace go.opentelemetry.io/otel/sdk/log => go.opentelemetry.io/otel/sdk/log v0.3.0
83 changes: 83 additions & 0 deletions dagger/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM=
github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo=
github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w=
github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ=
github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8=
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4=
github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/vektah/gqlparser/v2 v2.5.17 h1:9At7WblLV7/36nulgekUgIaqHZWn5hxqluxrxGUhOmI=
github.com/vektah/gqlparser/v2 v2.5.17/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg=
go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88/go.mod h1:JGG8ebaMO5nXOPnvKEl+DiA4MGwFjCbjsxT1WHIEBPY=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 h1:ccBrA8nCY5mM0y5uO7FT0ze4S0TuFcWdDB2FxGMTjkI=
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0/go.mod h1:/9pb6634zi2Lk8LYg9Q0X8Ar6jka4dkFOylBLbVQPCE=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0 h1:bFgvUr3/O4PHj3VQcFEuYKvRZJX1SJDQ+11JXuSB3/w=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v1.27.0/go.mod h1:xJntEd2KL6Qdg5lwp97HMLQDVeAhrYxmzFseAMDPQ8I=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0 h1:CIHWikMsN3wO+wq1Tp5VGdVRTcON+DmOJSfDjXypKOc=
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetrichttp v1.27.0/go.mod h1:TNupZ6cxqyFEpLXAZW7On+mLFL0/g0TE3unIYL91xWc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 h1:R9DE4kQ4k+YtfLI2ULwX82VtNQ2J8yZmA7ZIF/D+7Mc=
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0/go.mod h1:OQFyQVrDlbe+R7xrEyDr/2Wr67Ol0hRUgsfA+V5A95s=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0 h1:qFffATk0X+HD+f1Z8lswGiOQYKHRlzfmdJm0wEaVrFA=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0/go.mod h1:MOiCmryaYtc+V0Ei+Tx9o5S1ZjA7kzLucuVuyzBZloQ=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0 h1:QY7/0NeRPKlzusf40ZE4t1VlMKbqSNT7cJRYzWuja0s=
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0/go.mod h1:HVkSiDhTM9BoUJU8qE6j2eSWLLXvi1USXjyd2BXT8PY=
go.opentelemetry.io/otel/log v0.3.0 h1:kJRFkpUFYtny37NQzL386WbznUByZx186DpEMKhEGZs=
go.opentelemetry.io/otel/log v0.3.0/go.mod h1:ziCwqZr9soYDwGNbIL+6kAvQC+ANvjgG367HVcyR/ys=
go.opentelemetry.io/otel/metric v1.27.0 h1:hvj3vdEKyeCi4YaYfNjv2NUje8FqKqUY8IlF0FxV/ik=
go.opentelemetry.io/otel/metric v1.27.0/go.mod h1:mVFgmRlhljgBiuk/MP/oKylr4hs85GZAylncepAX/ak=
go.opentelemetry.io/otel/sdk v1.27.0 h1:mlk+/Y1gLPLn84U4tI8d3GNJmGT/eXe3ZuOXN9kTWmI=
go.opentelemetry.io/otel/sdk v1.27.0/go.mod h1:Ha9vbLwJE6W86YstIywK2xFfPjbWlCuwPtMkKdz/Y4A=
go.opentelemetry.io/otel/sdk/log v0.3.0 h1:GEjJ8iftz2l+XO1GF2856r7yYVh74URiF9JMcAacr5U=
go.opentelemetry.io/otel/sdk/log v0.3.0/go.mod h1:BwCxtmux6ACLuys1wlbc0+vGBd+xytjmjajwqqIul2g=
go.opentelemetry.io/otel/sdk/metric v1.27.0 h1:5uGNOlpXi+Hbo/DRoI31BSb1v+OGcpv2NemcCrOL8gI=
go.opentelemetry.io/otel/sdk/metric v1.27.0/go.mod h1:we7jJVrYN2kh3mVBlswtPU22K0SA+769l93J6bsyvqw=
go.opentelemetry.io/otel/trace v1.27.0 h1:IqYb813p7cmbHk0a5y6pD5JPakbVfftRXABGt5/Rscw=
go.opentelemetry.io/otel/trace v1.27.0/go.mod h1:6RiD1hkAprV4/q+yd2ln1HG9GoPx39SuvvstaLBl+l4=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ=
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8=
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU=
google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc=
google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ=
google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg=
google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
56 changes: 56 additions & 0 deletions dagger/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// A generated module for Dagger functions
//
// This module has been generated via dagger init and serves as a reference to
// basic module structure as you get started with Dagger.
//
// Two functions have been pre-created. You can modify, delete, or add to them,
// as needed. They demonstrate usage of arguments and return types using simple
// echo and grep commands. The functions can be called from the dagger CLI or
// from one of the SDKs.
//
// The first line in this comment block is a short description line and the
// rest is a long description with more detail on the module's purpose or usage,
// if appropriate. All modules should have a short description.

package main

import (
"context"
"dagger/dagger/internal/dagger"
)

type Dagger struct{}

// Returns a container that echoes whatever string argument is provided
func (m *Dagger) Release(ctx context.Context, source *dagger.Directory) (string, error){


return dag.Node(dagger.NodeOpts{
Version: "21"}).
WithNpm().
WithSource(source).
Container().
WithExec([]string{"npm", "install","--save-dev","@semantic-release/git"}).
WithExec([]string{"npm","install","--save-dev","@semantic-release/changelog"}).
WithExec([]string{"npx","semantic-release"}).
Stdout(ctx)

// Commands().
// Run([]string{"npx", "semantic-release", "--version"}).
// Stdout(ctx)



// version, err := dag.Nsv(source).Next(ctx, dagger.NsvNextOpts{Show: true})
// if err != nil {
// return "", err
// }
//
// fmt.Println("Version: ", version)
//
// return dag.Goreleaser(dagger.GoreleaserOpts{Source: source}).Test().Output(ctx)




}
36 changes: 36 additions & 0 deletions dreflect/dreflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,47 @@
package dreflect

import (
"crypto/sha256"
"fmt"
"reflect"
"unsafe"
)

// GetTypeHash recursively generates a hash based on struct type
func GetTypeHash(v interface{}) string {
t := reflect.TypeOf(v) // Get type

// If it's a pointer, dereference
if t.Kind() == reflect.Ptr {
t = t.Elem()
}

// Base case: If it's not a struct, just return type name
if t.Kind() != reflect.Struct {
return t.String()
}

// Construct type signature
typeSignature := t.String() + "{"
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
fieldType := field.Type

// If field is a struct, recurse
if fieldType.Kind() == reflect.Struct {
typeSignature += field.Name + ":" + GetTypeHash(
reflect.New(fieldType).Elem().Interface(),
) + ";"
} else {
typeSignature += field.Name + ":" + fieldType.String() + ";"
}
}
typeSignature += "}"
// Compute SHA-256 hash
hash := sha256.Sum256([]byte(typeSignature))
return fmt.Sprintf("%x", hash) // Return as hex string
}

// GetPointerOfValueType returns a pointer to a new value of the same type as the input value `val`.
// The new value is initialized to the input value.
func GetPointerOfValueType(val any) any {
Expand Down
10 changes: 5 additions & 5 deletions dstruct.generated.struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ func (gs *DStructGeneratedStruct[T]) addCustomTypes() {

func (gs *DStructGeneratedStruct[T]) AddCustomType(customType CustomType) {
// TODO: restrict some types from being added such as nil, ints etc
gs.customTypes[reflect.TypeOf(customType.Value).String()] = customType.FunctionHolder
gs.customTypes[dreflect.GetTypeHash(customType.Value)] = customType.FunctionHolder
// the function holder kind is the find that the function retrusn which could either be an existing kind or a new kind i.ie time.Time would be a new kind
// TODO:idea: GenerationsFunction key should be type of CustomKind and not reflect.Kind
gs.structConfig.GenerationFunctions[customType.FunctionHolder.Kind()] = customType.FunctionHolder
Expand All @@ -353,7 +353,7 @@ func (gs *DStructGeneratedStruct[T]) createGeneratedField(
field.data.tag,
gs.structConfig.Copy(kind),
gs.customTypes,
field.data.goType)
field.data.typeHash)
return v
}

Expand All @@ -363,7 +363,7 @@ func (gs *DStructGeneratedStruct[T]) populateGeneratedFields(node *Node[StructFi
continue
}

if customType := gs.customTypes[field.data.goType]; customType != nil {
if customType := gs.customTypes[field.data.typeHash]; customType != nil {
gs.fieldContexts[field.data.qualifiedName] = core.NewGeneratedFieldContext(
gs.createGeneratedField(field, customType.Kind()),
)
Expand All @@ -383,7 +383,7 @@ func (gs *DStructGeneratedStruct[T]) propagateConfig(
) {
for _, field := range node.children {
// Don't propagate changes to children nodes if the field is a custom type
if field.HasChildren() && gs.customTypes[field.data.goType] == nil {
if field.HasChildren() && gs.customTypes[field.data.typeHash] == nil {
gs.propagateConfig(field, cfg)
} else {
gs.fieldContexts[field.data.qualifiedName].GeneratedField.SetConfig(cfg)
Expand All @@ -396,7 +396,7 @@ func (gs *DStructGeneratedStruct[T]) propagateSettings(
settings config.GenerationSettings,
) {
for _, field := range node.children {
if field.HasChildren() && gs.customTypes[field.data.goType] == nil {
if field.HasChildren() && gs.customTypes[field.data.typeHash] == nil {
gs.propagateSettings(field, settings)
} else {
gs.fieldContexts[field.data.qualifiedName].GeneratedField.SetGenerationSettings(settings)
Expand Down
4 changes: 2 additions & 2 deletions examples/builder/adding-a-field/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func errorExample_2() {
defer examples.RecoverFromPanic()
builder := dstruct.NewBuilder().
AddField("Person", Person{Name: "Martin", Age: 25, Address: Address{Street: "Jackson Street"}}, `json:"person"`).
AddField("Job Titile", "Software Developer", "")
AddField("Job Title", "Software Developer", "")

builder.Build() // This will panic because the field "Job Titile" is an invalid struct field name
builder.Build() // This will panic because the field "Job Title" is an invalid struct field name
}
Loading