欢迎关注我的公众号:

目前刚开始写一个月,一共写了18篇原创文章,文章目录如下:
istio多集群探秘,部署了50次多集群后我得出的结论
istio多集群链路追踪,附实操视频
istio防故障利器,你知道几个,istio新手不要读,太难!
istio业务权限控制,原来可以这么玩
istio实现非侵入压缩,微服务之间如何实现压缩
不懂envoyfilter也敢说精通istio系列-http-rbac-不要只会用AuthorizationPolicy配置权限
不懂envoyfilter也敢说精通istio系列-02-http-corsFilter-不要只会vs
不懂envoyfilter也敢说精通istio系列-03-http-csrf filter-再也不用再代码里写csrf逻辑了
不懂envoyfilter也敢说精通istio系列http-jwt_authn-不要只会RequestAuthorization
不懂envoyfilter也敢说精通istio系列-05-fault-filter-故障注入不止是vs
不懂envoyfilter也敢说精通istio系列-06-http-match-配置路由不只是vs
不懂envoyfilter也敢说精通istio系列-07-负载均衡配置不止是dr
不懂envoyfilter也敢说精通istio系列-08-连接池和断路器
不懂envoyfilter也敢说精通istio系列-09-http-route filter
不懂envoyfilter也敢说精通istio系列-network filter-redis proxy
不懂envoyfilter也敢说精通istio系列-network filter-HttpConnectionManager
不懂envoyfilter也敢说精通istio系列-ratelimit-istio ratelimit完全手册
------------------------------------------------------------------------------------------------------------
func newDependencyCmd(out io.Writer) *cobra.Command {//创建dependency命令
  cmd := &cobra.Command{//创建cobra命令
    Use:     "dependency update|build|list",
    Aliases: []string{"dep", "dependencies"},
    Short:   "manage a chart's dependencies",
    Long:    dependencyDesc,
    Args:    require.NoArgs,
  }
  cmd.AddCommand(newDependencyListCmd(out))//添加list命令
  cmd.AddCommand(newDependencyUpdateCmd(out))//添加update命令
  cmd.AddCommand(newDependencyBuildCmd(out))//添加build命令
  return cmd
}func newDependencyListCmd(out io.Writer) *cobra.Command {//创建dependency list命令
  client := action.NewDependency()//初始化结构体
  cmd := &cobra.Command{//创建cobra命令
    Use:     "list CHART",
    Aliases: []string{"ls"},
    Short:   "list the dependencies for the given chart",
    Long:    dependencyListDesc,
    Args:    require.MaximumNArgs(1),
    RunE: func(cmd *cobra.Command, args []string) error {
      chartpath := "."//设置chartpath
      if len(args) > 0 {//如果参数个数大于0个,则设置第0个参数为chartpath
        chartpath = filepath.Clean(args[0])
      }
      return client.List(chartpath, out)//运行命令
    },
  }
  return cmd
}type Dependency struct {//dependency结构体
  Verify      bool
  Keyring     string
  SkipRefresh bool
}
// NewDependency creates a new Dependency object with the given configuration.
func NewDependency() *Dependency {//初始化结构体
  return &Dependency{}
}func (d *Dependency) List(chartpath string, out io.Writer) error {//list denendency
  c, err := loader.Load(chartpath)//加载chart
  if err != nil {
    return err
  }
  if c.Metadata.Dependencies == nil {//如果chart没有dependency则打印告警,返回
    fmt.Fprintf(out, "WARNING: no dependencies at %s\n", filepath.Join(chartpath, "charts"))
    return nil
  }
  d.printDependencies(chartpath, out, c.Metadata.Dependencies)//打印依赖
  fmt.Fprintln(out)
    d.printMissing(chartpath, out, c.Metadata.Dependencies)//打印丢失的依赖
  return nil
}//打印依赖
func (d *Dependency) printDependencies(chartpath string, out io.Writer, reqs []*chart.Dependency) {
table := uitable.New()//创建table
table.MaxColWidth = 80//设置宽度
table.AddRow("NAME", "VERSION", "REPOSITORY", "STATUS")// 添加头
for _, row := range reqs {// 打印依赖
table.AddRow(row.Name, row.Version, row.Repository, d.dependencyStatus(chartpath, row))
}
fmt.Fprintln(out, table)//打印表格
}
//打印丢失的依赖
func (d *Dependency) printMissing(chartpath string, out io.Writer, reqs []*chart.Dependency) {
folder := filepath.Join(chartpath, "charts/*")//获取charts目录
files, err := filepath.Glob(folder)//获取charts目录文件
if err != nil {
fmt.Fprintln(out, err)
return
}
for _, f := range files {//遍历文件
fi, err := os.Stat(f)//判断文件状态
if err != nil {
fmt.Fprintf(out, "Warning: %s\n", err)
}
// Skip anything that is not a directory and not a tgz file.
if !fi.IsDir() && filepath.Ext(f) != ".tgz" {//判断文件是否是目录或tgz文件
continue
}
c, err := loader.Load(f)//加载chart
if err != nil {
fmt.Fprintf(out, "WARNING: %q is not a chart.\n", f)
continue
}
found := false
for _, d := range reqs {//遍历依赖
if d.Name == c.Name() {//如果依赖名称和chart名称相同则找到
found = true
break
}
}
if !found {//没找到则打印告警
fmt.Fprintf(out, "WARNING: %q is not in Chart.yaml.\n", f)
}
}
}










