| layout | default |
|---|---|
| title | Chapter 4: File, Git, and Preview Workflows |
| nav_order | 4 |
| parent | Daytona Tutorial |
Welcome to Chapter 4: File, Git, and Preview Workflows. In this part of Daytona Tutorial: Secure Sandbox Infrastructure for AI-Generated Code, you will build an intuitive mental model first, then move into concrete implementation details and practical production tradeoffs.
This chapter maps the day-to-day development workflow inside Daytona sandboxes.
- manage file uploads, downloads, and directory operations
- clone and manipulate repositories in sandbox contexts
- expose running services with preview links
- keep preview and repo workflows reproducible for agents
Treat each sandbox as a disposable but scriptable workspace: hydrate files, clone code, run tasks, expose service previews for review, then persist artifacts through snapshots/volumes if needed.
You can now run a full code-to-preview loop inside Daytona with cleaner automation boundaries.
Next: Chapter 5: MCP Agent Integration and Tooling
The HasErrorReason function in libs/api-client-go/model_workspace.go handles a key part of this chapter's functionality:
}
// HasErrorReason returns a boolean if a field has been set.
func (o *Workspace) HasErrorReason() bool {
if o != nil && !IsNil(o.ErrorReason) {
return true
}
return false
}
// SetErrorReason gets a reference to the given string and assigns it to the ErrorReason field.
func (o *Workspace) SetErrorReason(v string) {
o.ErrorReason = &v
}
// GetRecoverable returns the Recoverable field value if set, zero value otherwise.
func (o *Workspace) GetRecoverable() bool {
if o == nil || IsNil(o.Recoverable) {
var ret bool
return ret
}
return *o.Recoverable
}
// GetRecoverableOk returns a tuple with the Recoverable field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Workspace) GetRecoverableOk() (*bool, bool) {
if o == nil || IsNil(o.Recoverable) {
return nil, false
}
return o.Recoverable, trueThis function is important because it defines how Daytona Tutorial: Secure Sandbox Infrastructure for AI-Generated Code implements the patterns covered in this chapter.
The SetErrorReason function in libs/api-client-go/model_workspace.go handles a key part of this chapter's functionality:
}
// SetErrorReason gets a reference to the given string and assigns it to the ErrorReason field.
func (o *Workspace) SetErrorReason(v string) {
o.ErrorReason = &v
}
// GetRecoverable returns the Recoverable field value if set, zero value otherwise.
func (o *Workspace) GetRecoverable() bool {
if o == nil || IsNil(o.Recoverable) {
var ret bool
return ret
}
return *o.Recoverable
}
// GetRecoverableOk returns a tuple with the Recoverable field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Workspace) GetRecoverableOk() (*bool, bool) {
if o == nil || IsNil(o.Recoverable) {
return nil, false
}
return o.Recoverable, true
}
// HasRecoverable returns a boolean if a field has been set.
func (o *Workspace) HasRecoverable() bool {
if o != nil && !IsNil(o.Recoverable) {
return true
}
return falseThis function is important because it defines how Daytona Tutorial: Secure Sandbox Infrastructure for AI-Generated Code implements the patterns covered in this chapter.
The GetRecoverable function in libs/api-client-go/model_workspace.go handles a key part of this chapter's functionality:
}
// GetRecoverable returns the Recoverable field value if set, zero value otherwise.
func (o *Workspace) GetRecoverable() bool {
if o == nil || IsNil(o.Recoverable) {
var ret bool
return ret
}
return *o.Recoverable
}
// GetRecoverableOk returns a tuple with the Recoverable field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Workspace) GetRecoverableOk() (*bool, bool) {
if o == nil || IsNil(o.Recoverable) {
return nil, false
}
return o.Recoverable, true
}
// HasRecoverable returns a boolean if a field has been set.
func (o *Workspace) HasRecoverable() bool {
if o != nil && !IsNil(o.Recoverable) {
return true
}
return false
}
// SetRecoverable gets a reference to the given bool and assigns it to the Recoverable field.
func (o *Workspace) SetRecoverable(v bool) {
o.Recoverable = &vThis function is important because it defines how Daytona Tutorial: Secure Sandbox Infrastructure for AI-Generated Code implements the patterns covered in this chapter.
The GetRecoverableOk function in libs/api-client-go/model_workspace.go handles a key part of this chapter's functionality:
}
// GetRecoverableOk returns a tuple with the Recoverable field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Workspace) GetRecoverableOk() (*bool, bool) {
if o == nil || IsNil(o.Recoverable) {
return nil, false
}
return o.Recoverable, true
}
// HasRecoverable returns a boolean if a field has been set.
func (o *Workspace) HasRecoverable() bool {
if o != nil && !IsNil(o.Recoverable) {
return true
}
return false
}
// SetRecoverable gets a reference to the given bool and assigns it to the Recoverable field.
func (o *Workspace) SetRecoverable(v bool) {
o.Recoverable = &v
}
// GetBackupState returns the BackupState field value if set, zero value otherwise.
func (o *Workspace) GetBackupState() string {
if o == nil || IsNil(o.BackupState) {
var ret string
return ret
}
return *o.BackupStateThis function is important because it defines how Daytona Tutorial: Secure Sandbox Infrastructure for AI-Generated Code implements the patterns covered in this chapter.
flowchart TD
A[HasErrorReason]
B[SetErrorReason]
C[GetRecoverable]
D[GetRecoverableOk]
E[HasRecoverable]
A --> B
B --> C
C --> D
D --> E