Code structure
The datumctl codebase is organized primarily within the internal directory, following common Go practices.
Key directories
Section titled “Key directories”internal/cmd/: Contains the definitions for all CLI commands, structured using the Cobra library.internal/cmd/auth/: Commands related to authentication (login,logout,list,get-token,update-kubeconfig).internal/cmd/organizations/: Commands for managing organization resources (currentlylist).internal/cmd/root.go: Defines the rootdatumctlcommand and ties subcommands together.
internal/authutil/: Provides shared utilities and types specifically for authentication handling.credentials.go: Defines theStoredCredentialsstruct, functions for interacting with the keyring (GetActiveCredentials,GetStoredCredentials), OIDC token source creation (GetTokenSource), and hostname derivation (DeriveAPIHostname). Constants for keyring service/keys are also defined here.
internal/keyring/: A simple wrapper around thego-keyringlibrary, primarily adding timeouts to keyring operations.internal/output/: Contains helpers for formatting CLI output (e.g.,CLIPrintfor tables, JSON, YAML).internal/resourcemanager/: (Example) Likely contains clients and logic for interacting with specific Datum Cloud API resource types (like Organizations).
Main entrypoint
Section titled “Main entrypoint”main.go: The main application entrypoint. It typically sets up and executes the root Cobra command defined ininternal/cmd/root.go.
Dependencies
Section titled “Dependencies”Key external dependencies include:
github.com/spf13/cobra: CLI framework.golang.org/x/oauth2: OAuth2 client library.github.com/coreos/go-oidc/v3/oidc: OpenID Connect client library.github.com/zalando/go-keyring: Secure credential storage.k8s.io/client-go/tools/clientcmd: Kubernetes client configuration API (forupdate-kubeconfig).github.com/pkg/browser: For opening the web browser during login.