cmdutil

package
v0.78.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2025 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingProject = fmt.Errorf("no matching project found")

Functions

func AddGroup added in v0.53.0

func AddGroup(parent *cobra.Command, title string, hidden bool, children ...*cobra.Command)

AddGroup adds a group of commands to the parent command.

func ConfirmPrompt

func ConfirmPrompt(msg, help string, def bool) (bool, error)

func EnsureGitignoreHasDotenv added in v0.64.1

func EnsureGitignoreHasDotenv(ctx context.Context, repo drivers.RepoStore) (bool, error)

func HasRillProject added in v0.50.0

func HasRillProject(dir string) bool

func InputPrompt

func InputPrompt(msg, def string) (string, error)

func RepoForProjectPath added in v0.36.0

func RepoForProjectPath(path string) (drivers.RepoStore, string, error)

RepoForProjectPath creates an ad-hoc drivers.RepoStore for a local project file path

func SelectPrompt

func SelectPrompt(msg string, options []string, def string) (string, error)

func SelectPromptIfEmpty

func SelectPromptIfEmpty(input *string, msg string, options []string, def string) error

func SetFlagsByInputPrompts added in v0.26.0

func SetFlagsByInputPrompts(cmd cobra.Command, flags ...string) error

func SetupGitIgnore added in v0.78.0

func SetupGitIgnore(ctx context.Context, repo drivers.RepoStore) error

func StringPromptIfEmpty

func StringPromptIfEmpty(input *string, msg string) error

func UploadRepo added in v0.47.0

func UploadRepo(ctx context.Context, repo drivers.RepoStore, ch *Helper, org, name string) (string, error)

UploadRepo uploads a local project files to rill managed store. Internally it creates an asset object on admin service and returns its id which can be supplied while creating/updating project.

Types

type GitHelper added in v0.64.1

type GitHelper struct {
	// contains filtered or unexported fields
}

GitHelper manages git operations for a project. It also caches the git credentials for the project. Do not use directly, use cmdutil.Helper to get an instance of GitHelper.

func (*GitHelper) GitConfig added in v0.64.1

func (g *GitHelper) GitConfig(ctx context.Context) (*gitutil.Config, error)

func (*GitHelper) PushToManagedRepo added in v0.64.1

func (g *GitHelper) PushToManagedRepo(ctx context.Context) error

func (*GitHelper) PushToNewManagedRepo added in v0.64.1

func (g *GitHelper) PushToNewManagedRepo(ctx context.Context) (*adminv1.CreateManagedGitRepoResponse, error)

type Helper added in v0.38.0

type Helper struct {
	*printer.Printer
	Version            version.Version
	DotRill            dotrill.DotRill
	Interactive        bool
	Org                string
	AdminURLDefault    string
	AdminURLOverride   string
	AdminTokenDefault  string
	AdminTokenOverride string
	// contains filtered or unexported fields
}

func NewHelper added in v0.60.7

func NewHelper(ver version.Version, homeDir string) (*Helper, error)

func (*Helper) AdminToken added in v0.42.0

func (h *Helper) AdminToken() string

func (*Helper) AdminURL added in v0.42.0

func (h *Helper) AdminURL() string

func (*Helper) CheckVersion added in v0.60.7

func (h *Helper) CheckVersion(ctx context.Context) error

func (*Helper) Client added in v0.42.0

func (h *Helper) Client() (*client.Client, error)

func (*Helper) Close added in v0.42.0

func (h *Helper) Close() error

func (*Helper) CommitAndSafePush added in v0.78.0

func (h *Helper) CommitAndSafePush(ctx context.Context, root string, config *gitutil.Config, commitMsg string, author *object.Signature, defaultPushChoice string) error

CommitAndSafePush commits changes and safely pushes them to the remote repository. It fetches the latest remote changes, checks for conflicts, and handles them based on defaultPushChoice:

  • "1": Pull remote changes and merge (fails on conflicts)
  • "2": Overwrite remote changes with local changes using merge with favourLocal=true (not supported for monorepos)
  • "3": Abort the push operation

If h.Interactive is true and there are remote commits, the user will be prompted to choose how to proceed.

func (*Helper) CurrentUserID added in v0.42.0

func (h *Helper) CurrentUserID(ctx context.Context) (string, error)

CurrentUserID fetches the ID of the current user. It caches the result in ~/.rill, along with a hash of the current admin token for cache invalidation in case of login/logout.

func (*Helper) GitHelper added in v0.64.1

func (h *Helper) GitHelper(org, project, localPath string) *GitHelper

func (*Helper) GitSignature added in v0.64.1

func (h *Helper) GitSignature(ctx context.Context, path string) (*object.Signature, error)

func (*Helper) HandleRepoTransfer added in v0.78.0

func (h *Helper) HandleRepoTransfer(path, remote string) error

func (*Helper) InferProjectName added in v0.42.0

func (h *Helper) InferProjectName(ctx context.Context, org, pathToProject string) (string, error)

InferProjectName infers the project name from the given path. If multiple projects are found, it prompts the user to select one.

func (*Helper) InferProjects added in v0.78.0

func (h *Helper) InferProjects(ctx context.Context, org, path string) ([]*adminv1.Project, error)

func (*Helper) IsAuthenticated added in v0.42.0

func (h *Helper) IsAuthenticated() bool

func (*Helper) IsDev added in v0.42.0

func (h *Helper) IsDev() bool

func (*Helper) LatestVersion added in v0.60.7

func (h *Helper) LatestVersion(ctx context.Context) (string, error)

LatestVersion returns the latest available version of Rill (cached for up to 24 hours).

func (*Helper) OpenRuntimeClient added in v0.49.0

func (h *Helper) OpenRuntimeClient(ctx context.Context, org, project string, local bool) (*runtimeclient.Client, string, error)

OpenRuntimeClient opens a client for the production deployment for the given project. If local is true, it connects to the locally running runtime instead of the deployed project's runtime. It returns the runtime client and instance ID for the project.

func (*Helper) ProjectNamesByGitRemote added in v0.78.0

func (h *Helper) ProjectNamesByGitRemote(ctx context.Context, org, remote, subPath string) ([]string, error)

func (*Helper) ReloadAdminConfig added in v0.49.0

func (h *Helper) ReloadAdminConfig() error

ReloadAdminConfig populates the helper's AdminURL, AdminTokenDefault, and Org properties from ~/.rill.

func (*Helper) SetOrg added in v0.64.1

func (h *Helper) SetOrg(org string) error

func (*Helper) Telemetry added in v0.42.0

func (h *Helper) Telemetry(ctx context.Context) *activity.Client

Telemetry returns a client for recording events. Note: It should only be used for parts of the CLI that run on users' local computer because: a) it accesses ~/.rill and adds information about the current user, b) it sends events to the public intake endpoint instead of directly to Kafka.

type PreRunCheck

type PreRunCheck func(cmd *cobra.Command, args []string) error

PreRunCheck is called before a command is run.

func CheckAuth

func CheckAuth(ch *Helper) PreRunCheck

CheckAuth checks if the user is authenticated.

func CheckChain

func CheckChain(chain ...PreRunCheck) PreRunCheck

func CheckOrganization

func CheckOrganization(ch *Helper) PreRunCheck

CheckOrganization checks if the user has an organization set.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL