Skip to content

Conversation

@grahamplata
Copy link
Member

@grahamplata grahamplata commented Nov 11, 2025

Enables superusers to remove virtual files via sudo in the cli

rill sudo virtual-files --help
Manage virtual files across projects

Usage:
  rill sudo virtual-files [command]

Available Commands:
  list        List all virtual files in a project's virtual repository
  get         Get the content of a specific virtual file
  delete      Delete a specific virtual file

Global Flags:
      --api-token string   Token for authenticating with the cloud API
      --api-url string     Base URL for the cloud API
      --format string      Output format (options: "human", "json", "csv") (default "human")
  -h, --help               Print usage
      --interactive        Prompt for missing required parameters (default true)

Use "rill sudo virtual-files [command] --help" for more information about a command.

List

# rill sudo virtual-files list --org <org-name> dev-project
rill sudo virtual-files list dev-project
Virtual files for project "dev-project" in org "example" (1 total):
Updated On           Path                                             Type   Size (bytes)  Deleted
2025-11-13 10:34:06  alerts/total-requests-value-alert-7617aba9.yaml  alert  1207          No

Get

# rill sudo virtual-files get --org <org-name> dev-project alerts/total-requests-value-alert-7617aba9.yaml
rill sudo virtual-files get dev-project alerts/total-requests-value-alert-7617aba9.yaml

Content of virtual file "alerts/total-requests-value-alert-7617aba9.yaml" in project "dev-project":
Type: alert
annotations:
    admin_managed: true
    admin_nonce: "2025-11-13T10:34:06.268416-05:00"
    admin_owner_user_id: 39d7aaee-ab20-4852-9d95-119aa62e38d8
    web_open_path: /explore/auction_explore
    web_open_state: CgUKA1A3RBgFKghyZXF1ZXN0czgASAFYAWAEahNBbWVyaWNhL0xvc19BbmdlbGVzeAKAAQGYAf///////////wGiAQQaAggI8AEB+AECgAIBigIHZGVmYXVsdJACAboCCHJlcXVlc3Rz
display_name: Total Requests value alert
for:
    user_id: 39d7aaee-ab20-4852-9d95-119aa62e38d8
intervals:
    duration: ""
notify:
    email:
        recipients:
            - graham.plata@rilldata.com
    slack:
        channels: []
        users: []
        webhooks: []
query:
    args_json: '{"metricsView":"auction_metrics","measures":[{"name":"requests"}],"dimensions":[],"having":{"cond":{"op":"OPERATION_AND","exprs":[{"cond":{"op":"OPERATION_GT","exprs":[{"ident":"requests"},{"val":0}]}}]}},"timeRange":{"expression":"P7D","timeZone":"America/Los_Angeles"},"sort":[{"name":"requests","desc":true}]}'
    for:
        user_id: 39d7aaee-ab20-4852-9d95-119aa62e38d8
    name: MetricsViewAggregation
refresh:
    cron: ""
    time_zone: ""
refs:
    - MetricsView/auction_metrics
renotify: true
renotify_after: 0
type: alert
watermark: inherit

Delete

go run ./cli sudo virtual-files delete --org <org-name>  dev-project alerts/total-requests-value-alert-7617aba9.yaml
go run ./cli sudo virtual-files delete dev-project alerts/total-requests-value-alert-7617aba9.yaml
? Delete alert "total-requests-value-alert-7617aba9" in project "dev-project" (org "example")? Yes
Successfully deleted alert "total-requests-value-alert-7617aba9"

Checklist:

  • Covered by tests
  • Ran it and it works as intended
  • Reviewed the diff before requesting a review
  • Checked for unhandled edge cases
  • Linked the issues it closes
  • Checked if the docs need to be updated. If so, create a separate Linear DOCS issue
  • Intend to cherry-pick into the release branch
  • I'm proud of this work!
@grahamplata grahamplata changed the title Gplata/plat 301 Nov 11, 2025
@grahamplata grahamplata marked this pull request as ready for review November 13, 2025 16:46
}

deleteCmd.Flags().BoolVarP(&force, "force", "f", false, "Skip confirmation prompt")
deleteCmd.PersistentFlags().StringVar(&ch.Org, "org", ch.Org, "Organization Name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sudo commands should not use ch.Org – they should accept org as an explicit positional arg.

The reason is that sudo commands are usually done by internal support on behalf of an external user, so you don't want things to get mixed up with the internal user's own org.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh noted. Initially I did do that approach

Comment on lines 58 to 71
data := string(resp.File.Data)
var obj interface{}
if err := yaml.Unmarshal(resp.File.Data, &obj); err != nil {
// fallback to plain text
fmt.Println(data)
return nil
}

yamlData, err := yaml.Marshal(obj)
if err != nil {
fmt.Println(data)
} else {
fmt.Println(string(yamlData))
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just print it outright, why the need for a YAML roundtrip?

I think just printing the virtual files outright would be better so there's no loss of information (like comments or newlines).

},
}

getCmd.PersistentFlags().StringVar(&ch.Org, "org", ch.Org, "Organization Name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as earlier – should be a positional arg

Comment on lines 86 to 88
sort.Slice(files, func(i, j int) bool {
return files[i].Path < files[j].Path
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be confusing if pagination is applied – you may not realize the next page may have values that interleave this sorting. When pagination is used, it should stick to the ordering that's used for the pagination.

}

listCmd.Flags().IntVar(&pageSize, "page-size", 100, "Number of files per page")
listCmd.PersistentFlags().StringVar(&ch.Org, "org", ch.Org, "Organization Name")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as earlier

@begelundmuller begelundmuller merged commit 164bfc0 into main Nov 20, 2025
15 checks passed
@begelundmuller begelundmuller deleted the gplata/plat-301 branch November 20, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants