From e8df9c8307701754e067b70f78e442ca0709291e Mon Sep 17 00:00:00 2001 From: Lucas Lara Date: Thu, 19 May 2022 06:57:28 +0200 Subject: [PATCH] Move source files out of plugin folder --- build.sh | 2 - {plugin/caddyfile => caddyfile}/caddyfile.go | 0 {plugin/caddyfile => caddyfile}/fromlabels.go | 0 .../fromlabels_test.go | 0 {plugin/caddyfile => caddyfile}/lexer.go | 0 {plugin/caddyfile => caddyfile}/marshal.go | 0 .../caddyfile => caddyfile}/marshal_test.go | 0 {plugin/caddyfile => caddyfile}/merge.go | 0 {plugin/caddyfile => caddyfile}/merge_test.go | 0 {plugin/caddyfile => caddyfile}/processor.go | 0 .../caddyfile => caddyfile}/processor_test.go | 0 .../labels/follow_alphabetical_order.txt | 0 .../testdata/labels/global_options.txt | 0 .../labels/global_options_comes_first.txt | 0 .../testdata/labels/grouping.txt | 0 .../labels/isolate_directives_with_suffix.txt | 0 .../testdata/labels/matchers_come_first.txt | 0 .../labels/one_line_matchers_come_first.txt | 0 ...der_and_isolate_directives_with_prefix.txt | 0 .../testdata/labels/quotes.txt | 0 .../testdata/labels/snippets_come_first.txt | 0 .../testdata/labels/template_error.txt | 0 .../labels/templates_empty_values.txt | 0 .../testdata/labels/wildcard_certificates.txt | 38 +++++++++---------- .../testdata/marshal/marshal.txt | 0 .../merge/php_fastcgi_different_matcher.txt | 0 .../testdata/merge/php_fastcgi_no_matcher.txt | 0 .../merge/php_fastcgi_same_matcher.txt | 0 .../merge/reverse_proxy_different_matcher.txt | 0 .../merge/reverse_proxy_no_matcher.txt | 0 .../merge/reverse_proxy_same_matcher.txt | 0 .../testdata/process/blank.txt | 0 .../testdata/process/empty.txt | 0 .../testdata/process/invalid_block.txt | 0 .../testdata/process/invalid_file.txt | 0 plugin/cmd.go => cmd.go | 6 +-- {plugin/config => config}/options.go | 0 {plugin/docker => docker}/client.go | 0 {plugin/docker => docker}/client_mock.go | 0 {plugin/docker => docker}/utils.go | 0 {plugin/docker => docker}/utils_mock.go | 0 {plugin/docker => docker}/utils_test.go | 0 {plugin/generator => generator}/containers.go | 2 +- .../containers_test.go | 2 +- {plugin/generator => generator}/generator.go | 6 +-- .../generator => generator}/generator_test.go | 4 +- {plugin/generator => generator}/labels.go | 2 +- .../generator => generator}/labels_test.go | 0 {plugin/generator => generator}/services.go | 2 +- .../generator => generator}/services_test.go | 2 +- .../testdata/labels/all_special_labels.txt | 0 .../labels/doesnt_override_existing_proxy.txt | 0 .../testdata/labels/h2c_reverse_proxy.txt | 0 .../testdata/labels/invalid_template.txt | 0 .../labels/minimum_special_labels.txt | 0 .../testdata/labels/multiple_addresses.txt | 0 .../testdata/labels/multiple_configs.txt | 0 ..._proxy_directives_are_moved_into_route.txt | 0 .../testdata/labels/with_groups.txt | 0 plugin/loader.go => loader.go | 17 +++++---- main.go | 5 --- {plugin => utils}/stringBoolCMap.go | 4 +- {plugin => utils}/stringInt64CMap.go | 4 +- 63 files changed, 45 insertions(+), 51 deletions(-) rename {plugin/caddyfile => caddyfile}/caddyfile.go (100%) rename {plugin/caddyfile => caddyfile}/fromlabels.go (100%) rename {plugin/caddyfile => caddyfile}/fromlabels_test.go (100%) rename {plugin/caddyfile => caddyfile}/lexer.go (100%) rename {plugin/caddyfile => caddyfile}/marshal.go (100%) rename {plugin/caddyfile => caddyfile}/marshal_test.go (100%) rename {plugin/caddyfile => caddyfile}/merge.go (100%) rename {plugin/caddyfile => caddyfile}/merge_test.go (100%) rename {plugin/caddyfile => caddyfile}/processor.go (100%) rename {plugin/caddyfile => caddyfile}/processor_test.go (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/follow_alphabetical_order.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/global_options.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/global_options_comes_first.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/grouping.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/isolate_directives_with_suffix.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/matchers_come_first.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/one_line_matchers_come_first.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/order_and_isolate_directives_with_prefix.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/quotes.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/snippets_come_first.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/template_error.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/templates_empty_values.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/labels/wildcard_certificates.txt (95%) rename {plugin/caddyfile => caddyfile}/testdata/marshal/marshal.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/merge/php_fastcgi_different_matcher.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/merge/php_fastcgi_no_matcher.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/merge/php_fastcgi_same_matcher.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/merge/reverse_proxy_different_matcher.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/merge/reverse_proxy_no_matcher.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/merge/reverse_proxy_same_matcher.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/process/blank.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/process/empty.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/process/invalid_block.txt (100%) rename {plugin/caddyfile => caddyfile}/testdata/process/invalid_file.txt (100%) rename plugin/cmd.go => cmd.go (98%) rename {plugin/config => config}/options.go (100%) rename {plugin/docker => docker}/client.go (100%) rename {plugin/docker => docker}/client_mock.go (100%) rename {plugin/docker => docker}/utils.go (100%) rename {plugin/docker => docker}/utils_mock.go (100%) rename {plugin/docker => docker}/utils_test.go (100%) rename {plugin/generator => generator}/containers.go (93%) rename {plugin/generator => generator}/containers_test.go (99%) rename {plugin/generator => generator}/generator.go (97%) rename {plugin/generator => generator}/generator_test.go (97%) rename {plugin/generator => generator}/labels.go (93%) rename {plugin/generator => generator}/labels_test.go (100%) rename {plugin/generator => generator}/services.go (97%) rename {plugin/generator => generator}/services_test.go (99%) rename {plugin/generator => generator}/testdata/labels/all_special_labels.txt (100%) rename {plugin/generator => generator}/testdata/labels/doesnt_override_existing_proxy.txt (100%) rename {plugin/generator => generator}/testdata/labels/h2c_reverse_proxy.txt (100%) rename {plugin/generator => generator}/testdata/labels/invalid_template.txt (100%) rename {plugin/generator => generator}/testdata/labels/minimum_special_labels.txt (100%) rename {plugin/generator => generator}/testdata/labels/multiple_addresses.txt (100%) rename {plugin/generator => generator}/testdata/labels/multiple_configs.txt (100%) rename {plugin/generator => generator}/testdata/labels/reverse_proxy_directives_are_moved_into_route.txt (100%) rename {plugin/generator => generator}/testdata/labels/with_groups.txt (100%) rename plugin/loader.go => loader.go (95%) delete mode 100644 main.go rename {plugin => utils}/stringBoolCMap.go (92%) rename {plugin => utils}/stringInt64CMap.go (92%) diff --git a/build.sh b/build.sh index 11b9dd3a..b71619ad 100755 --- a/build.sh +++ b/build.sh @@ -5,10 +5,8 @@ set -e echo ==PARAMETERS== echo ARTIFACTS: "${ARTIFACTS:=./artifacts}" -cd plugin go vet ./... go test -race ./... -cd ../ go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest diff --git a/plugin/caddyfile/caddyfile.go b/caddyfile/caddyfile.go similarity index 100% rename from plugin/caddyfile/caddyfile.go rename to caddyfile/caddyfile.go diff --git a/plugin/caddyfile/fromlabels.go b/caddyfile/fromlabels.go similarity index 100% rename from plugin/caddyfile/fromlabels.go rename to caddyfile/fromlabels.go diff --git a/plugin/caddyfile/fromlabels_test.go b/caddyfile/fromlabels_test.go similarity index 100% rename from plugin/caddyfile/fromlabels_test.go rename to caddyfile/fromlabels_test.go diff --git a/plugin/caddyfile/lexer.go b/caddyfile/lexer.go similarity index 100% rename from plugin/caddyfile/lexer.go rename to caddyfile/lexer.go diff --git a/plugin/caddyfile/marshal.go b/caddyfile/marshal.go similarity index 100% rename from plugin/caddyfile/marshal.go rename to caddyfile/marshal.go diff --git a/plugin/caddyfile/marshal_test.go b/caddyfile/marshal_test.go similarity index 100% rename from plugin/caddyfile/marshal_test.go rename to caddyfile/marshal_test.go diff --git a/plugin/caddyfile/merge.go b/caddyfile/merge.go similarity index 100% rename from plugin/caddyfile/merge.go rename to caddyfile/merge.go diff --git a/plugin/caddyfile/merge_test.go b/caddyfile/merge_test.go similarity index 100% rename from plugin/caddyfile/merge_test.go rename to caddyfile/merge_test.go diff --git a/plugin/caddyfile/processor.go b/caddyfile/processor.go similarity index 100% rename from plugin/caddyfile/processor.go rename to caddyfile/processor.go diff --git a/plugin/caddyfile/processor_test.go b/caddyfile/processor_test.go similarity index 100% rename from plugin/caddyfile/processor_test.go rename to caddyfile/processor_test.go diff --git a/plugin/caddyfile/testdata/labels/follow_alphabetical_order.txt b/caddyfile/testdata/labels/follow_alphabetical_order.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/follow_alphabetical_order.txt rename to caddyfile/testdata/labels/follow_alphabetical_order.txt diff --git a/plugin/caddyfile/testdata/labels/global_options.txt b/caddyfile/testdata/labels/global_options.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/global_options.txt rename to caddyfile/testdata/labels/global_options.txt diff --git a/plugin/caddyfile/testdata/labels/global_options_comes_first.txt b/caddyfile/testdata/labels/global_options_comes_first.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/global_options_comes_first.txt rename to caddyfile/testdata/labels/global_options_comes_first.txt diff --git a/plugin/caddyfile/testdata/labels/grouping.txt b/caddyfile/testdata/labels/grouping.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/grouping.txt rename to caddyfile/testdata/labels/grouping.txt diff --git a/plugin/caddyfile/testdata/labels/isolate_directives_with_suffix.txt b/caddyfile/testdata/labels/isolate_directives_with_suffix.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/isolate_directives_with_suffix.txt rename to caddyfile/testdata/labels/isolate_directives_with_suffix.txt diff --git a/plugin/caddyfile/testdata/labels/matchers_come_first.txt b/caddyfile/testdata/labels/matchers_come_first.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/matchers_come_first.txt rename to caddyfile/testdata/labels/matchers_come_first.txt diff --git a/plugin/caddyfile/testdata/labels/one_line_matchers_come_first.txt b/caddyfile/testdata/labels/one_line_matchers_come_first.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/one_line_matchers_come_first.txt rename to caddyfile/testdata/labels/one_line_matchers_come_first.txt diff --git a/plugin/caddyfile/testdata/labels/order_and_isolate_directives_with_prefix.txt b/caddyfile/testdata/labels/order_and_isolate_directives_with_prefix.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/order_and_isolate_directives_with_prefix.txt rename to caddyfile/testdata/labels/order_and_isolate_directives_with_prefix.txt diff --git a/plugin/caddyfile/testdata/labels/quotes.txt b/caddyfile/testdata/labels/quotes.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/quotes.txt rename to caddyfile/testdata/labels/quotes.txt diff --git a/plugin/caddyfile/testdata/labels/snippets_come_first.txt b/caddyfile/testdata/labels/snippets_come_first.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/snippets_come_first.txt rename to caddyfile/testdata/labels/snippets_come_first.txt diff --git a/plugin/caddyfile/testdata/labels/template_error.txt b/caddyfile/testdata/labels/template_error.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/template_error.txt rename to caddyfile/testdata/labels/template_error.txt diff --git a/plugin/caddyfile/testdata/labels/templates_empty_values.txt b/caddyfile/testdata/labels/templates_empty_values.txt similarity index 100% rename from plugin/caddyfile/testdata/labels/templates_empty_values.txt rename to caddyfile/testdata/labels/templates_empty_values.txt diff --git a/plugin/caddyfile/testdata/labels/wildcard_certificates.txt b/caddyfile/testdata/labels/wildcard_certificates.txt similarity index 95% rename from plugin/caddyfile/testdata/labels/wildcard_certificates.txt rename to caddyfile/testdata/labels/wildcard_certificates.txt index 6edb96dd..9e77cdd4 100644 --- a/plugin/caddyfile/testdata/labels/wildcard_certificates.txt +++ b/caddyfile/testdata/labels/wildcard_certificates.txt @@ -1,20 +1,20 @@ -caddy = *.example.com -caddy.1_@foo = host foo.example.com -caddy.1_handle = @foo -caddy.1_handle.reverse_proxy = foo:8080 - -caddy = *.example.com -caddy.2_@bar = host bar.example.com -caddy.2_handle = @bar -caddy.2_handle.reverse_proxy = bar:8080 ----------- -*.example.com { - @foo host foo.example.com - @bar host bar.example.com - handle @foo { - reverse_proxy foo:8080 - } - handle @bar { - reverse_proxy bar:8080 - } +caddy = *.example.com +caddy.1_@foo = host foo.example.com +caddy.1_handle = @foo +caddy.1_handle.reverse_proxy = foo:8080 + +caddy = *.example.com +caddy.2_@bar = host bar.example.com +caddy.2_handle = @bar +caddy.2_handle.reverse_proxy = bar:8080 +---------- +*.example.com { + @foo host foo.example.com + @bar host bar.example.com + handle @foo { + reverse_proxy foo:8080 + } + handle @bar { + reverse_proxy bar:8080 + } } \ No newline at end of file diff --git a/plugin/caddyfile/testdata/marshal/marshal.txt b/caddyfile/testdata/marshal/marshal.txt similarity index 100% rename from plugin/caddyfile/testdata/marshal/marshal.txt rename to caddyfile/testdata/marshal/marshal.txt diff --git a/plugin/caddyfile/testdata/merge/php_fastcgi_different_matcher.txt b/caddyfile/testdata/merge/php_fastcgi_different_matcher.txt similarity index 100% rename from plugin/caddyfile/testdata/merge/php_fastcgi_different_matcher.txt rename to caddyfile/testdata/merge/php_fastcgi_different_matcher.txt diff --git a/plugin/caddyfile/testdata/merge/php_fastcgi_no_matcher.txt b/caddyfile/testdata/merge/php_fastcgi_no_matcher.txt similarity index 100% rename from plugin/caddyfile/testdata/merge/php_fastcgi_no_matcher.txt rename to caddyfile/testdata/merge/php_fastcgi_no_matcher.txt diff --git a/plugin/caddyfile/testdata/merge/php_fastcgi_same_matcher.txt b/caddyfile/testdata/merge/php_fastcgi_same_matcher.txt similarity index 100% rename from plugin/caddyfile/testdata/merge/php_fastcgi_same_matcher.txt rename to caddyfile/testdata/merge/php_fastcgi_same_matcher.txt diff --git a/plugin/caddyfile/testdata/merge/reverse_proxy_different_matcher.txt b/caddyfile/testdata/merge/reverse_proxy_different_matcher.txt similarity index 100% rename from plugin/caddyfile/testdata/merge/reverse_proxy_different_matcher.txt rename to caddyfile/testdata/merge/reverse_proxy_different_matcher.txt diff --git a/plugin/caddyfile/testdata/merge/reverse_proxy_no_matcher.txt b/caddyfile/testdata/merge/reverse_proxy_no_matcher.txt similarity index 100% rename from plugin/caddyfile/testdata/merge/reverse_proxy_no_matcher.txt rename to caddyfile/testdata/merge/reverse_proxy_no_matcher.txt diff --git a/plugin/caddyfile/testdata/merge/reverse_proxy_same_matcher.txt b/caddyfile/testdata/merge/reverse_proxy_same_matcher.txt similarity index 100% rename from plugin/caddyfile/testdata/merge/reverse_proxy_same_matcher.txt rename to caddyfile/testdata/merge/reverse_proxy_same_matcher.txt diff --git a/plugin/caddyfile/testdata/process/blank.txt b/caddyfile/testdata/process/blank.txt similarity index 100% rename from plugin/caddyfile/testdata/process/blank.txt rename to caddyfile/testdata/process/blank.txt diff --git a/plugin/caddyfile/testdata/process/empty.txt b/caddyfile/testdata/process/empty.txt similarity index 100% rename from plugin/caddyfile/testdata/process/empty.txt rename to caddyfile/testdata/process/empty.txt diff --git a/plugin/caddyfile/testdata/process/invalid_block.txt b/caddyfile/testdata/process/invalid_block.txt similarity index 100% rename from plugin/caddyfile/testdata/process/invalid_block.txt rename to caddyfile/testdata/process/invalid_block.txt diff --git a/plugin/caddyfile/testdata/process/invalid_file.txt b/caddyfile/testdata/process/invalid_file.txt similarity index 100% rename from plugin/caddyfile/testdata/process/invalid_file.txt rename to caddyfile/testdata/process/invalid_file.txt diff --git a/plugin/cmd.go b/cmd.go similarity index 98% rename from plugin/cmd.go rename to cmd.go index c081d993..65d99e7f 100644 --- a/plugin/cmd.go +++ b/cmd.go @@ -1,4 +1,4 @@ -package plugin +package caddydockerproxy import ( "flag" @@ -10,8 +10,8 @@ import ( "github.com/caddyserver/caddy/v2" caddycmd "github.com/caddyserver/caddy/v2/cmd" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/config" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/generator" + "github.com/lucaslorentz/caddy-docker-proxy/v2/config" + "github.com/lucaslorentz/caddy-docker-proxy/v2/generator" "go.uber.org/zap" ) diff --git a/plugin/config/options.go b/config/options.go similarity index 100% rename from plugin/config/options.go rename to config/options.go diff --git a/plugin/docker/client.go b/docker/client.go similarity index 100% rename from plugin/docker/client.go rename to docker/client.go diff --git a/plugin/docker/client_mock.go b/docker/client_mock.go similarity index 100% rename from plugin/docker/client_mock.go rename to docker/client_mock.go diff --git a/plugin/docker/utils.go b/docker/utils.go similarity index 100% rename from plugin/docker/utils.go rename to docker/utils.go diff --git a/plugin/docker/utils_mock.go b/docker/utils_mock.go similarity index 100% rename from plugin/docker/utils_mock.go rename to docker/utils_mock.go diff --git a/plugin/docker/utils_test.go b/docker/utils_test.go similarity index 100% rename from plugin/docker/utils_test.go rename to docker/utils_test.go diff --git a/plugin/generator/containers.go b/generator/containers.go similarity index 93% rename from plugin/generator/containers.go rename to generator/containers.go index f6017adc..be23e54a 100644 --- a/plugin/generator/containers.go +++ b/generator/containers.go @@ -2,7 +2,7 @@ package generator import ( "github.com/docker/docker/api/types" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/caddyfile" + "github.com/lucaslorentz/caddy-docker-proxy/v2/caddyfile" "go.uber.org/zap" ) diff --git a/plugin/generator/containers_test.go b/generator/containers_test.go similarity index 99% rename from plugin/generator/containers_test.go rename to generator/containers_test.go index 8a42743a..15707d44 100644 --- a/plugin/generator/containers_test.go +++ b/generator/containers_test.go @@ -5,7 +5,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/config" + "github.com/lucaslorentz/caddy-docker-proxy/v2/config" ) func TestContainers_TemplateData(t *testing.T) { diff --git a/plugin/generator/generator.go b/generator/generator.go similarity index 97% rename from plugin/generator/generator.go rename to generator/generator.go index de2ac41a..62a9ffc8 100644 --- a/plugin/generator/generator.go +++ b/generator/generator.go @@ -11,9 +11,9 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/caddyfile" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/config" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/docker" + "github.com/lucaslorentz/caddy-docker-proxy/v2/caddyfile" + "github.com/lucaslorentz/caddy-docker-proxy/v2/config" + "github.com/lucaslorentz/caddy-docker-proxy/v2/docker" "go.uber.org/zap" ) diff --git a/plugin/generator/generator_test.go b/generator/generator_test.go similarity index 97% rename from plugin/generator/generator_test.go rename to generator/generator_test.go index 00c83293..a2320ed7 100644 --- a/plugin/generator/generator_test.go +++ b/generator/generator_test.go @@ -11,8 +11,8 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/network" "github.com/docker/docker/api/types/swarm" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/config" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/docker" + "github.com/lucaslorentz/caddy-docker-proxy/v2/config" + "github.com/lucaslorentz/caddy-docker-proxy/v2/docker" "github.com/stretchr/testify/assert" "go.uber.org/zap" "go.uber.org/zap/zapcore" diff --git a/plugin/generator/labels.go b/generator/labels.go similarity index 93% rename from plugin/generator/labels.go rename to generator/labels.go index 273654c8..6e1b3a69 100644 --- a/plugin/generator/labels.go +++ b/generator/labels.go @@ -5,7 +5,7 @@ import ( "strings" "text/template" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/caddyfile" + "github.com/lucaslorentz/caddy-docker-proxy/v2/caddyfile" ) type targetsProvider func() ([]string, error) diff --git a/plugin/generator/labels_test.go b/generator/labels_test.go similarity index 100% rename from plugin/generator/labels_test.go rename to generator/labels_test.go diff --git a/plugin/generator/services.go b/generator/services.go similarity index 97% rename from plugin/generator/services.go rename to generator/services.go index 26088be4..116ce5cb 100644 --- a/plugin/generator/services.go +++ b/generator/services.go @@ -7,7 +7,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/caddyfile" + "github.com/lucaslorentz/caddy-docker-proxy/v2/caddyfile" "go.uber.org/zap" ) diff --git a/plugin/generator/services_test.go b/generator/services_test.go similarity index 99% rename from plugin/generator/services_test.go rename to generator/services_test.go index f088b172..458a004f 100644 --- a/plugin/generator/services_test.go +++ b/generator/services_test.go @@ -5,7 +5,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/config" + "github.com/lucaslorentz/caddy-docker-proxy/v2/config" ) func TestServices_TemplateData(t *testing.T) { diff --git a/plugin/generator/testdata/labels/all_special_labels.txt b/generator/testdata/labels/all_special_labels.txt similarity index 100% rename from plugin/generator/testdata/labels/all_special_labels.txt rename to generator/testdata/labels/all_special_labels.txt diff --git a/plugin/generator/testdata/labels/doesnt_override_existing_proxy.txt b/generator/testdata/labels/doesnt_override_existing_proxy.txt similarity index 100% rename from plugin/generator/testdata/labels/doesnt_override_existing_proxy.txt rename to generator/testdata/labels/doesnt_override_existing_proxy.txt diff --git a/plugin/generator/testdata/labels/h2c_reverse_proxy.txt b/generator/testdata/labels/h2c_reverse_proxy.txt similarity index 100% rename from plugin/generator/testdata/labels/h2c_reverse_proxy.txt rename to generator/testdata/labels/h2c_reverse_proxy.txt diff --git a/plugin/generator/testdata/labels/invalid_template.txt b/generator/testdata/labels/invalid_template.txt similarity index 100% rename from plugin/generator/testdata/labels/invalid_template.txt rename to generator/testdata/labels/invalid_template.txt diff --git a/plugin/generator/testdata/labels/minimum_special_labels.txt b/generator/testdata/labels/minimum_special_labels.txt similarity index 100% rename from plugin/generator/testdata/labels/minimum_special_labels.txt rename to generator/testdata/labels/minimum_special_labels.txt diff --git a/plugin/generator/testdata/labels/multiple_addresses.txt b/generator/testdata/labels/multiple_addresses.txt similarity index 100% rename from plugin/generator/testdata/labels/multiple_addresses.txt rename to generator/testdata/labels/multiple_addresses.txt diff --git a/plugin/generator/testdata/labels/multiple_configs.txt b/generator/testdata/labels/multiple_configs.txt similarity index 100% rename from plugin/generator/testdata/labels/multiple_configs.txt rename to generator/testdata/labels/multiple_configs.txt diff --git a/plugin/generator/testdata/labels/reverse_proxy_directives_are_moved_into_route.txt b/generator/testdata/labels/reverse_proxy_directives_are_moved_into_route.txt similarity index 100% rename from plugin/generator/testdata/labels/reverse_proxy_directives_are_moved_into_route.txt rename to generator/testdata/labels/reverse_proxy_directives_are_moved_into_route.txt diff --git a/plugin/generator/testdata/labels/with_groups.txt b/generator/testdata/labels/with_groups.txt similarity index 100% rename from plugin/generator/testdata/labels/with_groups.txt rename to generator/testdata/labels/with_groups.txt diff --git a/plugin/loader.go b/loader.go similarity index 95% rename from plugin/loader.go rename to loader.go index cf20ced2..da16c04c 100644 --- a/plugin/loader.go +++ b/loader.go @@ -1,4 +1,4 @@ -package plugin +package caddydockerproxy import ( "bytes" @@ -17,9 +17,10 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/config" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/docker" - "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin/generator" + "github.com/lucaslorentz/caddy-docker-proxy/v2/config" + "github.com/lucaslorentz/caddy-docker-proxy/v2/docker" + "github.com/lucaslorentz/caddy-docker-proxy/v2/generator" + "github.com/lucaslorentz/caddy-docker-proxy/v2/utils" "go.uber.org/zap" ) @@ -35,16 +36,16 @@ type DockerLoader struct { lastCaddyfile []byte lastJSONConfig []byte lastVersion int64 - serversVersions *StringInt64CMap - serversUpdating *StringBoolCMap + serversVersions *utils.StringInt64CMap + serversUpdating *utils.StringBoolCMap } // CreateDockerLoader creates a docker loader func CreateDockerLoader(options *config.Options) *DockerLoader { return &DockerLoader{ options: options, - serversVersions: newStringInt64CMap(), - serversUpdating: newStringBoolCMap(), + serversVersions: utils.NewStringInt64CMap(), + serversUpdating: utils.NewStringBoolCMap(), } } diff --git a/main.go b/main.go deleted file mode 100644 index 803862ba..00000000 --- a/main.go +++ /dev/null @@ -1,5 +0,0 @@ -package caddydockerproxy - -import ( - _ "github.com/lucaslorentz/caddy-docker-proxy/v2/plugin" -) diff --git a/plugin/stringBoolCMap.go b/utils/stringBoolCMap.go similarity index 92% rename from plugin/stringBoolCMap.go rename to utils/stringBoolCMap.go index aafeef43..bc0cbbe0 100644 --- a/plugin/stringBoolCMap.go +++ b/utils/stringBoolCMap.go @@ -1,4 +1,4 @@ -package plugin +package utils import ( "sync" @@ -10,7 +10,7 @@ type StringBoolCMap struct { internal map[string]bool } -func newStringBoolCMap() *StringBoolCMap { +func NewStringBoolCMap() *StringBoolCMap { return &StringBoolCMap{ mutex: sync.RWMutex{}, internal: map[string]bool{}, diff --git a/plugin/stringInt64CMap.go b/utils/stringInt64CMap.go similarity index 92% rename from plugin/stringInt64CMap.go rename to utils/stringInt64CMap.go index ea872411..0d5c23b8 100644 --- a/plugin/stringInt64CMap.go +++ b/utils/stringInt64CMap.go @@ -1,4 +1,4 @@ -package plugin +package utils import ( "sync" @@ -10,7 +10,7 @@ type StringInt64CMap struct { internal map[string]int64 } -func newStringInt64CMap() *StringInt64CMap { +func NewStringInt64CMap() *StringInt64CMap { return &StringInt64CMap{ mutex: sync.RWMutex{}, internal: map[string]int64{},