devfile 0.3.0-x86_64-linux → 0.4.0-x86_64-linux

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/devfile +0 -0
  3. data/lib/devfile.rb +29 -7
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c545d301340ea527c06a9068445f1300ed0f6a905346ef6dab536689b0e140b3
4
- data.tar.gz: 4729596acdde380eb269c67d19e56301a09bf4c04ef05b0d60e8515501cfe4e7
3
+ metadata.gz: 460925be1f9888ebb6233df091d3c04342813bc352a57907bc95c77ae6d14498
4
+ data.tar.gz: 36c2382a1461ba41b8fd15ea000734c9329b295b1400dee95b01388536e6e708
5
5
  SHA512:
6
- metadata.gz: 72cde92ab5358ea08eee7ce1b7458c1b149447312d0a39c9bb459cbbbb697ab21dca552233bedf6a08ebb65f51c64b53917df5e7fb99d06d06e14bfec937a3e5
7
- data.tar.gz: af404581c25290afee322659afe09a1075a9aa7cea023f396e44818054c4b93ceb48e5fcf4c41019892339b7e506d7c8b66eefae21c2af4301c5bb7f6423f2d3
6
+ metadata.gz: a9ae4a50ed9a66a52bb376fb60f294c09ee854c90c08bd9827d1116b38ecbc47718be4e03d8fceb18daaec3cd511a4d749eac3000e3803c6cb36830a6803c076
7
+ data.tar.gz: 49e46c23d0614284281596610e165086681d8bafd5820a2b711abedf990d3720310f38e35d6da2a4edd099acb9881285a0ba79ad6be4b4985e54087fdf4bd28e
data/bin/devfile CHANGED
Binary file
data/lib/devfile.rb CHANGED
@@ -5,12 +5,25 @@ require 'open3'
5
5
  # Module that works with the Devfile standard
6
6
  module Devfile
7
7
  class CliError < StandardError; end
8
+ class UnsupportedPlatform < StandardError; end
8
9
 
9
10
  # Set of services to parse a devfile and output k8s manifests
10
11
  class Parser
11
12
  FILE_PATH = File.expand_path('./../bin/devfile', File.dirname(__FILE__))
12
13
  DEVFILE_GEMSPEC = Gem.loaded_specs['devfile']
13
- SYSTEM_PLATFORM = "#{Gem::Platform.local.cpu}-#{Gem::Platform.local.os}"
14
+ RUBY_CPU_TO_GOARCH = {
15
+ 'x86_64' => 'amd64',
16
+ 'aarch64' => 'arm64',
17
+ 'amd64' => 'amd64',
18
+ 'arm64' => 'arm64',
19
+ 'universal' => 'arm64'
20
+ # This exist because if Rosetta is enabled on mac, it means both arm and amd64 bianries
21
+ # can be run so the gem lib sets the CPU as "universal".
22
+ # see: https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment
23
+ }.freeze
24
+ ARCH = RUBY_CPU_TO_GOARCH[Gem::Platform.local.cpu] || Gem::Platform.local.cpu
25
+ SYSTEM_PLATFORM = "#{ARCH}-#{Gem::Platform.local.os}"
26
+ PLATFORM_SPECIFIC_BINARY_PATH = File.expand_path("./../bin/devfile-#{SYSTEM_PLATFORM}", File.dirname(__FILE__))
14
27
 
15
28
  class << self
16
29
  def get_deployment(devfile, name, namespace, labels, annotations, replicas)
@@ -40,19 +53,28 @@ module Devfile
40
53
  private
41
54
 
42
55
  def call(*cmd)
43
- warn_for_ruby_platform
44
-
45
- stdout, stderr, status = Open3.capture3({}, FILE_PATH, *cmd.map(&:to_s))
56
+ file_path = FILE_PATH
57
+ if ruby_platform?
58
+ raise_if_unsupported_system_platform!
59
+ file_path = PLATFORM_SPECIFIC_BINARY_PATH
60
+ end
46
61
 
62
+ stdout, stderr, status = Open3.capture3({}, file_path, *cmd.map(&:to_s))
47
63
  raise(CliError, stderr) unless status.success?
48
64
 
49
65
  stdout
50
66
  end
51
67
 
52
- def warn_for_ruby_platform
53
- return unless DEVFILE_GEMSPEC && DEVFILE_GEMSPEC.platform == 'ruby' && SYSTEM_PLATFORM != 'arm64-darwin'
68
+ def ruby_platform?
69
+ DEVFILE_GEMSPEC && DEVFILE_GEMSPEC.platform == 'ruby'
70
+ end
71
+
72
+ def raise_if_unsupported_system_platform!
73
+ return if %w[amd64-linux amd64-darwin arm64-linux arm64-darwin].include?(SYSTEM_PLATFORM)
54
74
 
55
- warn "devfile-gem only supports os: darwin and architecture: arm64 for 'ruby' platform"
75
+ err_msg = "Unsupported platform:#{SYSTEM_PLATFORM}, devfile-gem only supports " \
76
+ "os: darwin/linux and architectures: amd64/arm64 for 'ruby' platform only"
77
+ raise UnsupportedPlatform, err_msg
56
78
  end
57
79
  end
58
80
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-19 00:00:00.000000000 Z
11
+ date: 2025-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Library used to generate kubernetes manifests from a Devfile.
14
14
  email: