Revert "ref(helm): expose Get for repository file"

This reverts commit db578b51f8.

Signed-off-by: Sebastien Plisson <sebastien.plisson@gmail.com>
pull/3422/head
Sebastien Plisson 6 years ago
parent c8506ac96a
commit b8f17ee8f5

@ -117,18 +117,12 @@ func (r *RepoFile) Update(re ...*Entry) {
// Has returns true if the given name is already a repository name. // Has returns true if the given name is already a repository name.
func (r *RepoFile) Has(name string) bool { func (r *RepoFile) Has(name string) bool {
_, ok := r.Get(name) for _, rf := range r.Repositories {
return ok if rf.Name == name {
} return true
// Get returns entry by the given name if it exists.
func (r *RepoFile) Get(name string) (*Entry, bool) {
for _, entry := range r.Repositories {
if entry.Name == name {
return entry, true
} }
} }
return nil, false return false
} }
// Remove removes the entry from the list of repositories. // Remove removes the entry from the list of repositories.

@ -16,12 +16,10 @@ limitations under the License.
package repo package repo
import ( import "testing"
"io/ioutil" import "io/ioutil"
"os" import "os"
"strings" import "strings"
"testing"
)
const testRepositoriesFile = "testdata/repositories.yaml" const testRepositoriesFile = "testdata/repositories.yaml"
@ -122,43 +120,6 @@ func TestNewPreV1RepositoriesFile(t *testing.T) {
} }
} }
func TestRepoFile_Get(t *testing.T) {
repo := NewRepoFile()
repo.Add(
&Entry{
Name: "first",
URL: "https://example.com/first",
Cache: "first-index.yaml",
},
&Entry{
Name: "second",
URL: "https://example.com/second",
Cache: "second-index.yaml",
},
&Entry{
Name: "third",
URL: "https://example.com/third",
Cache: "third-index.yaml",
},
&Entry{
Name: "fourth",
URL: "https://example.com/fourth",
Cache: "fourth-index.yaml",
},
)
name := "second"
entry, ok := repo.Get(name)
if !ok {
t.Fatalf("Expected repo entry %q to be found", name)
}
if entry.URL != "https://example.com/second" {
t.Fatalf("Expected repo URL to be %q but got %q", "https://example.com/second", entry.URL)
}
}
func TestRemoveRepository(t *testing.T) { func TestRemoveRepository(t *testing.T) {
sampleRepository := NewRepoFile() sampleRepository := NewRepoFile()
sampleRepository.Add( sampleRepository.Add(

Loading…
Cancel
Save