Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ make build
3. Run:

```bash
uigraph sync
uigraph sync --enterprise
```

`--enterprise` points the CLI at the UiGraph gateway (`--enterprise=DEV` for the dev
environment), so there is no need to set
`UIGRAPH_GATEWAY_URL`. Self-hosted instances keep using `--api-url` or `UIGRAPH_GATEWAY_URL`.

Example:

```yaml
Expand All @@ -80,6 +84,8 @@ apis:
uigraph sync
uigraph sync --config ./config/.uigraph.yaml
uigraph sync --dry-run
uigraph sync --enterprise
uigraph sync --enterprise=DEV --dry-run
```

Record a release from a tag-triggered pipeline job. The version, notes and
Expand Down
16 changes: 15 additions & 1 deletion cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var releaseCmd = &cobra.Command{
Long: `Records a single release event at the moment a tag is created, for pipelines that cut releases as a CI/CD step.
Run this from a tag-triggered job; it resolves the version, release notes and commit range from git and posts one timeline event.
Requires the UIGRAPH_TOKEN environment variable.`,
Args: cobra.NoArgs,
RunE: runRelease,
}

Expand All @@ -42,6 +43,9 @@ func init() {
releaseCmd.Flags().StringVar(&releaseTitle, "title", "", "Event title (defaults to the version)")
releaseCmd.Flags().StringVar(&configPath, "config", ".uigraph.yaml", "Path to config file")
releaseCmd.Flags().StringVar(&apiURL, "api-url", "", "Gateway API URL (defaults to UIGRAPH_GATEWAY_URL env var)")
releaseCmd.Flags().StringVar(&enterpriseEnv, "enterprise", "", "Record the release on the UiGraph gateway ("+enterpriseGatewayURL+"); pass --enterprise=DEV for "+enterpriseDevGatewayURL)
releaseCmd.Flags().Lookup("enterprise").NoOptDefVal = "DEFAULT"
releaseCmd.MarkFlagsMutuallyExclusive("api-url", "enterprise")
releaseCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Print the event without sending it to the gateway")
}

Expand All @@ -54,11 +58,21 @@ func runRelease(cmd *cobra.Command, args []string) error {
os.Exit(1)
}

if enterpriseEnv == "DEFAULT" {
apiURL = enterpriseGatewayURL
}
if enterpriseEnv == "DEV" {
apiURL = enterpriseDevGatewayURL
}
if enterpriseEnv != "" && apiURL == "" {
fmt.Fprintf(os.Stderr, "Error: --enterprise accepts no value or =DEV, got %q\n", enterpriseEnv)
os.Exit(1)
}
if apiURL == "" {
apiURL = os.Getenv("UIGRAPH_GATEWAY_URL")
}
if apiURL == "" {
fmt.Fprintln(os.Stderr, "Error: gateway URL is required (set --api-url or UIGRAPH_GATEWAY_URL environment variable)")
fmt.Fprintln(os.Stderr, "Error: gateway URL is required (set --enterprise, --api-url or UIGRAPH_GATEWAY_URL environment variable)")
os.Exit(1)
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import (
"github.com/spf13/cobra"
)

const (
enterpriseGatewayURL = "https://console.uigraph.app/gateway"
enterpriseDevGatewayURL = "https://console.dev.uigraph.app/gateway"
)

var rootCmd = &cobra.Command{
Use: "uigraph",
Short: "UiGraph CLI - Sync services and APIs to UiGraph Gateway",
Expand Down
25 changes: 20 additions & 5 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,28 @@ import (
)

var (
configPath string
apiURL string
dryRun bool
verbose bool
configPath string
apiURL string
enterpriseEnv string
dryRun bool
verbose bool
)

var syncCmd = &cobra.Command{
Use: "sync",
Short: "Sync service and APIs to UiGraph Gateway",
Long: `Reads .uigraph.yaml, captures git metadata, and syncs service, API groups, architecture diagrams, test packs/test cases, and database schemas (when configured) to the gateway.
This command is designed to run in CI/CD environments and requires UIGRAPH_TOKEN environment variable.`,
Args: cobra.NoArgs,
RunE: runSync,
}

func init() {
syncCmd.Flags().StringVar(&configPath, "config", ".uigraph.yaml", "Path to config file")
syncCmd.Flags().StringVar(&apiURL, "api-url", "", "Gateway API URL (defaults to UIGRAPH_GATEWAY_URL env var)")
syncCmd.Flags().StringVar(&enterpriseEnv, "enterprise", "", "Sync to the UiGraph gateway ("+enterpriseGatewayURL+"); pass --enterprise=DEV for "+enterpriseDevGatewayURL)
syncCmd.Flags().Lookup("enterprise").NoOptDefVal = "DEFAULT"
syncCmd.MarkFlagsMutuallyExclusive("api-url", "enterprise")
syncCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Print payloads without sending to gateway")
syncCmd.Flags().BoolVar(&verbose, "verbose", false, "Log every MLflow and gateway request with its duration")
}
Expand Down Expand Up @@ -107,11 +112,21 @@ func runSync(cmd *cobra.Command, args []string) error {
os.Exit(1)
}

if enterpriseEnv == "DEFAULT" {
apiURL = enterpriseGatewayURL
}
if enterpriseEnv == "DEV" {
apiURL = enterpriseDevGatewayURL
}
if enterpriseEnv != "" && apiURL == "" {
fmt.Fprintf(os.Stderr, "Error: --enterprise accepts no value or =DEV, got %q\n", enterpriseEnv)
os.Exit(1)
}
if apiURL == "" {
apiURL = os.Getenv("UIGRAPH_GATEWAY_URL")
}
if apiURL == "" {
fmt.Fprintln(os.Stderr, "Error: gateway URL is required (set --api-url or UIGRAPH_GATEWAY_URL environment variable)")
fmt.Fprintln(os.Stderr, "Error: gateway URL is required (set --enterprise, --api-url or UIGRAPH_GATEWAY_URL environment variable)")
os.Exit(1)
}

Expand Down
Loading