This commit is contained in:
谢作欢 2023-11-02 17:24:36 +08:00
commit 4f6f6a0d6a
15 changed files with 1281 additions and 0 deletions

19
.drone.yml Normal file
View File

@ -0,0 +1,19 @@
kind: pipeline
type: docker
name: blog
trigger:
event: [tag]
steps:
- name: builder
image: plugins/docker
settings:
registry: gitea.mrx.ltd # 镜像仓库地址
repo: gitea.mrx.ltd/coward-code/blog # 镜像仓库地址
username:
from_secret: docker_user
password:
from_secret: docker_pwd
use_cache: true
auto_tag: true

560
.editorconfig Normal file
View File

@ -0,0 +1,560 @@
root = true
[*]
# charset = utf-8
# end_of_line = crlf
# indent_size = 4
# indent_style = space
# insert_final_newline = false
# max_line_length = 120
# tab_width = 4
# ij_continuation_indent_size = 8
# ij_formatter_off_tag = @formatter:off
# ij_formatter_on_tag = @formatter:on
# ij_formatter_tags_enabled = true
# ij_smart_tabs = false
# ij_visual_guides =
# ij_wrap_on_typing = false
[*.css]
# ij_css_align_closing_brace_with_properties = false
# ij_css_blank_lines_around_nested_selector = 1
# ij_css_blank_lines_between_blocks = 1
# ij_css_block_comment_add_space = false
# ij_css_brace_placement = end_of_line
# ij_css_enforce_quotes_on_format = false
# ij_css_hex_color_long_format = false
# ij_css_hex_color_lower_case = false
# ij_css_hex_color_short_format = false
# ij_css_hex_color_upper_case = false
# ij_css_keep_blank_lines_in_code = 2
# ij_css_keep_indents_on_empty_lines = false
# ij_css_keep_single_line_blocks = false
# ij_css_properties_order = font,font-family,font-size,font-weight,font-style,font-variant,font-size-adjust,font-stretch,line-height,position,z-index,top,right,bottom,left,display,visibility,float,clear,overflow,overflow-x,overflow-y,clip,zoom,align-content,align-items,align-self,flex,flex-flow,flex-basis,flex-direction,flex-grow,flex-shrink,flex-wrap,justify-content,order,box-sizing,width,min-width,max-width,height,min-height,max-height,margin,margin-top,margin-right,margin-bottom,margin-left,padding,padding-top,padding-right,padding-bottom,padding-left,table-layout,empty-cells,caption-side,border-spacing,border-collapse,list-style,list-style-position,list-style-type,list-style-image,content,quotes,counter-reset,counter-increment,resize,cursor,user-select,nav-index,nav-up,nav-right,nav-down,nav-left,transition,transition-delay,transition-timing-function,transition-duration,transition-property,transform,transform-origin,animation,animation-name,animation-duration,animation-play-state,animation-timing-function,animation-delay,animation-iteration-count,animation-direction,text-align,text-align-last,vertical-align,white-space,text-decoration,text-emphasis,text-emphasis-color,text-emphasis-style,text-emphasis-position,text-indent,text-justify,letter-spacing,word-spacing,text-outline,text-transform,text-wrap,text-overflow,text-overflow-ellipsis,text-overflow-mode,word-wrap,word-break,tab-size,hyphens,pointer-events,opacity,color,border,border-width,border-style,border-color,border-top,border-top-width,border-top-style,border-top-color,border-right,border-right-width,border-right-style,border-right-color,border-bottom,border-bottom-width,border-bottom-style,border-bottom-color,border-left,border-left-width,border-left-style,border-left-color,border-radius,border-top-left-radius,border-top-right-radius,border-bottom-right-radius,border-bottom-left-radius,border-image,border-image-source,border-image-slice,border-image-width,border-image-outset,border-image-repeat,outline,outline-width,outline-style,outline-color,outline-offset,background,background-color,background-image,background-repeat,background-attachment,background-position,background-position-x,background-position-y,background-clip,background-origin,background-size,box-decoration-break,box-shadow,text-shadow
# ij_css_space_after_colon = true
# ij_css_space_before_opening_brace = true
# ij_css_use_double_quotes = true
# ij_css_value_alignment = do_not_align
[*.proto]
# indent_size = 2
# tab_width = 2
# ij_continuation_indent_size = 4
# ij_protobuf_keep_blank_lines_in_code = 2
# ij_protobuf_keep_indents_on_empty_lines = false
# ij_protobuf_keep_line_breaks = true
# ij_protobuf_space_after_comma = true
# ij_protobuf_space_before_comma = false
# ij_protobuf_spaces_around_assignment_operators = true
# ij_protobuf_spaces_within_braces = false
# ij_protobuf_spaces_within_brackets = false
[.editorconfig]
# ij_editorconfig_align_group_field_declarations = false
# ij_editorconfig_space_after_colon = false
# ij_editorconfig_space_after_comma = true
# ij_editorconfig_space_before_colon = false
# ij_editorconfig_space_before_comma = false
# ij_editorconfig_spaces_around_assignment_operators = true
[{*.ant,*.fxml,*.jhm,*.jnlp,*.jrxml,*.rng,*.tld,*.wsdl,*.xml,*.xsd,*.xsl,*.xslt,*.xul}]
# ij_xml_align_attributes = true
# ij_xml_align_text = false
# ij_xml_attribute_wrap = normal
# ij_xml_block_comment_add_space = false
# ij_xml_block_comment_at_first_column = true
# ij_xml_keep_blank_lines = 2
# ij_xml_keep_indents_on_empty_lines = false
# ij_xml_keep_line_breaks = true
# ij_xml_keep_line_breaks_in_text = true
# ij_xml_keep_whitespaces = false
# ij_xml_keep_whitespaces_around_cdata = preserve
# ij_xml_keep_whitespaces_inside_cdata = false
# ij_xml_line_comment_at_first_column = true
# ij_xml_space_after_tag_name = false
# ij_xml_space_around_equals_in_attribute = false
# ij_xml_space_inside_empty_tag = false
# ij_xml_text_wrap = normal
[{*.ats,*.cts,*.mts,*.ts}]
# ij_continuation_indent_size = 4
# ij_typescript_align_imports = false
# ij_typescript_align_multiline_array_initializer_expression = false
# ij_typescript_align_multiline_binary_operation = false
# ij_typescript_align_multiline_chained_methods = false
# ij_typescript_align_multiline_extends_list = false
# ij_typescript_align_multiline_for = true
# ij_typescript_align_multiline_parameters = true
# ij_typescript_align_multiline_parameters_in_calls = false
# ij_typescript_align_multiline_ternary_operation = false
# ij_typescript_align_object_properties = 0
# ij_typescript_align_union_types = false
# ij_typescript_align_var_statements = 0
# ij_typescript_array_initializer_new_line_after_left_brace = false
# ij_typescript_array_initializer_right_brace_on_new_line = false
# ij_typescript_array_initializer_wrap = off
# ij_typescript_assignment_wrap = off
# ij_typescript_binary_operation_sign_on_next_line = false
# ij_typescript_binary_operation_wrap = off
# ij_typescript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/**
# ij_typescript_blank_lines_after_imports = 1
# ij_typescript_blank_lines_around_class = 1
# ij_typescript_blank_lines_around_field = 0
# ij_typescript_blank_lines_around_field_in_interface = 0
# ij_typescript_blank_lines_around_function = 1
# ij_typescript_blank_lines_around_method = 1
# ij_typescript_blank_lines_around_method_in_interface = 1
# ij_typescript_block_brace_style = end_of_line
# ij_typescript_block_comment_add_space = false
# ij_typescript_block_comment_at_first_column = true
# ij_typescript_call_parameters_new_line_after_left_paren = false
# ij_typescript_call_parameters_right_paren_on_new_line = false
# ij_typescript_call_parameters_wrap = off
# ij_typescript_catch_on_new_line = false
# ij_typescript_chained_call_dot_on_new_line = true
# ij_typescript_class_brace_style = end_of_line
# ij_typescript_comma_on_new_line = false
# ij_typescript_do_while_brace_force = never
# ij_typescript_else_on_new_line = false
# ij_typescript_enforce_trailing_comma = keep
# ij_typescript_enum_constants_wrap = on_every_item
# ij_typescript_extends_keyword_wrap = off
# ij_typescript_extends_list_wrap = off
# ij_typescript_field_prefix = _
# ij_typescript_file_name_style = relaxed
# ij_typescript_finally_on_new_line = false
# ij_typescript_for_brace_force = never
# ij_typescript_for_statement_new_line_after_left_paren = false
# ij_typescript_for_statement_right_paren_on_new_line = false
# ij_typescript_for_statement_wrap = off
# ij_typescript_force_quote_style = false
# ij_typescript_force_semicolon_style = false
# ij_typescript_function_expression_brace_style = end_of_line
# ij_typescript_if_brace_force = never
# ij_typescript_import_merge_members = global
# ij_typescript_import_prefer_absolute_path = global
# ij_typescript_import_sort_members = true
# ij_typescript_import_sort_module_name = false
# ij_typescript_import_use_node_resolution = true
# ij_typescript_imports_wrap = on_every_item
# ij_typescript_indent_case_from_switch = true
# ij_typescript_indent_chained_calls = true
# ij_typescript_indent_package_children = 0
# ij_typescript_jsdoc_include_types = false
# ij_typescript_jsx_attribute_value = braces
# ij_typescript_keep_blank_lines_in_code = 2
# ij_typescript_keep_first_column_comment = true
# ij_typescript_keep_indents_on_empty_lines = false
# ij_typescript_keep_line_breaks = true
# ij_typescript_keep_simple_blocks_in_one_line = false
# ij_typescript_keep_simple_methods_in_one_line = false
# ij_typescript_line_comment_add_space = true
# ij_typescript_line_comment_at_first_column = false
# ij_typescript_method_brace_style = end_of_line
# ij_typescript_method_call_chain_wrap = off
# ij_typescript_method_parameters_new_line_after_left_paren = false
# ij_typescript_method_parameters_right_paren_on_new_line = false
# ij_typescript_method_parameters_wrap = off
# ij_typescript_object_literal_wrap = on_every_item
# ij_typescript_object_types_wrap = on_every_item
# ij_typescript_parentheses_expression_new_line_after_left_paren = false
# ij_typescript_parentheses_expression_right_paren_on_new_line = false
# ij_typescript_place_assignment_sign_on_next_line = false
# ij_typescript_prefer_as_type_cast = false
# ij_typescript_prefer_explicit_types_function_expression_returns = false
# ij_typescript_prefer_explicit_types_function_returns = false
# ij_typescript_prefer_explicit_types_vars_fields = false
# ij_typescript_prefer_parameters_wrap = false
# ij_typescript_property_prefix =
# ij_typescript_reformat_c_style_comments = false
# ij_typescript_space_after_colon = true
# ij_typescript_space_after_comma = true
# ij_typescript_space_after_dots_in_rest_parameter = false
# ij_typescript_space_after_generator_mult = true
# ij_typescript_space_after_property_colon = true
# ij_typescript_space_after_quest = true
# ij_typescript_space_after_type_colon = true
# ij_typescript_space_after_unary_not = false
# ij_typescript_space_before_async_arrow_lparen = true
# ij_typescript_space_before_catch_keyword = true
# ij_typescript_space_before_catch_left_brace = true
# ij_typescript_space_before_catch_parentheses = true
# ij_typescript_space_before_class_lbrace = true
# ij_typescript_space_before_class_left_brace = true
# ij_typescript_space_before_colon = true
# ij_typescript_space_before_comma = false
# ij_typescript_space_before_do_left_brace = true
# ij_typescript_space_before_else_keyword = true
# ij_typescript_space_before_else_left_brace = true
# ij_typescript_space_before_finally_keyword = true
# ij_typescript_space_before_finally_left_brace = true
# ij_typescript_space_before_for_left_brace = true
# ij_typescript_space_before_for_parentheses = true
# ij_typescript_space_before_for_semicolon = false
# ij_typescript_space_before_function_left_parenth = true
# ij_typescript_space_before_generator_mult = false
# ij_typescript_space_before_if_left_brace = true
# ij_typescript_space_before_if_parentheses = true
# ij_typescript_space_before_method_call_parentheses = false
# ij_typescript_space_before_method_left_brace = true
# ij_typescript_space_before_method_parentheses = false
# ij_typescript_space_before_property_colon = false
# ij_typescript_space_before_quest = true
# ij_typescript_space_before_switch_left_brace = true
# ij_typescript_space_before_switch_parentheses = true
# ij_typescript_space_before_try_left_brace = true
# ij_typescript_space_before_type_colon = false
# ij_typescript_space_before_unary_not = false
# ij_typescript_space_before_while_keyword = true
# ij_typescript_space_before_while_left_brace = true
# ij_typescript_space_before_while_parentheses = true
# ij_typescript_spaces_around_additive_operators = true
# ij_typescript_spaces_around_arrow_function_operator = true
# ij_typescript_spaces_around_assignment_operators = true
# ij_typescript_spaces_around_bitwise_operators = true
# ij_typescript_spaces_around_equality_operators = true
# ij_typescript_spaces_around_logical_operators = true
# ij_typescript_spaces_around_multiplicative_operators = true
# ij_typescript_spaces_around_relational_operators = true
# ij_typescript_spaces_around_shift_operators = true
# ij_typescript_spaces_around_unary_operator = false
# ij_typescript_spaces_within_array_initializer_brackets = false
# ij_typescript_spaces_within_brackets = false
# ij_typescript_spaces_within_catch_parentheses = false
# ij_typescript_spaces_within_for_parentheses = false
# ij_typescript_spaces_within_if_parentheses = false
# ij_typescript_spaces_within_imports = false
# ij_typescript_spaces_within_interpolation_expressions = false
# ij_typescript_spaces_within_method_call_parentheses = false
# ij_typescript_spaces_within_method_parentheses = false
# ij_typescript_spaces_within_object_literal_braces = false
# ij_typescript_spaces_within_object_type_braces = true
# ij_typescript_spaces_within_parentheses = false
# ij_typescript_spaces_within_switch_parentheses = false
# ij_typescript_spaces_within_type_assertion = false
# ij_typescript_spaces_within_union_types = true
# ij_typescript_spaces_within_while_parentheses = false
# ij_typescript_special_else_if_treatment = true
# ij_typescript_ternary_operation_signs_on_next_line = false
# ij_typescript_ternary_operation_wrap = off
# ij_typescript_union_types_wrap = on_every_item
# ij_typescript_use_chained_calls_group_indents = false
# ij_typescript_use_double_quotes = true
# ij_typescript_use_explicit_js_extension = auto
# ij_typescript_use_path_mapping = always
# ij_typescript_use_public_modifier = false
# ij_typescript_use_semicolon_after_statement = true
# ij_typescript_var_declaration_wrap = normal
# ij_typescript_while_brace_force = never
# ij_typescript_while_on_new_line = false
# ij_typescript_wrap_comments = false
[{*.bash,*.sh,*.zsh}]
# indent_size = 2
# tab_width = 2
# ij_shell_binary_ops_start_line = false
# ij_shell_keep_column_alignment_padding = false
# ij_shell_minify_program = false
# ij_shell_redirect_followed_by_space = false
# ij_shell_switch_cases_indented = false
# ij_shell_use_unix_line_separator = true
[{*.cjs,*.js}]
# ij_continuation_indent_size = 4
# ij_javascript_align_imports = false
# ij_javascript_align_multiline_array_initializer_expression = false
# ij_javascript_align_multiline_binary_operation = false
# ij_javascript_align_multiline_chained_methods = false
# ij_javascript_align_multiline_extends_list = false
# ij_javascript_align_multiline_for = true
# ij_javascript_align_multiline_parameters = true
# ij_javascript_align_multiline_parameters_in_calls = false
# ij_javascript_align_multiline_ternary_operation = false
# ij_javascript_align_object_properties = 0
# ij_javascript_align_union_types = false
# ij_javascript_align_var_statements = 0
# ij_javascript_array_initializer_new_line_after_left_brace = false
# ij_javascript_array_initializer_right_brace_on_new_line = false
# ij_javascript_array_initializer_wrap = off
# ij_javascript_assignment_wrap = off
# ij_javascript_binary_operation_sign_on_next_line = false
# ij_javascript_binary_operation_wrap = off
# ij_javascript_blacklist_imports = rxjs/Rx,node_modules/**,**/node_modules/**,@angular/material,@angular/material/typings/**
# ij_javascript_blank_lines_after_imports = 1
# ij_javascript_blank_lines_around_class = 1
# ij_javascript_blank_lines_around_field = 0
# ij_javascript_blank_lines_around_function = 1
# ij_javascript_blank_lines_around_method = 1
# ij_javascript_block_brace_style = end_of_line
# ij_javascript_block_comment_add_space = false
# ij_javascript_block_comment_at_first_column = true
# ij_javascript_call_parameters_new_line_after_left_paren = false
# ij_javascript_call_parameters_right_paren_on_new_line = false
# ij_javascript_call_parameters_wrap = off
# ij_javascript_catch_on_new_line = false
# ij_javascript_chained_call_dot_on_new_line = true
# ij_javascript_class_brace_style = end_of_line
# ij_javascript_comma_on_new_line = false
# ij_javascript_do_while_brace_force = never
# ij_javascript_else_on_new_line = false
# ij_javascript_enforce_trailing_comma = keep
# ij_javascript_extends_keyword_wrap = off
# ij_javascript_extends_list_wrap = off
# ij_javascript_field_prefix = _
# ij_javascript_file_name_style = relaxed
# ij_javascript_finally_on_new_line = false
# ij_javascript_for_brace_force = never
# ij_javascript_for_statement_new_line_after_left_paren = false
# ij_javascript_for_statement_right_paren_on_new_line = false
# ij_javascript_for_statement_wrap = off
# ij_javascript_force_quote_style = false
# ij_javascript_force_semicolon_style = false
# ij_javascript_function_expression_brace_style = end_of_line
# ij_javascript_if_brace_force = never
# ij_javascript_import_merge_members = global
# ij_javascript_import_prefer_absolute_path = global
# ij_javascript_import_sort_members = true
# ij_javascript_import_sort_module_name = false
# ij_javascript_import_use_node_resolution = true
# ij_javascript_imports_wrap = on_every_item
# ij_javascript_indent_case_from_switch = true
# ij_javascript_indent_chained_calls = true
# ij_javascript_indent_package_children = 0
# ij_javascript_jsx_attribute_value = braces
# ij_javascript_keep_blank_lines_in_code = 2
# ij_javascript_keep_first_column_comment = true
# ij_javascript_keep_indents_on_empty_lines = false
# ij_javascript_keep_line_breaks = true
# ij_javascript_keep_simple_blocks_in_one_line = false
# ij_javascript_keep_simple_methods_in_one_line = false
# ij_javascript_line_comment_add_space = true
# ij_javascript_line_comment_at_first_column = false
# ij_javascript_method_brace_style = end_of_line
# ij_javascript_method_call_chain_wrap = off
# ij_javascript_method_parameters_new_line_after_left_paren = false
# ij_javascript_method_parameters_right_paren_on_new_line = false
# ij_javascript_method_parameters_wrap = off
# ij_javascript_object_literal_wrap = on_every_item
# ij_javascript_object_types_wrap = on_every_item
# ij_javascript_parentheses_expression_new_line_after_left_paren = false
# ij_javascript_parentheses_expression_right_paren_on_new_line = false
# ij_javascript_place_assignment_sign_on_next_line = false
# ij_javascript_prefer_as_type_cast = false
# ij_javascript_prefer_explicit_types_function_expression_returns = false
# ij_javascript_prefer_explicit_types_function_returns = false
# ij_javascript_prefer_explicit_types_vars_fields = false
# ij_javascript_prefer_parameters_wrap = false
# ij_javascript_property_prefix =
# ij_javascript_reformat_c_style_comments = false
# ij_javascript_space_after_colon = true
# ij_javascript_space_after_comma = true
# ij_javascript_space_after_dots_in_rest_parameter = false
# ij_javascript_space_after_generator_mult = true
# ij_javascript_space_after_property_colon = true
# ij_javascript_space_after_quest = true
# ij_javascript_space_after_type_colon = true
# ij_javascript_space_after_unary_not = false
# ij_javascript_space_before_async_arrow_lparen = true
# ij_javascript_space_before_catch_keyword = true
# ij_javascript_space_before_catch_left_brace = true
# ij_javascript_space_before_catch_parentheses = true
# ij_javascript_space_before_class_lbrace = true
# ij_javascript_space_before_class_left_brace = true
# ij_javascript_space_before_colon = true
# ij_javascript_space_before_comma = false
# ij_javascript_space_before_do_left_brace = true
# ij_javascript_space_before_else_keyword = true
# ij_javascript_space_before_else_left_brace = true
# ij_javascript_space_before_finally_keyword = true
# ij_javascript_space_before_finally_left_brace = true
# ij_javascript_space_before_for_left_brace = true
# ij_javascript_space_before_for_parentheses = true
# ij_javascript_space_before_for_semicolon = false
# ij_javascript_space_before_function_left_parenth = true
# ij_javascript_space_before_generator_mult = false
# ij_javascript_space_before_if_left_brace = true
# ij_javascript_space_before_if_parentheses = true
# ij_javascript_space_before_method_call_parentheses = false
# ij_javascript_space_before_method_left_brace = true
# ij_javascript_space_before_method_parentheses = false
# ij_javascript_space_before_property_colon = false
# ij_javascript_space_before_quest = true
# ij_javascript_space_before_switch_left_brace = true
# ij_javascript_space_before_switch_parentheses = true
# ij_javascript_space_before_try_left_brace = true
# ij_javascript_space_before_type_colon = false
# ij_javascript_space_before_unary_not = false
# ij_javascript_space_before_while_keyword = true
# ij_javascript_space_before_while_left_brace = true
# ij_javascript_space_before_while_parentheses = true
# ij_javascript_spaces_around_additive_operators = true
# ij_javascript_spaces_around_arrow_function_operator = true
# ij_javascript_spaces_around_assignment_operators = true
# ij_javascript_spaces_around_bitwise_operators = true
# ij_javascript_spaces_around_equality_operators = true
# ij_javascript_spaces_around_logical_operators = true
# ij_javascript_spaces_around_multiplicative_operators = true
# ij_javascript_spaces_around_relational_operators = true
# ij_javascript_spaces_around_shift_operators = true
# ij_javascript_spaces_around_unary_operator = false
# ij_javascript_spaces_within_array_initializer_brackets = false
# ij_javascript_spaces_within_brackets = false
# ij_javascript_spaces_within_catch_parentheses = false
# ij_javascript_spaces_within_for_parentheses = false
# ij_javascript_spaces_within_if_parentheses = false
# ij_javascript_spaces_within_imports = false
# ij_javascript_spaces_within_interpolation_expressions = false
# ij_javascript_spaces_within_method_call_parentheses = false
# ij_javascript_spaces_within_method_parentheses = false
# ij_javascript_spaces_within_object_literal_braces = false
# ij_javascript_spaces_within_object_type_braces = true
# ij_javascript_spaces_within_parentheses = false
# ij_javascript_spaces_within_switch_parentheses = false
# ij_javascript_spaces_within_type_assertion = false
# ij_javascript_spaces_within_union_types = true
# ij_javascript_spaces_within_while_parentheses = false
# ij_javascript_special_else_if_treatment = true
# ij_javascript_ternary_operation_signs_on_next_line = false
# ij_javascript_ternary_operation_wrap = off
# ij_javascript_union_types_wrap = on_every_item
# ij_javascript_use_chained_calls_group_indents = false
# ij_javascript_use_double_quotes = true
# ij_javascript_use_explicit_js_extension = auto
# ij_javascript_use_path_mapping = always
# ij_javascript_use_public_modifier = false
# ij_javascript_use_semicolon_after_statement = true
# ij_javascript_var_declaration_wrap = normal
# ij_javascript_while_brace_force = never
# ij_javascript_while_on_new_line = false
# ij_javascript_wrap_comments = false
[{*.go,*.go2}]
# indent_style = tab
# ij_continuation_indent_size = 4
# ij_go_GROUP_CURRENT_PROJECT_IMPORTS = false
# ij_go_add_leading_space_to_comments = false
# ij_go_add_parentheses_for_single_import = false
# ij_go_call_parameters_new_line_after_left_paren = true
# ij_go_call_parameters_right_paren_on_new_line = true
# ij_go_call_parameters_wrap = off
# ij_go_fill_paragraph_width = 80
# ij_go_group_stdlib_imports = false
# ij_go_import_sorting = gofmt
# ij_go_keep_indents_on_empty_lines = false
# ij_go_local_group_mode = project
# ij_go_local_package_prefixes =
# ij_go_move_all_imports_in_one_declaration = false
# ij_go_move_all_stdlib_imports_in_one_group = false
# ij_go_remove_redundant_import_aliases = false
# ij_go_run_go_fmt_on_reformat = true
# ij_go_use_back_quotes_for_imports = false
# ij_go_wrap_comp_lit = off
# ij_go_wrap_comp_lit_newline_after_lbrace = true
# ij_go_wrap_comp_lit_newline_before_rbrace = true
# ij_go_wrap_func_params = off
# ij_go_wrap_func_params_newline_after_lparen = true
# ij_go_wrap_func_params_newline_before_rparen = true
# ij_go_wrap_func_result = off
# ij_go_wrap_func_result_newline_after_lparen = true
# ij_go_wrap_func_result_newline_before_rparen = true
[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}]
# indent_size = 2
# ij_json_array_wrapping = split_into_lines
# ij_json_keep_blank_lines_in_code = 0
# ij_json_keep_indents_on_empty_lines = false
# ij_json_keep_line_breaks = true
# ij_json_keep_trailing_comma = false
# ij_json_object_wrapping = split_into_lines
# ij_json_property_alignment = do_not_align
# ij_json_space_after_colon = true
# ij_json_space_after_comma = true
# ij_json_space_before_colon = false
# ij_json_space_before_comma = false
# ij_json_spaces_within_braces = false
# ij_json_spaces_within_brackets = false
# ij_json_wrap_long_lines = false
[{*.htm,*.html,*.sht,*.shtm,*.shtml}]
# ij_html_add_new_line_before_tags = body,div,p,form,h1,h2,h3
# ij_html_align_attributes = true
# ij_html_align_text = false
# ij_html_attribute_wrap = normal
# ij_html_block_comment_add_space = false
# ij_html_block_comment_at_first_column = true
# ij_html_do_not_align_children_of_min_lines = 0
# ij_html_do_not_break_if_inline_tags = title,h1,h2,h3,h4,h5,h6,p
# ij_html_do_not_indent_children_of_tags = html,body,thead,tbody,tfoot
# ij_html_enforce_quotes = false
# ij_html_inline_tags = a,abbr,acronym,b,basefont,bdo,big,br,cite,cite,code,dfn,em,font,i,img,input,kbd,label,q,s,samp,select,small,span,strike,strong,sub,sup,textarea,tt,u,var
# ij_html_keep_blank_lines = 2
# ij_html_keep_indents_on_empty_lines = false
# ij_html_keep_line_breaks = true
# ij_html_keep_line_breaks_in_text = true
# ij_html_keep_whitespaces = false
# ij_html_keep_whitespaces_inside = span,pre,textarea
# ij_html_line_comment_at_first_column = true
# ij_html_new_line_after_last_attribute = never
# ij_html_new_line_before_first_attribute = never
# ij_html_quote_style = double
# ij_html_remove_new_line_before_tags = br
# ij_html_space_after_tag_name = false
# ij_html_space_around_equality_in_attribute = false
# ij_html_space_inside_empty_tag = false
# ij_html_text_wrap = normal
[{*.http,*.rest}]
# indent_size = 0
# ij_continuation_indent_size = 4
# ij_http-request_call_parameters_wrap = normal
# ij_http-request_method_parameters_wrap = split_into_lines
# ij_http-request_space_before_comma = true
# ij_http-request_spaces_around_assignment_operators = true
[{*.markdown,*.md}]
# ij_markdown_force_one_space_after_blockquote_symbol = true
# ij_markdown_force_one_space_after_header_symbol = true
# ij_markdown_force_one_space_after_list_bullet = true
# ij_markdown_force_one_space_between_words = true
# ij_markdown_format_tables = true
# ij_markdown_insert_quote_arrows_on_wrap = true
# ij_markdown_keep_indents_on_empty_lines = false
# ij_markdown_keep_line_breaks_inside_text_blocks = true
# ij_markdown_max_lines_around_block_elements = 1
# ij_markdown_max_lines_around_header = 1
# ij_markdown_max_lines_between_paragraphs = 1
# ij_markdown_min_lines_around_block_elements = 1
# ij_markdown_min_lines_around_header = 1
# ij_markdown_min_lines_between_paragraphs = 1
# ij_markdown_wrap_text_if_long = true
# ij_markdown_wrap_text_inside_blockquotes = true
[{*.pb,*.textproto}]
# indent_size = 2
# tab_width = 2
# ij_continuation_indent_size = 4
# ij_prototext_keep_blank_lines_in_code = 2
# ij_prototext_keep_indents_on_empty_lines = false
# ij_prototext_keep_line_breaks = true
# ij_prototext_space_after_colon = true
# ij_prototext_space_after_comma = true
# ij_prototext_space_before_colon = false
# ij_prototext_space_before_comma = false
# ij_prototext_spaces_within_braces = true
# ij_prototext_spaces_within_brackets = false
[{*.toml,Cargo.lock,Cargo.toml.orig,Gopkg.lock,Pipfile,poetry.lock}]
# ij_toml_keep_indents_on_empty_lines = false
[{*.yaml,*.yml}]
# indent_size = 2
# ij_yaml_align_values_properties = do_not_align
# ij_yaml_autoinsert_sequence_marker = true
# ij_yaml_block_mapping_on_new_line = false
# ij_yaml_indent_sequence_value = true
# ij_yaml_keep_indents_on_empty_lines = false
# ij_yaml_keep_line_breaks = true
# ij_yaml_sequence_on_new_line = false
# ij_yaml_space_before_colon = false
# ij_yaml_spaces_within_braces = true
# ij_yaml_spaces_within_brackets = true

