欢迎关注我的公众号:

目前刚开始写一个月,一共写了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 newDependencyUpdateCmd(out io.Writer) *cobra.Command {//创建dependecny update命令
  client := action.NewDependency()//初始化结构体
  cmd := &cobra.Command{//创建cobra命令
    Use:     "update CHART",
    Aliases: []string{"up"},
    Short:   "update charts/ based on the contents of Chart.yaml",
    Long:    dependencyUpDesc,
    Args:    require.MaximumNArgs(1),
    RunE: func(cmd *cobra.Command, args []string) error {
      chartpath := "."//设置chartpath为当前目录
      if len(args) > 0 {//如果参数大于0个,设置chart目录为第一个参数
        chartpath = filepath.Clean(args[0])
      }
      man := &downloader.Manager{//构造manager
        Out:              out,
        ChartPath:        chartpath,
        Keyring:          client.Keyring,
        SkipUpdate:       client.SkipRefresh,
        Getters:          getter.All(settings),
        RepositoryConfig: settings.RepositoryConfig,
        RepositoryCache:  settings.RepositoryCache,
        Debug:            settings.Debug,
      }
      if client.Verify {//判断是否verify
        man.Verify = downloader.VerifyAlways
      }
      return man.Update()//执行更新
    },
  }
  f := cmd.Flags()
  f.BoolVar(&client.Verify, "verify", false, "verify the packages against signatures")//verify选项
  f.StringVar(&client.Keyring, "keyring", defaultKeyring(), "keyring containing public keys")//keyring选项
  f.BoolVar(&client.SkipRefresh, "skip-refresh", false, "do not refresh the local repository cache")//skip-refresh选项
  return cmd
}func (m *Manager) Update() error {//执行更新
  c, err := m.loadChartDir()//加载chart
  if err != nil {
    return err
  }
  // If no dependencies are found, we consider this a successful
  // completion.
  req := c.Metadata.Dependencies//获取chart的依赖
  if req == nil {
    return nil
  }
  // Check that all of the repos we're dependent on actually exist and
  // the repo index names.
  repoNames, err := m.resolveRepoNames(req)//解析仓库名称
  if err != nil {
    return err
  }
  // For each repo in the file, update the cached copy of that repo
  if !m.SkipUpdate {//如果不跳过update
    if err := m.UpdateRepositories(); err != nil {//更新仓库
      return err
    }
  }
  // Now we need to find out which version of a chart best satisfies the
  // dependencies in the Chart.yaml
  lock, err := m.resolve(req, repoNames)//解析依赖版本
  if err != nil {
    return err
  }
  // Now we need to fetch every package here into charts/
  if err := m.downloadAll(lock.Dependencies); err != nil {//下载依赖
    return err
  }
  // downloadAll might overwrite dependency version, recalculate lock digest
  newDigest, err := resolver.HashReq(req, lock.Dependencies)//计算依赖hash
  if err != nil {
    return err
  }
  lock.Digest = newDigest//设置hash
  // If the lock file hasn't changed, don't write a new one.
  oldLock := c.Lock
  if oldLock != nil && oldLock.Digest == lock.Digest {//如果新旧hash相同则直接返回
    return nil
  }
  // Finally, we need to write the lockfile.
  return writeLock(m.ChartPath, lock, c.Metadata.APIVersion == chart.APIVersionV1)//写依赖lock文件
}//写依赖lock文件
func writeLock(chartpath string, lock *chart.Lock, legacyLockfile bool) error {
data, err := yaml.Marshal(lock)//把lock文件内容转成yaml
if err != nil {
return err
}
lockfileName := "Chart.lock"//设置lock文件名称
if legacyLockfile {//如果是老版本,设置lock文件名称
lockfileName = "requirements.lock"
}
dest := filepath.Join(chartpath, lockfileName)//获取完成文件名称
return ioutil.WriteFile(dest, data, 0644)//写数据到文件
}










