Skip to content

Commit

Permalink
fix(docs): Provide versioned links to documentation (#13455)
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Clucas <[email protected]>
  • Loading branch information
Joibel committed Sep 20, 2024
1 parent 8f65f02 commit b881cf0
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 12 deletions.
2 changes: 1 addition & 1 deletion cmd/argo/commands/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func NewServerCommand() *cobra.Command {
Use: "server",
Short: "start the Argo Server",
Example: fmt.Sprintf(`
See %s`, help.ArgoServer),
See %s`, help.ArgoServer()),
RunE: func(c *cobra.Command, args []string) error {
cmd.SetLogFormatter(logFormat)
stats.RegisterStackDumper()
Expand Down
2 changes: 1 addition & 1 deletion pkg/apiclient/argo-kube-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (

var (
argoKubeOffloadNodeStatusRepo = sqldb.ExplosiveOffloadNodeStatusRepo
NoArgoServerErr = fmt.Errorf("this is impossible if you are not using the Argo Server, see " + help.CLI)
NoArgoServerErr = fmt.Errorf("this is impossible if you are not using the Argo Server, see " + help.CLI())
)

type argoKubeClient struct {
Expand Down
18 changes: 18 additions & 0 deletions pkg/apis/workflow/v1alpha1/version_types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package v1alpha1

import (
"errors"
"regexp"
)

type Version struct {
Version string `json:"version" protobuf:"bytes,1,opt,name=version"`
BuildDate string `json:"buildDate" protobuf:"bytes,2,opt,name=buildDate"`
Expand All @@ -10,3 +15,16 @@ type Version struct {
Compiler string `json:"compiler" protobuf:"bytes,7,opt,name=compiler"`
Platform string `json:"platform" protobuf:"bytes,8,opt,name=platform"`
}

var verRe = regexp.MustCompile(`^v(\d+)\.(\d+)\.(\d+)`)

// BrokenDown returns the major, minor and release components
// of the version number, or error if this is not a release
// The error path is considered "normal" in a non-release build.
func (v Version) Components() (string, string, string, error) {
matches := verRe.FindStringSubmatch(v.Version)
if matches == nil || matches[1] == "0" {
return ``, ``, ``, errors.New("Not a formal release")
}
return matches[1], matches[2], matches[3], nil
}
40 changes: 31 additions & 9 deletions util/help/topics.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,35 @@
package help

const (
root = "https://argo-workflows.readthedocs.io/en/release-3.5"
ArgoServer = root + "/argo-server/"
CLI = root + "/cli/argo"
import (
"fmt"

WorkflowTemplates = root + "/workflow-templates/"
WorkflowTemplatesReferencingOtherTemplates = WorkflowTemplates + "#referencing-other-workflowtemplates"

Scaling = root + "/scaling/"
ConfigureMaximumRecursionDepth = Scaling + "#maximum-recursion-depth"
"github.com/argoproj/argo-workflows/v3"
)

func root() string {
version := `latest`
if major, minor, _, err := argo.GetVersion().Components(); err == nil {
version = fmt.Sprintf("release-%s.%s", major, minor)
}
return fmt.Sprintf("https://argo-workflows.readthedocs.io/en/%s", version)
}

// ArgoServer returns a URL to the argo-server documentation
func ArgoServer() string {
return root() + "/argo-server/"
}

// CLI returns a URL to the cli documentation
func CLI() string {
return root() + "/cli/argo"
}

// scaling returns a URL to the scaling documentation
func scaling() string {
return root() + "/scaling/"
}

// ConfigureMaximumRecursionDepth returns a URL to the maximum recursion depth documentation
func ConfigureMaximumRecursionDepth() string {
return scaling() + "#maximum-recursion-depth"
}
2 changes: 1 addition & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var (
// ErrTimeout indicates a specific template timed out
ErrTimeout = errors.New(errors.CodeTimeout, "timeout")
// ErrMaxDepthExceeded indicates that the maximum recursion depth was exceeded
ErrMaxDepthExceeded = errors.New(errors.CodeTimeout, fmt.Sprintf("Maximum recursion depth exceeded. See %s", help.ConfigureMaximumRecursionDepth))
ErrMaxDepthExceeded = errors.New(errors.CodeTimeout, fmt.Sprintf("Maximum recursion depth exceeded. See %s", help.ConfigureMaximumRecursionDepth()))
)

// maxOperationTime is the maximum time a workflow operation is allowed to run
Expand Down

0 comments on commit b881cf0

Please sign in to comment.