25
.gitignore vendored Normal file
View File

@ -0,0 +1,25 @@
### Go template
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
# vendor/
./idea
# Go workspace file
go.work

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

1
.idea/.name generated Normal file
View File

@ -0,0 +1 @@
drone-kubernetes

9
.idea/drone-kubernetes.iml generated Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="Go" enabled="true" />
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/drone-kubernetes.iml" filepath="$PROJECT_DIR$/.idea/drone-kubernetes.iml" />
</modules>
</component>
</project>

18
Dockerfile Normal file
View File

@ -0,0 +1,18 @@
FROM golang as build
WORKDIR /app
COPY . .
ENV GO111MODULE=on
ENV GOPROXY=https://goproxy.cn,direct
RUN go mod download
RUN go build -o app
FROM alpine
WORKDIR /app
COPY --from=build /app/app .

0
README.md Normal file
View File

53
go.mod Normal file
View File

@ -0,0 +1,53 @@
module drone-kubernetes
go 1.20
require (
github.com/urfave/cli/v2 v2.25.7
k8s.io/api v0.28.3
k8s.io/apimachinery v0.28.3
k8s.io/client-go v0.28.3
)
require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.8.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)

156
go.sum Normal file
View File

@ -0,0 +1,156 @@
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE=
github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28=
github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/onsi/ginkgo/v2 v2.9.4 h1:xR7vG4IXt5RWx6FfIjyAtsoMAtnc3C/rFXBBd2AjZwE=
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/oauth2 v0.8.0 h1:6dkIjl3j3LtZ/O3sTgZTMsLKSftL/B8Zgq4huOIIUu8=
golang.org/x/oauth2 v0.8.0/go.mod h1:yr7u4HXZRm1R1kBWqr/xKNqewf0plRYoB7sla+BCIXE=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.13.0 h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.28.3 h1:Gj1HtbSdB4P08C8rs9AR94MfSGpRhJgsS+GF9V26xMM=
k8s.io/api v0.28.3/go.mod h1:MRCV/jr1dW87/qJnZ57U5Pak65LGmQVkKTzf3AtKFHc=
k8s.io/apimachinery v0.28.3 h1:B1wYx8txOaCQG0HmYF6nbpU8dg6HvA06x5tEffvOe7A=
k8s.io/apimachinery v0.28.3/go.mod h1:uQTKmIqs+rAYaq+DFaoD2X7pcjLOqbQX2AOiO0nIpb8=
k8s.io/client-go v0.28.3 h1:2OqNb72ZuTZPKCl+4gTKvqao0AMOl9f3o2ijbAj3LI4=
k8s.io/client-go v0.28.3/go.mod h1:LTykbBp9gsA7SwqirlCXBWtK0guzfhpoW4qSm7i9dxo=
k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg=
k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0=
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 h1:LyMgNKD2P8Wn1iAwQU5OhxCKlKJy0sHc+PcDwFB24dQ=
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9/go.mod h1:wZK2AVp1uHCp4VamDVgBP2COHZjqD1T68Rf0CM3YjSM=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2 h1:qY1Ad8PODbnymg2pRbkyMT/ylpTrCM8P2RJ0yroCyIk=
k8s.io/utils v0.0.0-20230406110748-d93618cff8a2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE=
sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E=
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8=

126
k8s/client.go Normal file
View File

@ -0,0 +1,126 @@
package k8s
import (
"context"
"errors"
"fmt"
appv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/json"
"k8s.io/client-go/kubernetes"
kindv1 "k8s.io/client-go/kubernetes/typed/apps/v1"
"strings"
"time"
)
type client struct {
kubernetes.Interface
}
// Client
// @description: 获取客户端
// @receiver c
// @return *client
// @return error
func (c *config) Client() (*client, error) {
kubeClient, err := kubernetes.NewForConfig(c.resetConf)
if err != nil {
return nil, err
}
return &client{kubeClient}, nil
}
// Do
// @description: 执行
// @receiver c
// @param namespace
// @param kind
// @param resourceName
// @param actionMethod
// @param repo
// @return err
func (c client) Do(namespace, kind, resourceName, actionMethod, repo string) (err error) {
fmt.Println("命名空间: ", namespace)
fmt.Println("资源类型: ", kind)
fmt.Println("资源名称: ", resourceName)
fmt.Println("操作类型: ", actionMethod)
fmt.Println("镜像地址: ", repo)
var kindType any // 应用类型
var resource any // 资源详情
switch kind {
case "Deployment":
kindType = c.AppsV1().Deployments(namespace)
// 获取一下资源
resource, err = kindType.(kindv1.DeploymentInterface).Get(context.Background(), resourceName, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("get deployment error: %v", err.Error())
}
switch actionMethod {
case "create":
case "update": // 更新目前仅支持更新镜像和tag
if err != nil && resource == nil {
return fmt.Errorf("get deployment error: %v", err.Error())
}
if repo == "" {
return fmt.Errorf("repo not empty")
}
// 解析规则判断是只单独变更tag还是镜像整个替换
if !strings.Contains(repo, ":") {
resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image = fmt.Sprintf("%s:%s", strings.Split(resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image, ":")[0], repo)
} else {
resource.(*appv1.Deployment).Spec.Template.Spec.Containers[0].Image = repo
}
_, err = kindType.(kindv1.DeploymentInterface).Update(context.Background(), resource.(*appv1.Deployment), metav1.UpdateOptions{})
if err != nil {
return fmt.Errorf("update deployment error: %v", err.Error())
}
case "delete": // 删除应用
if err != nil && resource == nil {
return fmt.Errorf("get deployment error: %v", err.Error())
}
err = kindType.(kindv1.DeploymentInterface).Delete(context.Background(), resourceName, metav1.DeleteOptions{})
if err != nil {
return err
}
case "restart": // 重启应用
if err != nil && resource == nil {
return fmt.Errorf("get deployment error: %v", err.Error())
}
rJ, _ := json.Marshal(resource)
fmt.Println(string(rJ))
resource.(*appv1.Deployment).Spec.Template.ObjectMeta.Annotations["kubectl.kubernetes.io/restartedAt"] = time.Now().Local().String()
_, err = kindType.(kindv1.DeploymentInterface).Update(context.Background(), resource.(*appv1.Deployment), metav1.UpdateOptions{})
if err != nil {
return err
}
}
kindType = c.AppsV1().Deployments(namespace)
default:
return errors.New("not support")
}
return nil
}

156
k8s/config.go Normal file
View File

@ -0,0 +1,156 @@
package k8s
import (
"fmt"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
"os"
"strings"
)
type config struct {
Host string `json:"host"` // K8S地址
AuthType AuthType `json:"authType"` // 认证方式 0:config 1:token
Config string `json:"config"` // 认证配置文件
Token string `json:"token"` // 认证Token
IsSkipTls bool `json:"isSkipTls"` // 是否跳过TLS认证
CaCrt string `json:"caCrt"` // CA证书
ClusterName string `json:"clusterName"` // 集群名称
resetConf *rest.Config
}
type option func(c *config)
func WithHost(host string) option {
return func(c *config) {
c.Host = host
}
}
func WithAuthType(authType string) option {
return func(c *config) {
switch strings.ToUpper(authType) {
case "CONFIG":
c.AuthType = AuthConfig
case "TOKEN":
c.AuthType = AuthToken
}
}
}
func WithConfig(conf string) option {
return func(c *config) {
c.Config = conf
}
}
func WithToken(token string) option {
return func(c *config) {
c.Token = token
}
}
func WithIsSkipTls(isSkipTls bool) option {
return func(c *config) {
c.IsSkipTls = isSkipTls
}
}
func WithCaCrt(caCrt string) option {
return func(c *config) {
c.CaCrt = caCrt
}
}
func WithCluster(cluster string) option {
return func(c *config) {
c.ClusterName = cluster
}
}
func NewConfig(opts ...option) (*config, error) {
c := &config{}
for _, opt := range opts {
opt(c)
}
if err := c.valid(); err != nil {
return nil, err
}
var restConfig *rest.Config
var err error
switch c.AuthType {
case AuthToken:
restConfig, err = clientcmd.BuildConfigFromKubeconfigGetter(c.Host, func() (*api.Config, error) {
apiConf := &api.Config{
Clusters: map[string]*api.Cluster{
c.ClusterName: {
Server: c.Host,
InsecureSkipTLSVerify: c.IsSkipTls,
CertificateAuthorityData: []byte(c.CaCrt),
},
},
AuthInfos: map[string]*api.AuthInfo{
c.ClusterName: {
Token: c.Token,
},
},
Contexts: map[string]*api.Context{
c.ClusterName: {
Cluster: c.ClusterName,
AuthInfo: c.ClusterName,
},
},
CurrentContext: c.ClusterName,
}
// 如果跳过TLS认证则清空CA证书
if c.IsSkipTls {
apiConf.Clusters[c.ClusterName].InsecureSkipTLSVerify = c.IsSkipTls
apiConf.Clusters[c.ClusterName].CertificateAuthorityData = nil
}
return apiConf, nil
})
case AuthConfig:
restConfig, err = clientcmd.BuildConfigFromFlags(c.Host, c.GetConfigPath())
}
if err != nil {
return nil, err
}
c.resetConf = restConfig
return c, nil
}
func (c *config) valid() error {
if !strings.HasPrefix(c.Host, "https://") && !strings.HasPrefix(c.Host, "http://") {
c.Host = fmt.Sprintf("https://%s", c.Host)
}
if c.Token == "" && c.Config == "" {
return fmt.Errorf("auth token or auth config not empty")
}
if c.ClusterName == "" {
c.ClusterName = "default"
}
return nil
}
func (c *config) GetConfigPath() string {
if err := os.WriteFile("./kubernetes", []byte(c.Config), 0644); err != nil {
panic(err)
}
return "./kubernetes"
}

