Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ pkg/app/web/src/service
.ijwb
.idea

# Generated proto go files
*.embed.go

.dev

# Terraform workspace
Expand Down
3 changes: 0 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,3 @@ genrule(
# gazelle:exclude pkg/model/role.pb.validate.go
# gazelle:exclude pkg/model/user.pb.validate.go
# gazelle:exclude pkg/app/helloworld/service/service.pb.validate.go
# gazelle:exclude pkg/datastore/mysql/ensurer/sql.embed.go
# gazelle:exclude pkg/app/ops/handler/templates.embed.go
# gazelle:exclude pkg/app/ops/firestoreindexensurer/indexes.embed.go
7 changes: 0 additions & 7 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ go_register_toolchains(
go_version = "1.17.6",
)

load(
"@io_bazel_rules_go//extras:embed_data_deps.bzl",
"go_embed_data_dependencies",
)

go_embed_data_dependencies()

http_archive(
name = "bazel_gazelle",
sha256 = "de69a09dc70417580aabf20a28619bb3ef60d038470c7cf8442fafcf627c21cb",
Expand Down
19 changes: 0 additions & 19 deletions hack/expose-generated-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,25 +113,6 @@ for package in $(bazelisk query 'kind(gomock, //...)' --output package); do
expose_package ${out_path} ${package} old_links generated_files
done

############################
# For go_embed_data go files
############################

# Link to the generated files and add them to excluding list in the root BUILD file.
for label in $(bazelisk query 'kind(go_embed_data, //...)'); do
package="${label%%:*}"
package="${package##//}"
target="${label##*:}"
[[ -d "${package}" ]] || continue

# Compute the path where Bazel puts the files.
out_path="bazel-bin/${package}"

old_links=${package}/${target}.go
generated_files=${out_path}/${target}.go
expose_package ${out_path} ${package} old_links generated_files
done

# Reset the root BUILD file
cat ${GENERATED_BUILD_FILE} > ${BUILD_FILE}
rm ${GENERATED_BUILD_FILE}
136 changes: 0 additions & 136 deletions hack/gen-go-strings/main.go

This file was deleted.

12 changes: 1 addition & 11 deletions pkg/app/ops/firestoreindexensurer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ go_library(
"gcloud.go",
"indexensurer.go",
"indexes.go",
":indexes.embed", #keep
],
embedsrcs = ["indexes.json"],
importpath = "github.com/pipe-cd/pipecd/pkg/app/ops/firestoreindexensurer",
visibility = ["//visibility:public"],
deps = ["@org_uber_go_zap//:go_default_library"],
Expand All @@ -27,13 +27,3 @@ go_test(
"@com_github_stretchr_testify//require:go_default_library",
],
)

load("@io_bazel_rules_go//go:def.bzl", "go_embed_data")

go_embed_data(
name = "indexes.embed",
src = "indexes.json",
package = "firestoreindexensurer",
var = "indexesJSON",
visibility = ["//visibility:public"],
)
4 changes: 4 additions & 0 deletions pkg/app/ops/firestoreindexensurer/indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
package firestoreindexensurer

import (
_ "embed"
"encoding/json"
"fmt"
"strings"
)

//go:embed indexes.json
var indexesJSON []byte

// index represents a Firestore composite index.
type index struct {
CollectionGroup string `json:"collectionGroup"`
Expand Down
22 changes: 7 additions & 15 deletions pkg/app/ops/handler/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = [
"handler.go",
":templates.embed", #keep
srcs = ["handler.go"],
embedsrcs = [
"templates/AddProject",
"templates/AddedProject",
"templates/ApplicationCounts",
"templates/ListProjects",
"templates/Top",
],
importpath = "github.com/pipe-cd/pipecd/pkg/app/ops/handler",
visibility = ["//visibility:public"],
Expand All @@ -17,18 +21,6 @@ go_library(
],
)

load("@io_bazel_rules_go//go:def.bzl", "go_embed_data")

go_embed_data(
name = "templates.embed",
srcs = glob(["templates/*"]),
flatten = True,
package = "handler",
string = True,
var = "Templates",
visibility = ["//visibility:public"],
)

go_test(
name = "go_default_test",
size = "small",
Expand Down
14 changes: 9 additions & 5 deletions pkg/app/ops/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package handler

import (
"context"
"embed"
"fmt"
"html/template"
"net/http"
Expand All @@ -30,12 +31,15 @@ import (
"github.com/pipe-cd/pipecd/pkg/model"
)

//go:embed templates/*
var templateFS embed.FS

var (
topPageTmpl = template.Must(template.New("Top").Parse(Templates["Top"]))
listProjectsTmpl = template.Must(template.New("ListProjects").Parse(Templates["ListProjects"]))
applicationCountsTmpl = template.Must(template.New("ApplicationCounts").Parse(Templates["ApplicationCounts"]))
addProjectTmpl = template.Must(template.New("AddProject").Parse(Templates["AddProject"]))
addedProjectTmpl = template.Must(template.New("AddedProject").Parse(Templates["AddedProject"]))
topPageTmpl = template.Must(template.ParseFS(templateFS, "templates/Top"))
listProjectsTmpl = template.Must(template.ParseFS(templateFS, "templates/ListProjects"))
applicationCountsTmpl = template.Must(template.ParseFS(templateFS, "templates/ApplicationCounts"))
addProjectTmpl = template.Must(template.ParseFS(templateFS, "templates/AddProject"))
addedProjectTmpl = template.Must(template.ParseFS(templateFS, "templates/AddedProject"))
)

type projectStore interface {
Expand Down
2 changes: 0 additions & 2 deletions pkg/app/server/grpcapi/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,3 @@ go_test(
"@org_uber_go_zap//:go_default_library",
],
)

load("@io_bazel_rules_go//go:def.bzl", "go_embed_data")
18 changes: 4 additions & 14 deletions pkg/datastore/mysql/ensurer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ go_library(
name = "go_default_library",
srcs = [
"client.go",
"sql.embed", #keep
"sqlsensurer.go",
],
embedsrcs = [
"indexes.sql",
"schema.sql",
],
importpath = "github.com/pipe-cd/pipecd/pkg/datastore/mysql/ensurer",
visibility = ["//visibility:public"],
deps = [
Expand All @@ -16,19 +19,6 @@ go_library(
],
)

load("@io_bazel_rules_go//go:def.bzl", "go_embed_data")

go_embed_data(
name = "sql.embed",
srcs = [
"indexes.sql",
"schema.sql",
],
package = "ensurer",
string = True,
var = "mysqlProperties",
)

go_test(
name = "go_default_test",
size = "small",
Expand Down
7 changes: 5 additions & 2 deletions pkg/datastore/mysql/ensurer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package ensurer
import (
"context"
"database/sql"
_ "embed"
"fmt"
"strings"

Expand All @@ -27,8 +28,10 @@ import (
)

var (
mysqlDatabaseSchema = mysqlProperties_1
mysqlDatabaseIndexes = mysqlProperties_0
//go:embed schema.sql
mysqlDatabaseSchema string
//go:embed indexes.sql
mysqlDatabaseIndexes string
)

const (
Expand Down