mirror of https://github.com/artifacthub/hub.git
Generic tracker now supports README.md files (#1276)
Signed-off-by: Sergio Castaño Arteaga <tegioz@icloud.com>
This commit is contained in:
parent
daafabc5ae
commit
9538cc7069
|
|
@ -24,7 +24,7 @@ keywords: # (optional)
|
|||
links: # (optional)
|
||||
- name: Title of the link (required for each link)
|
||||
url: URL of the link (required for each link)
|
||||
readme: | # (optional)
|
||||
readme: | # (optional, can be provided from a README.md file as well)
|
||||
Package documentation in markdown format
|
||||
|
||||
Content added here will be rendered on Artifact Hub
|
||||
|
|
|
|||
|
|
@ -80,6 +80,15 @@ func (s *TrackerSource) preparePackage(r *hub.Repository, md *hub.PackageMetadat
|
|||
}
|
||||
p.Repository = r
|
||||
|
||||
// If the readme content hasn't been provided in the metadata file, try to
|
||||
// get it from the README.md file.
|
||||
if p.Readme == "" {
|
||||
readme, err := ioutil.ReadFile(filepath.Join(pkgPath, "README.md"))
|
||||
if err == nil {
|
||||
p.Readme = string(readme)
|
||||
}
|
||||
}
|
||||
|
||||
// Include kind specific data into package
|
||||
ignorer := ignore.CompileIgnoreLines(md.Ignore...)
|
||||
var data map[string]interface{}
|
||||
|
|
|
|||
|
|
@ -292,4 +292,36 @@ func TestTrackerSource(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
sw.AssertExpectations(t)
|
||||
})
|
||||
|
||||
t.Run("opa package returned (README.md file), no errors", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Setup services and expectations
|
||||
sw := source.NewTestsServicesWrapper()
|
||||
i := &hub.TrackerSourceInput{
|
||||
Repository: &hub.Repository{
|
||||
Kind: hub.OPA,
|
||||
},
|
||||
BasePath: "testdata/path9",
|
||||
Svc: sw.Svc,
|
||||
}
|
||||
sw.Is.On("SaveImage", sw.Svc.Ctx, imageData).Return("logoImageID", nil)
|
||||
|
||||
// Run test and check expectations
|
||||
p := source.ClonePackage(basePkg)
|
||||
p.Repository = i.Repository
|
||||
p.LogoImageID = "logoImageID"
|
||||
p.Data = map[string]interface{}{
|
||||
"policies": map[string]string{
|
||||
"policy1.rego": "policy content\n",
|
||||
},
|
||||
}
|
||||
p.Readme = "# Package documentation in markdown format\n"
|
||||
packages, err := NewTrackerSource(i).GetPackagesAvailable()
|
||||
assert.Equal(t, map[string]*hub.Package{
|
||||
pkg.BuildKey(p): p,
|
||||
}, packages)
|
||||
assert.NoError(t, err)
|
||||
sw.AssertExpectations(t)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
# Package documentation in markdown format
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
version: 1.0.0
|
||||
name: pkg1
|
||||
displayName: Package 1
|
||||
createdAt: 2019-06-28T15:23:00Z
|
||||
description: Description
|
||||
logoPath: ../red-dot.png
|
||||
digest: 0123456789
|
||||
license: Apache-2.0
|
||||
homeURL: https://home.url
|
||||
appVersion: 10.0.0
|
||||
containersImages:
|
||||
- image: registry/test/test:latest
|
||||
containsSecurityUpdates: true
|
||||
operator: false
|
||||
deprecated: false
|
||||
prerelease: true
|
||||
keywords:
|
||||
- kw1
|
||||
- kw2
|
||||
links:
|
||||
- name: Link1
|
||||
url: https://link1.url
|
||||
install: Brief install instructions in markdown format
|
||||
changes:
|
||||
- feature 1
|
||||
- fix 1
|
||||
maintainers:
|
||||
- name: Maintainer
|
||||
email: test@email.com
|
||||
provider:
|
||||
name: Provider
|
||||
recommendations:
|
||||
- url: https://artifacthub.io/packages/helm/artifact-hub/artifact-hub
|
||||
|
|
@ -0,0 +1 @@
|
|||
policy content
|
||||
Loading…
Reference in New Issue