daytona 0.210.0 → 0.211.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/daytona/config.rb +43 -4
- data/lib/daytona/object_storage.rb +21 -10
- data/lib/daytona/sdk/version.rb +1 -1
- metadata +17 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ae7269e4ef21322f6ac905fd214310b46842edf2bdd45291a1c5eee1e78f6e0
|
|
4
|
+
data.tar.gz: 1cc443a01e292980d47b0092cb435593b8def426a88f334cae20a556e6497130
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8011684fcd9fe5fc324eeafe02cffadb2e71311741d23cb6e08f8a52926dda8ea32feea4c47275bb496ef82112eb6db954367c8fa527c09a4b28e95ef50229cf
|
|
7
|
+
data.tar.gz: 7bb8084c0981db0281b0c6264cc8e20365a38a52012e54bc36a0a4a00aec807c39867f7b39df12eda8d3c8e4546fe646b0b8f4f41f6f4a27644d621acdba9bd7
|
data/lib/daytona/config.rb
CHANGED
|
@@ -80,7 +80,9 @@ module Daytona
|
|
|
80
80
|
|
|
81
81
|
@api_key = api_key || @env_reader.call('DAYTONA_API_KEY')
|
|
82
82
|
@jwt_token = jwt_token || @env_reader.call('DAYTONA_JWT_TOKEN')
|
|
83
|
-
|
|
83
|
+
# Resolved from the process environment only, never from .env / .env.local:
|
|
84
|
+
# the endpoint decides where the credential above is sent.
|
|
85
|
+
@api_url = resolve_api_url(api_url)
|
|
84
86
|
@target = target || @env_reader.call('DAYTONA_TARGET')
|
|
85
87
|
@organization_id = organization_id || @env_reader.call('DAYTONA_ORGANIZATION_ID')
|
|
86
88
|
@otel_enabled = otel_enabled
|
|
@@ -101,14 +103,44 @@ module Daytona
|
|
|
101
103
|
|
|
102
104
|
private
|
|
103
105
|
|
|
104
|
-
#
|
|
105
|
-
#
|
|
106
|
-
|
|
106
|
+
# Resolves the API endpoint without consulting the working directory, then reports a
|
|
107
|
+
# dotenv value that was passed over. Staying silent when the file value matches the
|
|
108
|
+
# endpoint in use keeps the documented .env layout quiet, while a file that would have
|
|
109
|
+
# changed the destination is surfaced.
|
|
110
|
+
def resolve_api_url(api_url)
|
|
111
|
+
resolved = api_url || process_env('DAYTONA_API_URL') || API_URL
|
|
112
|
+
file_value = env_file_vars['DAYTONA_API_URL']
|
|
113
|
+
return resolved if file_value.nil? || file_value.empty? || file_value == resolved
|
|
114
|
+
|
|
115
|
+
warn(
|
|
116
|
+
'`DAYTONA_API_URL` set in a .env or .env.local file was ignored: the Daytona API endpoint ' \
|
|
117
|
+
'is never read from dotenv files, because the working directory is not always authored ' \
|
|
118
|
+
"by you. Using `#{resolved}` instead. To change the endpoint, pass `api_url:` to " \
|
|
119
|
+
'`Daytona::Config.new` or set `DAYTONA_API_URL` in the environment of the process.'
|
|
120
|
+
)
|
|
121
|
+
resolved
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Parses DAYTONA_-prefixed vars out of .env and .env.local in the working directory.
|
|
125
|
+
# These files are not necessarily authored by whoever runs the process, so anything
|
|
126
|
+
# that determines where a credential is sent must not be read from them.
|
|
127
|
+
def env_file_vars
|
|
128
|
+
@env_file_vars ||= parse_dotenv_files
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def parse_dotenv_files
|
|
107
132
|
file_vars = {}
|
|
108
133
|
env_file = File.join(Dir.pwd, '.env')
|
|
109
134
|
file_vars.merge!(daytona_filter(Dotenv.parse(env_file))) if File.exist?(env_file)
|
|
110
135
|
env_local_file = File.join(Dir.pwd, '.env.local')
|
|
111
136
|
file_vars.merge!(daytona_filter(Dotenv.parse(env_local_file))) if File.exist?(env_local_file)
|
|
137
|
+
file_vars
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Returns a lambda that looks up DAYTONA_-prefixed env vars without writing to ENV.
|
|
141
|
+
# Files are parsed once; lookups check runtime env first, then .env.local, then .env.
|
|
142
|
+
def daytona_env_reader
|
|
143
|
+
file_vars = env_file_vars
|
|
112
144
|
|
|
113
145
|
lambda do |name|
|
|
114
146
|
raise ArgumentError, "Variable must start with 'DAYTONA_', got '#{name}'" unless name.start_with?('DAYTONA_')
|
|
@@ -117,6 +149,13 @@ module Daytona
|
|
|
117
149
|
end
|
|
118
150
|
end
|
|
119
151
|
|
|
152
|
+
# Reads a DAYTONA_-prefixed variable from the process environment only.
|
|
153
|
+
def process_env(name)
|
|
154
|
+
raise ArgumentError, "Variable must start with 'DAYTONA_', got '#{name}'" unless name.start_with?('DAYTONA_')
|
|
155
|
+
|
|
156
|
+
ENV.fetch(name, nil)
|
|
157
|
+
end
|
|
158
|
+
|
|
120
159
|
def daytona_filter(env_hash)
|
|
121
160
|
env_hash.select { |k, _| k.start_with?('DAYTONA_') }
|
|
122
161
|
end
|
|
@@ -34,7 +34,8 @@ module Daytona
|
|
|
34
34
|
endpoint: endpoint_url,
|
|
35
35
|
access_key_id: aws_access_key_id,
|
|
36
36
|
secret_access_key: aws_secret_access_key,
|
|
37
|
-
session_token: aws_session_token
|
|
37
|
+
session_token: aws_session_token,
|
|
38
|
+
**CLIENT_OPTIONS
|
|
38
39
|
)
|
|
39
40
|
end
|
|
40
41
|
|
|
@@ -146,17 +147,15 @@ module Daytona
|
|
|
146
147
|
self.class.compute_archive_base_path(source_path) if archive_base_path.nil?
|
|
147
148
|
|
|
148
149
|
temp_file = Tempfile.new(['context', '.tar'])
|
|
150
|
+
archive_path = temp_file.path
|
|
149
151
|
|
|
150
152
|
begin
|
|
151
|
-
system('tar', '-cf',
|
|
152
|
-
|
|
153
|
-
File.open(temp_file.path, 'rb') do |file|
|
|
154
|
-
s3_client.put_object(
|
|
155
|
-
bucket: bucket_name,
|
|
156
|
-
key: s3_key,
|
|
157
|
-
body: file
|
|
158
|
-
)
|
|
153
|
+
unless system('tar', '-cf', archive_path, '-C', File.dirname(source_path), File.basename(source_path))
|
|
154
|
+
raise Sdk::Error, "Failed to create tar archive for #{source_path}"
|
|
159
155
|
end
|
|
156
|
+
|
|
157
|
+
Aws::S3::TransferManager.new(client: s3_client)
|
|
158
|
+
.upload_file(archive_path, bucket: bucket_name, key: s3_key, **UPLOAD_OPTIONS)
|
|
160
159
|
ensure
|
|
161
160
|
temp_file.close
|
|
162
161
|
temp_file.unlink
|
|
@@ -164,6 +163,18 @@ module Daytona
|
|
|
164
163
|
end
|
|
165
164
|
|
|
166
165
|
DEFAULT_BUCKET_NAME = 'daytona-volume-builds'
|
|
167
|
-
|
|
166
|
+
|
|
167
|
+
# multipart_threshold is also the part size floor: S3 rejects any part but the
|
|
168
|
+
# last below 5 MiB, and uploading in parts means a slow or unstable connection
|
|
169
|
+
# only ever has to carry 5 MiB per request instead of the whole context.
|
|
170
|
+
UPLOAD_OPTIONS = {
|
|
171
|
+
multipart_threshold: 5 * 1024 * 1024,
|
|
172
|
+
thread_count: 4,
|
|
173
|
+
content_type: 'application/x-tar'
|
|
174
|
+
}.freeze
|
|
175
|
+
|
|
176
|
+
CLIENT_OPTIONS = { http_open_timeout: 15, http_read_timeout: 120, retry_limit: 3 }.freeze
|
|
177
|
+
|
|
178
|
+
private_constant :DEFAULT_BUCKET_NAME, :UPLOAD_OPTIONS, :CLIENT_OPTIONS
|
|
168
179
|
end
|
|
169
180
|
end
|
data/lib/daytona/sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: daytona
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.211.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daytona Platforms Inc.
|
|
@@ -69,58 +69,64 @@ dependencies:
|
|
|
69
69
|
name: aws-sdk-s3
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
|
-
- - "
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 1.197.0
|
|
75
|
+
- - "<"
|
|
73
76
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: '
|
|
77
|
+
version: '2'
|
|
75
78
|
type: :runtime
|
|
76
79
|
prerelease: false
|
|
77
80
|
version_requirements: !ruby/object:Gem::Requirement
|
|
78
81
|
requirements:
|
|
79
|
-
- - "
|
|
82
|
+
- - ">="
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: 1.197.0
|
|
85
|
+
- - "<"
|
|
80
86
|
- !ruby/object:Gem::Version
|
|
81
|
-
version: '
|
|
87
|
+
version: '2'
|
|
82
88
|
- !ruby/object:Gem::Dependency
|
|
83
89
|
name: daytona_analytics_api_client
|
|
84
90
|
requirement: !ruby/object:Gem::Requirement
|
|
85
91
|
requirements:
|
|
86
92
|
- - '='
|
|
87
93
|
- !ruby/object:Gem::Version
|
|
88
|
-
version: 0.
|
|
94
|
+
version: 0.211.2
|
|
89
95
|
type: :runtime
|
|
90
96
|
prerelease: false
|
|
91
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
92
98
|
requirements:
|
|
93
99
|
- - '='
|
|
94
100
|
- !ruby/object:Gem::Version
|
|
95
|
-
version: 0.
|
|
101
|
+
version: 0.211.2
|
|
96
102
|
- !ruby/object:Gem::Dependency
|
|
97
103
|
name: daytona_api_client
|
|
98
104
|
requirement: !ruby/object:Gem::Requirement
|
|
99
105
|
requirements:
|
|
100
106
|
- - '='
|
|
101
107
|
- !ruby/object:Gem::Version
|
|
102
|
-
version: 0.
|
|
108
|
+
version: 0.211.2
|
|
103
109
|
type: :runtime
|
|
104
110
|
prerelease: false
|
|
105
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
106
112
|
requirements:
|
|
107
113
|
- - '='
|
|
108
114
|
- !ruby/object:Gem::Version
|
|
109
|
-
version: 0.
|
|
115
|
+
version: 0.211.2
|
|
110
116
|
- !ruby/object:Gem::Dependency
|
|
111
117
|
name: daytona_toolbox_api_client
|
|
112
118
|
requirement: !ruby/object:Gem::Requirement
|
|
113
119
|
requirements:
|
|
114
120
|
- - '='
|
|
115
121
|
- !ruby/object:Gem::Version
|
|
116
|
-
version: 0.
|
|
122
|
+
version: 0.211.2
|
|
117
123
|
type: :runtime
|
|
118
124
|
prerelease: false
|
|
119
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
120
126
|
requirements:
|
|
121
127
|
- - '='
|
|
122
128
|
- !ruby/object:Gem::Version
|
|
123
|
-
version: 0.
|
|
129
|
+
version: 0.211.2
|
|
124
130
|
- !ruby/object:Gem::Dependency
|
|
125
131
|
name: dotenv
|
|
126
132
|
requirement: !ruby/object:Gem::Requirement
|