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: 4 additions & 4 deletions cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var releaseCmd = &cobra.Command{
Short: "Record a release on the service timeline",
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.`,
Requires the UIGRAPH_TOKEN environment variable, except for a dry run, which reaches no gateway.`,
Args: cobra.NoArgs,
RunE: runRelease,
}
Expand All @@ -46,14 +46,14 @@ func init() {
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")
releaseCmd.Flags().BoolVar(&dryRun, "dry-run", false, "Print the event without sending it to the gateway (no token or gateway URL needed)")
}

func runRelease(cmd *cobra.Command, args []string) error {
ctx := cmd.Context()

token := os.Getenv("UIGRAPH_TOKEN")
if token == "" {
if token == "" && !dryRun {
fmt.Fprintln(os.Stderr, "Error: UIGRAPH_TOKEN environment variable is required")
os.Exit(1)
}
Expand All @@ -71,7 +71,7 @@ func runRelease(cmd *cobra.Command, args []string) error {
if apiURL == "" {
apiURL = os.Getenv("UIGRAPH_GATEWAY_URL")
}
if apiURL == "" {
if apiURL == "" && !dryRun {
fmt.Fprintln(os.Stderr, "Error: gateway URL is required (set --enterprise, --api-url or UIGRAPH_GATEWAY_URL environment variable)")
os.Exit(1)
}
Expand Down
31 changes: 17 additions & 14 deletions cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ 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.`,
This command is designed to run in CI/CD environments and requires UIGRAPH_TOKEN environment variable.
A dry run reaches no gateway, so it needs neither UIGRAPH_TOKEN nor a gateway URL.`,
Args: cobra.NoArgs,
RunE: runSync,
}
Expand All @@ -46,7 +47,7 @@ func init() {
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(&dryRun, "dry-run", false, "Print payloads without sending to gateway (no token or gateway URL needed)")
syncCmd.Flags().BoolVar(&verbose, "verbose", false, "Log every MLflow and gateway request with its duration")
}

Expand Down Expand Up @@ -107,7 +108,7 @@ func runSync(cmd *cobra.Command, args []string) error {

// 1. Authenticate using UIGRAPH_TOKEN
token := os.Getenv("UIGRAPH_TOKEN")
if token == "" {
if token == "" && !dryRun {
fmt.Fprintln(os.Stderr, "Error: UIGRAPH_TOKEN environment variable is required")
os.Exit(1)
}
Expand All @@ -125,7 +126,7 @@ func runSync(cmd *cobra.Command, args []string) error {
if apiURL == "" {
apiURL = os.Getenv("UIGRAPH_GATEWAY_URL")
}
if apiURL == "" {
if apiURL == "" && !dryRun {
fmt.Fprintln(os.Stderr, "Error: gateway URL is required (set --enterprise, --api-url or UIGRAPH_GATEWAY_URL environment variable)")
os.Exit(1)
}
Expand Down Expand Up @@ -909,18 +910,20 @@ func runSync(cmd *cobra.Command, args []string) error {

watermarks := map[string]time.Time{}
deletedProjects := map[string]bool{}
states, err := client.ListMLProjects(ctx, true)
if err != nil {
exitGatewayErrorErr("read last ML sync time", err)
}
for _, state := range states {
if state.DeletedAt != nil {
deletedProjects[state.Name] = true
if !dryRun {
states, err := client.ListMLProjects(ctx, true)
if err != nil {
exitGatewayErrorErr("read last ML sync time", err)
}
if state.SyncedAt == nil {
continue
for _, state := range states {
if state.DeletedAt != nil {
deletedProjects[state.Name] = true
}
if state.SyncedAt == nil {
continue
}
watermarks[state.Name] = *state.SyncedAt
}
watermarks[state.Name] = *state.SyncedAt
}

orderedML := make([]config.MLProjectRef, 0, len(cfg.ML))
Expand Down
Loading