-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #94 from defenseunicorns/go-api
First golang generation
- Loading branch information
Showing
77 changed files
with
3,311 additions
and
1,314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM cgr.dev/chainguard/go:1.20 as build | ||
|
||
WORKDIR /work | ||
|
||
ADD go.mod . | ||
ADD go.sum . | ||
ADD api api | ||
ADD pkg pkg | ||
ADD api/models.toml . | ||
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags '-extldflags "-static"' -o app api/main.go | ||
|
||
|
||
FROM cgr.dev/chainguard/static:latest | ||
COPY --from=build /work/app /app | ||
COPY api/models.toml . | ||
|
||
EXPOSE 8080 | ||
CMD ["/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/BurntSushi/toml" | ||
) | ||
|
||
type Config map[string]Model | ||
|
||
type Model struct { | ||
Metadata Metadata `toml:"metadata"` | ||
Network Network `toml:"network"` | ||
} | ||
|
||
type Metadata struct { | ||
OwnedBy string `toml:"owned_by"` | ||
Permission []string `toml:"permission"` | ||
Description string `toml:"description"` | ||
Tasks []string `toml:"tasks"` | ||
} | ||
|
||
type Network struct { | ||
URL string `toml:"url"` | ||
Type string `toml:"type"` | ||
} | ||
|
||
func LoadConfig(path string) (Config, error) { | ||
var config Config | ||
_, err := toml.DecodeFile(path, &config) | ||
|
||
return config, err | ||
} |
Oops, something went wrong.