Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
1105 Внедрение механизмов обеспечения безопасности цепочки поставки программных проектов
Legacy
scanned-projects
helm
Commits
3b51dfbd
Unverified
Commit
3b51dfbd
authored
5 years ago
by
Matthew Fisher
Committed by
GitHub
5 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #3478 from hypnoglow/expose-repofile-get
ref(helm): expose Get for repository file
parents
01f775d0
a8db3be0
release-2.17
dev-v2
release-2.15
release-2.16
v2.17.0
v2.17.0-rc.1
v2.16.12
v2.16.11
v2.16.10
v2.16.9
v2.16.8
v2.16.7
v2.16.6
v2.16.5
v2.16.4
v2.16.3
v2.16.2
v2.16.1
v2.16.0
v2.16.0-rc.2
v2.16.0-rc.1
v2.15.2
v2.15.1
v2.15.0
v2.15.0-rc.2
v2.15.0-rc.1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pkg/repo/repo.go
+10
-4
pkg/repo/repo.go
pkg/repo/repo_test.go
+43
-4
pkg/repo/repo_test.go
with
53 additions
and
8 deletions
+53
-8
pkg/repo/repo.go
+
10
−
4
View file @
3b51dfbd
...
...
@@ -117,12 +117,18 @@ func (r *RepoFile) Update(re ...*Entry) {
// Has returns true if the given name is already a repository name.
func
(
r
*
RepoFile
)
Has
(
name
string
)
bool
{
for
_
,
rf
:=
range
r
.
Repositories
{
if
rf
.
Name
==
name
{
return
true
_
,
ok
:=
r
.
Get
(
name
)
return
ok
}
// 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
false
return
nil
,
false
}
// Remove removes the entry from the list of repositories.
...
...
This diff is collapsed.
Click to expand it.
pkg/repo/repo_test.go
+
43
−
4
View file @
3b51dfbd
...
...
@@ -16,10 +16,12 @@ limitations under the License.
package
repo
import
"testing"
import
"io/ioutil"
import
"os"
import
"strings"
import
(
"io/ioutil"
"os"
"strings"
"testing"
)
const
testRepositoriesFile
=
"testdata/repositories.yaml"
...
...
@@ -120,6 +122,43 @@ 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
)
{
sampleRepository
:=
NewRepoFile
()
sampleRepository
.
Add
(
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets