Skip to content

Commit

Permalink
fix: bouk/staticfiles is deprecated #11654
Browse files Browse the repository at this point in the history
Signed-off-by: Son Bui <[email protected]>
  • Loading branch information
sonbui00 committed Aug 29, 2023
1 parent 01cb204 commit 542605d
Show file tree
Hide file tree
Showing 15 changed files with 350 additions and 117 deletions.
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ run:
- sdks
- ui
- vendor
skip-files:
- server/static/files.go
build-tags:
- api
- cli
Expand Down
32 changes: 10 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -164,22 +164,6 @@ ui/dist/app/index.html: $(shell find ui/src -type f && find ui -maxdepth 1 -type
# `yarn build` is slow, so we guard it with a up-to-date check.
JOBS=max yarn --cwd ui build

$(GOPATH)/bin/staticfiles:
# update this in Nix when updating it here
ifneq ($(USE_NIX), true)
go install bou.ke/staticfiles@dd04075
endif

ifeq ($(STATIC_FILES),true)
server/static/files.go: $(GOPATH)/bin/staticfiles ui/dist/app/index.html
# Pack UI into a Go file
$(GOPATH)/bin/staticfiles -o server/static/files.go ui/dist/app
else
server/static/files.go:
# Building without static files
cp ./server/static/files.go.stub ./server/static/files.go
endif

dist/argo-linux-amd64: GOARGS = GOOS=linux GOARCH=amd64
dist/argo-linux-arm64: GOARGS = GOOS=linux GOARCH=arm64
dist/argo-linux-ppc64le: GOARGS = GOOS=linux GOARCH=ppc64le
Expand All @@ -191,16 +175,16 @@ dist/argo-windows-amd64: GOARGS = GOOS=windows GOARCH=amd64
dist/argo-windows-%.gz: dist/argo-windows-%
gzip --force --keep dist/argo-windows-$*.exe

dist/argo-windows-%: server/static/files.go $(CLI_PKGS) go.sum
dist/argo-windows-%: ui/dist/app/index.html $(CLI_PKGS) go.sum
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@.exe ./cmd/argo

dist/argo-%.gz: dist/argo-%
gzip --force --keep dist/argo-$*

dist/argo-%: server/static/files.go $(CLI_PKGS) go.sum
dist/argo-%: ui/dist/app/index.html $(CLI_PKGS) go.sum
CGO_ENABLED=0 $(GOARGS) go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS} -extldflags -static' -o $@ ./cmd/argo

dist/argo: server/static/files.go $(CLI_PKGS) go.sum
dist/argo: ui/dist/app/index.html $(CLI_PKGS) go.sum
ifeq ($(shell uname -s),Darwin)
# if local, then build fast: use CGO and dynamic-linking
go build -v -gcflags '${GCFLAGS}' -ldflags '${LDFLAGS}' -o $@ ./cmd/argo
Expand Down Expand Up @@ -444,7 +428,7 @@ $(GOPATH)/bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b `go env GOPATH`/bin v1.52.2

.PHONY: lint
lint: server/static/files.go $(GOPATH)/bin/golangci-lint
lint: $(GOPATH)/bin/golangci-lint
rm -Rf v3 vendor
# If you're using `woc.wf.Spec` or `woc.execWf.Status` your code probably won't work with WorkflowTemplate.
# * Change `woc.wf.Spec` to `woc.execWf.Spec`.
Expand All @@ -461,7 +445,7 @@ lint: server/static/files.go $(GOPATH)/bin/golangci-lint

# for local we have a faster target that prints to stdout, does not use json, and can cache because it has no coverage
.PHONY: test
test: server/static/files.go
test: ui/dist/app
go build ./...
env KUBECONFIG=/dev/null $(GOTEST) ./...
# marker file, based on it's modification time, we know how long ago this target was run
Expand Down Expand Up @@ -670,9 +654,13 @@ docs/fields.md: api/openapi-spec/swagger.json $(shell find examples -type f) hac
env ARGO_SECURE=false ARGO_INSECURE_SKIP_VERIFY=false ARGO_SERVER= ARGO_INSTANCEID= go run ./hack docgen

# generates several other files
docs/cli/argo.md: $(CLI_PKGS) go.sum server/static/files.go hack/cli/main.go
docs/cli/argo.md: $(CLI_PKGS) go.sum ui/dist/app hack/cli/main.go
go run ./hack/cli

ui/dist/app:
@mkdir -p ui/dist/app
touch ui/dist/app/json.worker.js

# docs

/usr/local/bin/mdspell:
Expand Down
1 change: 0 additions & 1 deletion dev/nix/conf.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# Even then the buildFlags are not passed into Go, meaning you won't see the correct version info yet.
# This is only intended for quick developing at the moment, gradually more functionality will be pushed here.
rec {
staticFiles = false; # not acted upon
version = "latest";
env = {
DEFAULT_REQUEUE_TIME = "1s";
Expand Down
74 changes: 46 additions & 28 deletions dev/nix/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 0 additions & 13 deletions dev/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -307,17 +307,6 @@
doCheck = false;
};

staticfiles = pkgs.buildGoPackage rec {
name = "staticfiles";
src = pkgs.fetchFromGitHub {
owner = "bouk";
repo = "staticfiles";
rev = "827d7f6389cd410d0aa3f3d472a4838557bf53dd";
sha256 = "0xarhmsqypl8036w96ssdzjv3k098p2d4mkmw5f6hkp1m3j67j61";
};

goPackagePath = "bou.ke/staticfiles";
};
default = config.packages.${package.name};
};

Expand All @@ -338,7 +327,6 @@
config.packages.k8sio-tools
config.packages.goreman
config.packages.stern
config.packages.staticfiles
config.packages.${package.name}
nodePackages.shell.nodeDependencies
gopls
Expand Down Expand Up @@ -368,7 +356,6 @@
config.packages.k8sio-tools
config.packages.goreman
config.packages.stern
config.packages.staticfiles
config.packages.${package.name}
nodePackages.shell.nodeDependencies
gopls
Expand Down
3 changes: 2 additions & 1 deletion server/apiserver/argoserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import (
"github.com/argoproj/argo-workflows/v3/server/workflow"
"github.com/argoproj/argo-workflows/v3/server/workflowarchive"
"github.com/argoproj/argo-workflows/v3/server/workflowtemplate"
"github.com/argoproj/argo-workflows/v3/ui"
grpcutil "github.com/argoproj/argo-workflows/v3/util/grpc"
"github.com/argoproj/argo-workflows/v3/util/instanceid"
"github.com/argoproj/argo-workflows/v3/util/json"
Expand Down Expand Up @@ -407,7 +408,7 @@ func (as *argoServer) newHTTPServer(ctx context.Context, port int, artifactServe

})
// we only enable HTST if we are secure mode, otherwise you would never be able access the UI
mux.HandleFunc("/", static.NewFilesServer(as.baseHRef, as.tlsConfig != nil && as.hsts, as.xframeOptions, as.accessControlAllowOrigin).ServerFiles)
mux.HandleFunc("/", static.NewFilesServer(as.baseHRef, as.tlsConfig != nil && as.hsts, as.xframeOptions, as.accessControlAllowOrigin, ui.Embedded).ServerFiles)
return &httpServer
}

Expand Down
8 changes: 0 additions & 8 deletions server/static/files.go

This file was deleted.

8 changes: 0 additions & 8 deletions server/static/files.go.stub

This file was deleted.

20 changes: 0 additions & 20 deletions server/static/response-rewriter.go

This file was deleted.

Loading

0 comments on commit 542605d

Please sign in to comment.