-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
always show latest versions of releases on init-* doc pages
- Loading branch information
1 parent
10a7f6a
commit affda5d
Showing
4 changed files
with
125 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package release | ||
|
||
import ( | ||
"fmt" | ||
|
||
bhrelsrepo "github.com/cppforlife/bosh-hub/release/releasesrepo" | ||
) | ||
|
||
type ReleaseRef struct { | ||
Source Source | ||
PrettyName string | ||
DocPage string | ||
} | ||
|
||
type ReleaseRefs []ReleaseRef | ||
|
||
var BOSH = NewReleaseRef("github.com/cloudfoundry/bosh", "BOSH", "") | ||
|
||
var KnownCPIs = ReleaseRefs{ | ||
NewReleaseRef("github.com/cloudfoundry-incubator/bosh-aws-cpi-release", "AWS", "init-aws"), | ||
NewReleaseRef("github.com/cloudfoundry-incubator/bosh-openstack-cpi-release", "OpenStack", "init-openstack"), | ||
NewReleaseRef("github.com/cloudfoundry-incubator/bosh-vsphere-cpi-release", "vSphere", "init-vsphere"), | ||
NewReleaseRef("github.com/cloudfoundry-incubator/bosh-vcloud-cpi-release", "vCloud", "init-vcloud"), | ||
} | ||
|
||
func NewReleaseRef(fullSource, prettyName, docPage string) ReleaseRef { | ||
return ReleaseRef{ | ||
Source: NewSource(bhrelsrepo.Source{Full: fullSource}), | ||
PrettyName: prettyName, | ||
DocPage: docPage, | ||
} | ||
} | ||
|
||
func (c ReleaseRef) DocPagePath() string { return fmt.Sprintf("/docs/%s.html", c.DocPage) } | ||
|
||
func (c ReleaseRef) DocPageLink() string { | ||
return fmt.Sprintf("<a href='%s'>Initializing a BOSH environment on %s</a>", c.DocPagePath(), c.PrettyName) | ||
} | ||
|
||
func (c ReleaseRefs) FindByShortName(name string) (ReleaseRef, bool) { | ||
for _, cpi := range c { | ||
if cpi.Source.ShortName() == name { | ||
return cpi, true | ||
} | ||
} | ||
|
||
return ReleaseRef{}, false | ||
} | ||
|
||
func (c ReleaseRefs) FindByDocPage(docPage string) (ReleaseRef, bool) { | ||
for _, cpi := range c { | ||
if cpi.DocPage == docPage { | ||
return cpi, true | ||
} | ||
} | ||
|
||
return ReleaseRef{}, false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters