Skip to content

Commit

Permalink
search greatness: enable search resolver generation (#44)
Browse files Browse the repository at this point in the history
* get it clean

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* generated against entx + gqlgen-plugin changes

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* go mod entx

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* regen

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix gomod

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix output

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix output

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix admin search

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* update entx + gqlgen-plugin versions

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix up search for json

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* bump entx and gqlgen-plugins versions

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* bk pipeline to use ghcr.io/theopenlane/build-image:latest

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* GOFLAGS: -buildvcs=false

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* use task commands in ci

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* put that GOFLAGS: -buildvcs=false back

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fix build task command

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

---------

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
  • Loading branch information
golanglemonade authored Sep 10, 2024
1 parent dabde8e commit 4176551
Show file tree
Hide file tree
Showing 78 changed files with 18,549 additions and 2,658 deletions.
34 changes: 20 additions & 14 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ steps:
cancel_on_build_failing: true
plugins:
- docker#v5.11.0:
image: "ghcr.io/theopenlane/build-image:v0.1.2"
image: "ghcr.io/theopenlane/build-image:latest"
always_pull: true
command: ["task", "ci"]
environment:
- "GOTOOLCHAIN=auto"
Expand All @@ -23,7 +24,8 @@ steps:
cancel_on_build_failing: true
plugins:
- docker#v5.11.0:
image: "ghcr.io/theopenlane/build-image:v0.1.2"
image: "ghcr.io/theopenlane/build-image:latest"
always_pull: true
command: ["task", "config:ci"]
environment:
- "GOTOOLCHAIN=auto"
Expand All @@ -35,8 +37,8 @@ steps:
key: "lint"
plugins:
- docker#v5.11.0:
image: "golangci/golangci-lint:latest-alpine"
command: ["golangci-lint", "run", "-v", "--timeout", "10m", "--config", ".golangci.yaml", "--concurrency", "0"]
image: "ghcr.io/theopenlane/build-image:latest"
command: ["task", "go:lint"]
always_pull: true
environment:
- "GOTOOLCHAIN=auto"
Expand All @@ -51,8 +53,9 @@ steps:
TEST_DB_URL: "libsql://file::memory:?cache=shared"
plugins:
- docker#v5.11.0:
image: golang:1.23.0
command: ["go", "test", "-coverprofile=coverage.out", "./..."]
image: ghcr.io/theopenlane/build-image:latest
always_pull: true
command: ["task", "go:test:cover"]
environment:
- "TEST_DB_URL"
artifact_paths: ["coverage.out"]
Expand All @@ -70,8 +73,9 @@ steps:
- "sqlite://file:ent?mode=memory&cache=shared"
plugins:
- docker#v5.11.0:
image: golang:1.23.0
command: ["go", "test", "-coverprofile=coverage.out", "./..."]
image: ghcr.io/theopenlane/build-image:latest
always_pull: true
command: ["task", "go:test:cover"]
environment:
- "TEST_DB_URL"
- "TEST_DB_CONTAINER_EXPIRY=8" # container expiry in minutes
Expand All @@ -93,7 +97,7 @@ steps:
key: "gosec"
plugins:
- docker#v5.11.0:
image: "registry.hub.docker.com/securego/gosec:2.20.0"
image: "securego/gosec:2.20.0"
command: ["-no-fail", "-exclude-generated", "-fmt sonarqube", "-out", "results.txt", "./..."]
environment:
- "GOTOOLCHAIN=auto"
Expand Down Expand Up @@ -137,21 +141,23 @@ steps:
artifact_paths: "bin/${APP_NAME}"
plugins:
- docker#v5.11.0:
image: "golang:1.23.0"
image: "ghcr.io/theopenlane/build-image:latest"
always_pull: true
environment:
- CGO_ENABLED=0
- GOOS=linux
command: ["go", "build", "-buildvcs=false", "-mod=mod", "-a", "-o", "bin/$APP_NAME"]
command: ["task", "go:build:ci"]
- label: ":terminal: build cli"
key: "gobuild-cli"
artifact_paths: "bin/${APP_NAME}-cli"
artifact_paths: "bin/openlane-cli"
plugins:
- docker#v5.11.0:
image: "golang:1.23.0"
image: "ghcr.io/theopenlane/build-image:latest"
always_pull: true
environment:
- GOOS=darwin
- GOARCH=arm64
command: ["go", "build", "-buildvcs=false", "-mod=mod", "-a", "-o", "bin/${APP_NAME}-cli", "./cmd/cli"]
command: ["task", "go:build-cli:ci"]
- group: ":database: atlas migrate"
key: "database"
steps:
Expand Down
21 changes: 19 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ env:
TEST_FGA_URL: "localhost:8080"
ENV: config
GODEBUG: gotypesalias=0 # remove once the backport fixes the types.Alias bug
GOFLAGS: -buildvcs=false

tasks:
default:
Expand Down Expand Up @@ -65,6 +66,12 @@ tasks:
aliases: [cover]
cmds:
- go test -v ./... -coverprofile=coverage.out

go:test:coverout:
desc: runs and outputs results of created go tests with coverage
aliases: [cover]
cmds:
- task: go:test:cover
- go tool cover -html=coverage.out

go:fmt:
Expand All @@ -83,12 +90,22 @@ tasks:
cmds:
- go build -mod=mod -o core

go:build:ci:
desc: Runs go build for the core server
cmds:
- go build -mod=mod -a -o bin/core

go:build-cli:
aliases: [buildcli]
desc: Runs go build for the openlane cli
cmds:
- go build -mod=mod -o openlane-cli ./cmd/cli

go:build-cli:ci:
desc: Runs go build for the openlane cli in CI
cmds:
- go build -mod=mod -a -o bin/openlane-cli ./cmd/cli

go:all:
aliases: [go]
desc: Runs all go test and lint related tasks
Expand Down Expand Up @@ -138,10 +155,10 @@ tasks:
fi
clean:local:
desc: cleans up core.db and core-cli local
desc: cleans up core.db and openlane-cli local
cmds:
- "rm -f core.db"
- "rm -f core-cli"
- "rm -f openlane-cli"
- task: buildcli

shell:
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cmd/apitokens/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the output in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/cli/cmd/contact/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func init() {
createCmd.Flags().StringP("phone", "p", "", "phone number of the contact")
createCmd.Flags().StringP("title", "t", "", "title of the contact")
createCmd.Flags().StringP("company", "c", "", "company of the contact")
createCmd.Flags().StringSlice("tags", []string{}, "tags associated with the contact")
}

// createValidation validates the required fields for the command
Expand Down Expand Up @@ -57,6 +58,11 @@ func createValidation() (input openlaneclient.CreateContactInput, err error) {
input.Company = &company
}

tags := cmd.Config.Strings("tags")
if len(tags) > 0 {
input.Tags = tags
}

return input, nil
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/contact/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package contact

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the contacts in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/contacthistory/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package contacthistory

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the contactHistories in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/documentdatahistory/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package documentdatahistory

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the documentDataHistories in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitlementhistory/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitlementhistory

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the entitlementHistories in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitlementplan/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitlementplan

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the plans in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the plans in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitlementplanfeaturehistory/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitlementplanfeaturehistory

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the entitlementPlanFeatureHistories in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitlementplanfeatures/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitlementplanfeatures

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the planFeatures in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitlementplanhistory/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitlementplanhistory

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the entitlementPlanHistories in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitlements/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitlement

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the output in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
6 changes: 6 additions & 0 deletions cmd/cli/cmd/entity/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func init() {
createCmd.Flags().String("status", "", "status of the entity")
createCmd.Flags().StringSlice("domains", []string{}, "domains associated with the entity")
createCmd.Flags().String("note", "", "note about the entity")
createCmd.Flags().StringSlice("tags", []string{}, "tags associated with the entity")
}

// createValidation validates the required fields for the command
Expand Down Expand Up @@ -83,6 +84,11 @@ func createValidation(ctx context.Context) (input openlaneclient.CreateEntityInp
}
}

tags := cmd.Config.Strings("tags")
if len(tags) > 0 {
input.Tags = tags
}

return input, nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cmd/entity/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the entities in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entityhistory/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entityhistory

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the entityHistories in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
3 changes: 2 additions & 1 deletion cmd/cli/cmd/entitytype/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package entitytype

import (
"encoding/json"
"strings"

"github.com/spf13/cobra"

Expand All @@ -24,7 +25,7 @@ func init() {
// consoleOutput prints the output in the console
func consoleOutput(e any) error {
// check if the output format is JSON and print the entity types in JSON format
if cmd.OutputFormat == cmd.JSONOutput {
if strings.EqualFold(cmd.OutputFormat, cmd.JSONOutput) {
return jsonOutput(e)
}

Expand Down
Loading

0 comments on commit 4176551

Please sign in to comment.