mirror of https://github.com/helm/helm
Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>pull/5255/head
parent
087d1eab52
commit
5c4af6f275
@ -0,0 +1,83 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/helm/cmd/helm/require"
|
||||
)
|
||||
|
||||
const libraryDesc = `
|
||||
Manage the libraries of a chart.
|
||||
|
||||
Helm charts store their libraries in 'library/'. For chart developers, it is
|
||||
often easier to manage libraries in 'Chart.yaml' which declares all
|
||||
libraries.
|
||||
|
||||
The library commands operate on that file, making it easy to synchronize
|
||||
between the desired libraries and the actual libraries stored in the
|
||||
'library/' directory.
|
||||
|
||||
For example, this Chart.yaml declares one library:
|
||||
|
||||
# Chart.yaml
|
||||
libraries:
|
||||
- name: common
|
||||
version: "^2.1.0"
|
||||
repository: http://another.example.com/charts
|
||||
|
||||
|
||||
The 'name' should be the name of a chart, where that name must match the name
|
||||
in that chart's 'Chart.yaml' file.
|
||||
|
||||
The 'version' field should contain a semantic version or version range.
|
||||
|
||||
The 'repository' URL should point to a Chart Repository. Helm expects that by
|
||||
appending '/index.yaml' to the URL, it should be able to retrieve the chart
|
||||
repository's index. Note: 'repository' can be an alias. The alias must start
|
||||
with 'alias:' or '@'.
|
||||
|
||||
Starting from 2.2.0, repository can be defined as the path to the directory of
|
||||
the library charts stored locally. The path should start with a prefix of
|
||||
"file://". For example,
|
||||
|
||||
# Chart.yaml
|
||||
libraries:
|
||||
- name: common
|
||||
version: "^2.1.0"
|
||||
repository: "file://../library_chart/common"
|
||||
|
||||
If the library chart is retrieved locally, it is not required to have the
|
||||
repository added to helm by "helm add repo". Version matching is also supported
|
||||
for this case.
|
||||
`
|
||||
|
||||
func newLibraryCmd(out io.Writer) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "library update",
|
||||
Aliases: []string{"lib", "libraries"},
|
||||
Short: "manage a chart's libraries",
|
||||
Long: libraryDesc,
|
||||
Args: require.NoArgs,
|
||||
}
|
||||
|
||||
cmd.AddCommand(newLibraryUpdateCmd(out))
|
||||
|
||||
return cmd
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/helm/cmd/helm/require"
|
||||
)
|
||||
|
||||
const libraryUpDesc = `
|
||||
Update the on-disk libraries to mirror Chart.yaml.
|
||||
|
||||
This command verifies that the required charts, as expressed in 'Chart.yaml',
|
||||
are present in 'library/' and are at an acceptable version. It will pull down
|
||||
the latest charts that satisfy the libraries, and clean up old libraries.
|
||||
|
||||
On successful update, this will generate a lock file that can be used to
|
||||
rebuild the libraries to an exact version.
|
||||
|
||||
Libraries are not required to be represented in 'Chart.yaml'. For that
|
||||
reason, an update command will not remove charts unless they are (a) present
|
||||
in the Chart.yaml file, but (b) at the wrong version.
|
||||
`
|
||||
|
||||
// newLibraryUpdateCmd creates a new library update command.
|
||||
func newLibraryUpdateCmd(out io.Writer) *cobra.Command {
|
||||
o := &refUpdateOptions{
|
||||
chartpath: ".",
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "update CHART",
|
||||
Aliases: []string{"up"},
|
||||
Short: "update library/ based on the contents of Chart.yaml",
|
||||
Long: libraryUpDesc,
|
||||
Args: require.MaximumNArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if len(args) > 0 {
|
||||
o.chartpath = filepath.Clean(args[0])
|
||||
}
|
||||
o.helmhome = settings.Home
|
||||
return o.run(out, true)
|
||||
},
|
||||
}
|
||||
|
||||
f := cmd.Flags()
|
||||
f.BoolVar(&o.verify, "verify", false, "verify the packages against signatures")
|
||||
f.StringVar(&o.keyring, "keyring", defaultKeyring(), "keyring containing public keys")
|
||||
f.BoolVar(&o.skipRefresh, "skip-refresh", false, "do not refresh the local repository cache")
|
||||
|
||||
return cmd
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright The Helm Authors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"k8s.io/helm/pkg/downloader"
|
||||
"k8s.io/helm/pkg/getter"
|
||||
"k8s.io/helm/pkg/helm/helmpath"
|
||||
)
|
||||
|
||||
// refUpdateOptions describes a 'helm library/dependency update'
|
||||
type refUpdateOptions struct {
|
||||
keyring string // --keyring
|
||||
skipRefresh bool // --skip-refresh
|
||||
verify bool // --verify
|
||||
|
||||
// args
|
||||
chartpath string
|
||||
|
||||
helmhome helmpath.Home
|
||||
}
|
||||
|
||||
// run runs the full library update process.
|
||||
func (o *refUpdateOptions) run(out io.Writer, lib bool) error {
|
||||
man := &downloader.Manager{
|
||||
Out: out,
|
||||
ChartPath: o.chartpath,
|
||||
HelmHome: o.helmhome,
|
||||
Keyring: o.keyring,
|
||||
SkipUpdate: o.skipRefresh,
|
||||
Getters: getter.All(settings),
|
||||
}
|
||||
if o.verify {
|
||||
man.Verify = downloader.VerifyAlways
|
||||
}
|
||||
if settings.Debug {
|
||||
man.Debug = true
|
||||
}
|
||||
return man.Update(lib)
|
||||
}
|
Loading…
Reference in new issue