mavenproxy

package module
v0.0.0-...-a3cc0ba Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: MIT Imports: 25 Imported by: 0

README

一.插件描述

该模块借鉴了maven-manager, maven-manager使用java开发, 我在部署试用时 发现内存占用过大,且想整合多个中央参股功能, 所以用Go框架重新实现了一遍

  • 1.本人使用的Go版本为: 1.18.8
  • 2.配置文件读取来源于goframe默认的配置文件config.yaml,默认参数也可通过代码参数自行修改
  • 3.默认配置及参数字段具体释义见配置文件说明

二.插件必要的配置文件参数

1.配置文件说明

# 在gofarme框架默认读取的config.yml中添加自定义项maven
center:
    proxy:
      ###maven模块    #################################
      maven:
        cache: embedFs      #可以填写参数:本地embedFs/本地Cos服务minioCos/腾讯Cos服务tencentCos
        buffName: maven # 本地仓库地址,存储路径
        mirror: # 镜像地址, 会先尝试在本地加载, 如果加载失败, 会尝试从镜像依次读取
          - https://maven.aliyun.com/nexus/content/repositories/public
          - https://repo1.maven.org/maven2
        repository: # 仓库设置
          - id: public # 仓库ID
            name: public repository # 仓库名字, 随意,唯一即可
            mode: 6 # 模式,默认为6,参数描述:0 无效 2 仅可写 4 仅可读 6 可读写
            cache: true # 是否缓存镜像文件, 默认缓存,参数描述:true 缓存 false不缓存
            target: public # 数据目录, buffName的相对路径, 默认取id值
          - id: private
            name: private repository
            mode: 4

2.启动参数自定义

  • 1.方法一(默认):读取程序内嵌指定的config.yaml中的配置文件
  • 2.方法二:存放配置config.yaml文件到启动时读取当前工作或执行目录下的configmanifest/config目录下
  • 3.方法三:通过命令行启动指定参数: ./main --gf.gcfg.file=config.prod.toml

三.拓展:定制开发module模块

1.指定gitee.com 为私有仓库

# 配置开启gomod
go env -w GO111MODULE="on"
# 配置GoMod私有仓库
go env -w GOPRIVATE="git@gitee.com"
# 配置不加密访问
go env -w GOINSECURE="gitee.com"
# 配置不使用代理
go env -w GONOPROXY="gitee.com"
# 配置不验证包
go env -w GONOSUMDB="gitee.com"

注意:经测试,go get 的tag 需在master分支方可下载最新代码

四.部署后代理仓库服务用法

步骤一:修改maven配置修改

参数描述:
  • id 建议为配置文件下repository节点id值
  • username 建议为配置文件下authUser节点对应的用户名称
  • password 建议为配置文件下authUser节点对应的用户密码
<!-- 这里是需要上传的账号密码 -->
<servers>
    <server>
        <!--建议为配置文件下repository节点的名称 -->
        <id>public</id>
        <!--建议为配置文件下authUser节点对应的用户名称 -->
        <username>admin</username>
        <!--建议为配置文件下authUser节点对应的用户密码 -->
        <password>password</password>
    </server>
    <server>
        <id>private</id>
        <username>admin</username>
        <password>password</password>
    </server>
</servers>

步骤二:代理服务仓库修改

参数描述:
  • id 建议为配置文件下repository节点id值
  • name 建议为配置文件下repository节点name值
  • url 为当前服务ip:port/maven/public

<mirror>
    <id>public</id>
    <name>public repository</name>
    <url>http://localhost:10010/proxy/maven/public</url>
    <mirrorOf>central</mirrorOf>
</mirror>

步骤三:springboot工程项目中pom.xml文件修改


<distributionManagement>
    <repository>
        <id>public</id>
        <name>public repository</name>
        <url>http://localhost:10010/proxy/maven/public</url>
    </repository>
    <snapshotRepository>
        <id>private</id>
        <name>public repository</name>
        <url>http://localhost:10010/proxy/maven/public</url>
    </snapshotRepository>
</distributionManagement>

Documentation

Overview

Package mavenproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License

Package mavenproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License

Package mavenproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License

Package mavenproxy @Link https://gitee.com/linngc/center.gf @Copyright Copyright (c) 2022 center CLI @Author linngc @License

Index

Constants

This section is empty.

Variables

View Source
var Maven = cMaven{}

Functions

This section is empty.

Types

type AuthFunc

type AuthFunc func(authorization string) bool

AuthFunc 鉴权判断

type MavenConfig

type MavenConfig struct {
	Cache      string                 `yaml:"cache" default:"embedFs"  dc:"缓存类型:embedFs/minioCos/tencentCos"`
	BuffName   string                 `yaml:"buffName" default:"maven"  dc:"存储位置"`
	Mirror     []string               `` /* 222-byte string literal not displayed */
	Repository map[string]*Repository `yaml:"repository" default:"[{\"Id\":\"public\",\"Name\":\"mirror\"}]"`
}

type Repository

type Repository struct {
	Id     string `yaml:"id" dc:"仓库ID"`
	Name   string `yaml:"name" dc:"仓库名字, 随意,唯一即可"`
	Target string `yaml:"target" dc:"数据目录, buffName的相对路径, 默认取id值"`
	Mode   int    `yaml:"mode" default:"6" dc:"模式,默认为6,参数描述:0 无效 2 仅可写 4 仅可读 6 可读写"`
	Auth   bool   `yaml:"auth" default:"true" dc:"是否鉴权, 默认鉴权,参数描述:true 鉴权 false不鉴权"`
	Cache  bool   `yaml:"cache" default:"true" dc:"是否缓存镜像文件, 默认缓存,参数描述:true 缓存 false不缓存"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL