Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/acp 38937 #24

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
39 changes: 35 additions & 4 deletions .build/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
memory: "4G"
limits:
cpu: "6"
memory: "4G"
memory: "4G"
script: |
#!/bin/sh
scripts/go-test.sh
Expand Down Expand Up @@ -188,14 +188,45 @@ spec:
memory: "4G"
limits:
cpu: "4"
memory: "4G"
memory: "4G"
script: |
#!/bin/sh
./scripts/nginx-test.sh
- name: build-alb-chart
- name: update-module-plugin
runAfter:
- nginx-build
- alb-build
workspaces:
- name: source
workspace: source
params:
- name: build_git_version_shart
value: $(build.git.version.short)
taskSpec:
description: |
set the version
workspaces:
- name: source
workspace: source
params:
- name: build_git_version_shart
type: string
steps:
- name: set-version
image: build-harbor.alauda.cn/ops/alpine:latest
imagePullPolicy: IfNotPresent
workingDir: $(workspaces.source.path)
script: |
#!/bin/sh
sed -i "s|version: .*|version: $(params.build_git_version_shart)|g" ./deploy/chart/alb/module-plugin.yaml
cat ./deploy/chart/alb/module-plugin.yaml
resources:
requests:
cpu: 100m
memory: 100Mi
- name: build-alb-chart
runAfter:
- update-module-plugin
timeout: 30m
retries: 0
taskRef:
Expand All @@ -221,7 +252,7 @@ spec:
- name: values
value:
- .global.images.alb2.tag=$(build.git.version.docker)
- .global.images.nginx.tag=$(build.git.version.docker)
- .global.images.nginx.tag=$(build.git.version.docker)
- name: commit-push
taskRef:
name: alauda-git-commit-push
Expand Down
27 changes: 27 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@
"caseSensitive": false,
"words": [
//proper noun
"testlink",
"rshift",
"restry",
"combind",
"divmod",
"lshift",
"rshift",
"flamegraph",
"urlsafe",
"urandom",
"pborman",
"hostport",
"jsondiff",
"AUTHFAIL",
"joxi",
"ncaptures",
"ingng", // ingress-nginx
"nameserver",
"resolvconf",
"resolv",
"authtypes",
"httpbin",
"signinurl",
"ingressnginx",
"varstring",
"extctl",
"sortbean",
"luacov",
"strftime",
"ncruces",
Expand Down
168 changes: 168 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@

# see https://github.com/CppCXY/EmmyLuaCodeStyle
[*.lua]
# [basic]

# optional space/tab
indent_style = space
# if indent_style is space, this is valid
indent_size = 4
# if indent_style is tab, this is valid
tab_width = 4
# none/single/double
quote_style = none

continuation_indent = 4
## extend option
# continuation_indent.before_block = 4
# continuation_indent.in_expr = 4
# continuation_indent.in_table = 4

# this mean utf8 length , if this is 'unset' then the line width is no longer checked
# this option decides when to chopdown the code
max_line_length = 120

# optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf
# in neovim the value 'auto' is not a valid option, please use 'unset'
end_of_line = auto

# none/ comma / semicolon / only_kv_colon
table_separator_style = none

#optional keep/never/always/smart
trailing_table_separator = keep

# keep/remove/remove_table_only/remove_string_only
call_arg_parentheses = keep

detect_end_of_line = false

# this will check text end with new line
insert_final_newline = true

# [space]
space_around_table_field_list = true

space_before_attribute = true

space_before_function_open_parenthesis = false

space_before_function_call_open_parenthesis = false

space_before_closure_open_parenthesis = true

# optional always/only_string/only_table/none
# or true/false
space_before_function_call_single_arg = always
## extend option
## always/keep/none
# space_before_function_call_single_arg.table = always
## always/keep/none
# space_before_function_call_single_arg.string = always

space_before_open_square_bracket = false

space_inside_function_call_parentheses = false

space_inside_function_param_list_parentheses = false

space_inside_square_brackets = false

# like t[#t+1] = 1
space_around_table_append_operator = false

ignore_spaces_inside_function_call = false

# detail number or 'keep'
space_before_inline_comment = 1

# convert '---' to '--- ' or '--' to '-- '
space_after_comment_dash = false

# [operator space]
space_around_math_operator = true
# space_around_math_operator.exponent = false

space_after_comma = true

space_after_comma_in_for_statement = true

space_around_concat_operator = true

space_around_logical_operator = true

space_around_assign_operator = true

# [align]

align_call_args = false

align_function_params = true

align_continuous_assign_statement = true

align_continuous_rect_table_field = true

align_continuous_line_space = 2

align_if_branch = false

# option none / always / contain_curly/
align_array_table = true

align_continuous_similar_call_args = false

align_continuous_inline_comment = true
# option none / always / only_call_stmt
align_chain_expr = none

# [indent]

never_indent_before_if_condition = false

never_indent_comment_on_if_branch = false

keep_indents_on_empty_lines = false

allow_non_indented_comments = false
# [line space]

# The following configuration supports four expressions
# keep
# fixed(n)
# min(n)
# max(n)
# for eg. min(2)

line_space_after_if_statement = keep

line_space_after_do_statement = keep

line_space_after_while_statement = keep

line_space_after_repeat_statement = keep

line_space_after_for_statement = keep

line_space_after_local_or_assign_statement = keep

line_space_after_function_statement = fixed(2)

line_space_after_expression_statement = keep

line_space_after_comment = keep

line_space_around_block = fixed(1)
# [line break]
break_all_list_when_line_exceed = false

auto_collapse_lines = false

break_before_braces = false

# [preference]
ignore_space_after_colon = true

remove_call_expression_list_finish_comma = false
# keep / always / same_line / replace_with_newline / never
end_statement_with_semicolon = keep
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ docs/.obsidian
template/share/dhparam.pem
luacov-html/
luacov.stats.out
luacov.report.out
luacov.report.out.index
luacov.summary
.kube
.fg
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG OPENRESTY_BASE=build-harbor.alauda.cn/3rdparty/alb-nginx:v1.25.3
FROM ${GO_BUILD_BASE} AS go_builder

ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
ENV GOPROXY=https://goproxy.cn,https://build-nexus.alauda.cn/repository/golang,direct
COPY ./ /alb/
WORKDIR /alb
ENV GOFLAGS=-buildvcs=false
Expand All @@ -15,6 +15,8 @@ RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-
RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-static' -v -o /out/albctl alauda.io/alb2/cmd/utils/albctl
RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-z,relro,-z,now' -v -o /out/tweak_gen alauda.io/alb2/cmd/utils/tweak_gen
RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-z,relro,-z,now' -v -o /out/ngx_gen alauda.io/alb2/cmd/utils/ngx_gen
RUN go build -buildmode=pie -ldflags '-w -s -linkmode=external -extldflags=-Wl,-z,relro,-z,now' -v -o /out/dirhash alauda.io/alb2/cmd/utils/dirhash
RUN go install github.com/mccutchen/go-httpbin/v2/cmd/go-httpbin@latest && cp /go/bin/go-httpbin /out/
RUN ldd /out/albctl || true

FROM ${OPENRESTY_BASE} AS base
Expand All @@ -38,11 +40,13 @@ COPY ./pkg/controller/ngxconf/nginx.tmpl /alb/ctl/template/nginx/nginx.tmpl
COPY run-alb.sh /alb/ctl/run-alb.sh
COPY --from=go_builder /out/tweak_gen /alb/tools/tweak_gen
COPY --from=go_builder /out/ngx_gen /alb/tools/ngx_gen
COPY --from=go_builder /out/dirhash /alb/tools/dirhash
COPY --from=go_builder /out/alb /alb/ctl/alb
COPY --from=go_builder /out/migrate /alb/ctl/tools/
COPY --from=go_builder /out/operator /alb/ctl/operator
COPY --from=go_builder /alb/migrate/backup /alb/ctl/tools/backup
COPY --from=go_builder /out/albctl /alb/ctl/tools/albctl
COPY --from=go_builder /out/go-httpbin /alb/tools/go-httpbin

ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin:/usr/local/openresty/openssl/bin/
ENV NGINX_TEMPLATE_PATH /alb/ctl/template/nginx/nginx.tmpl
Expand Down
8 changes: 7 additions & 1 deletion cmd/utils/albctl/cmd/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ func listRule(ctx Ctx) error {
if err != nil {
return err
}
rule_maps := map[string]InternalRule{}
for _, ft := range lb.Frontends {
for _, r := range ft.Rules {
rule_maps[r.RuleID] = *r
}
}
err = pcli.FillUpBackends(lb)
if err != nil {
return err
Expand Down Expand Up @@ -238,7 +244,7 @@ func listRule(ctx Ctx) error {
Name: p.Rule,
Port: int(port),
RealPriority: p.ComplexPriority,
Host: parse_host(p.DSLX),
Host: parse_host(rule_maps[p.Rule].DSLX),
Matches: PrettyCompactJson(p.InternalDSL),
Policy: *p,
Upstream: backens_maps[p.Rule],
Expand Down
16 changes: 16 additions & 0 deletions cmd/utils/dirhash/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"fmt"
"os"

"alauda.io/alb2/utils/dirhash"
)

func main() {
out, err := dirhash.HashDir(os.Args[1], "", dirhash.DefaultHash)
if err != nil {
panic(err)
}
fmt.Printf("%s\n", out)
}
Loading