8
k8s/const.go Normal file
View File

@ -0,0 +1,8 @@
package k8s
type AuthType int
const (
AuthConfig = iota
AuthToken
)

134
main.go Normal file
View File

@ -0,0 +1,134 @@
package main
import (
"drone-kubernetes/k8s"
"fmt"
"github.com/urfave/cli/v2"
"os"
)
func main() {
app := &cli.App{
Name: "drone-kubernetes",
Usage: "Drone plugin to deploy to kubernetes",
}
app.Action = run
app.Flags = []cli.Flag{
&cli.StringFlag{
Required: true,
Name: "k8s_host",
Usage: "k8s ip+port or domain",
EnvVars: []string{"PLUGIN_K8S_HOST"},
},
&cli.StringFlag{
Required: true,
Name: "k8s_auth_type",
Usage: "k8s auth type example: token,config",
EnvVars: []string{"PLUGIN_K8S_AUTH_TYPE"},
},
&cli.StringFlag{
Name: "k8s_auth_config",
Usage: "k8s auth config",
EnvVars: []string{"PLUGIN_K8S_AUTH_CONFIG"},
},
&cli.StringFlag{
Name: "k8s_auth_token",
Usage: "k8s auth token",
EnvVars: []string{"PLUGIN_K8S_AUTH_TOKEN"},
},
&cli.StringFlag{
Name: "k8s_auth_ca_crt",
Usage: "k8s auth ca crt",
EnvVars: []string{"PLUGIN_K8S_AUTH_CA_CRT"},
},
&cli.BoolFlag{
Name: "k8s_auth_skip_tls",
Usage: "k8s auth skip tls",
EnvVars: []string{"PLUGIN_K8S_AUTH_SKIP_TLS"},
},
&cli.StringFlag{
Required: true,
Name: "k8s_namespace",
Usage: "k8s namespace example: default",
DefaultText: "default",
EnvVars: []string{"PLUGIN_K8S_NAMESPACE"},
},
&cli.StringFlag{
Required: true,
Name: "kind",
Usage: "workload type,example: deployment,service...",
EnvVars: []string{"PLUGIN_KIND"},
},
&cli.StringFlag{
Required: true,
Name: "resource_name",
Usage: "resource name,example: deployments name pod name",
EnvVars: []string{"PLUGIN_RESOURCE_NAME"},
},
&cli.StringFlag{
Required: true,
Name: "action_method",
Aliases: []string{"acm"},
Usage: "workload action method,example: create,update,delete,restart...",
EnvVars: []string{"PLUGIN_ACTION_METHOD"},
},
&cli.StringFlag{
Name: "repo",
Usage: "repo",
EnvVars: []string{"PLUGIN_REPO"},
},
}
// 启动
err := app.Run(os.Args)
if err != nil {
panic(err)
}
}
func run(c *cli.Context) error {
authType := c.String("k8s_auth_type")
authConfig := c.String("k8s_auth_config")
authToken := c.String("k8s_auth_token")
if (authType != "") && (authConfig == "" && authToken == "") {
return cli.Exit("auth token or auth config not empty", 1)
}
if c.String("action_method") == "update" {
if c.String("repo") == "" {
return cli.Exit("repo not empty", 1)
}
}
k8sConf, err := k8s.NewConfig(
k8s.WithHost(c.String("k8s_host")),
k8s.WithAuthType(c.String("k8s_auth_type")),
k8s.WithConfig(c.String("k8s_auth_config")),
k8s.WithToken(c.String("k8s_auth_token")),
k8s.WithCaCrt(c.String("k8s_auth_ca_crt")),
k8s.WithIsSkipTls(c.Bool("k8s_auth_skip_tls")),
)
if err != nil {
return err
}
client, err := k8sConf.Client()
if err != nil {
fmt.Println("k8s client error: ", err.Error())
return cli.Exit("k8s client error", 1)
}
if err = client.Do(c.String("k8s_namespace"), c.String("kind"), c.String("resource_name"), c.String("action_method"), c.String("repo")); err != nil {
return cli.Exit(err.Error(), 1)
}
return nil
}