-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5cab02
commit b6ea300
Showing
9 changed files
with
225 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'https://rubygems.org' | ||
|
||
gem "rake", "~> 13.0" | ||
gem "rspec", "~> 3.0" | ||
gem "rubocop", "~> 1.21" | ||
gem 'ffi', '~> 1.9', '>= 1.9.10' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ast (2.4.2) | ||
diff-lcs (1.5.1) | ||
ffi (1.17.0) | ||
ffi (1.17.0-arm64-darwin) | ||
json (2.7.1) | ||
language_server-protocol (3.17.0.3) | ||
parallel (1.25.1) | ||
parser (3.3.3.0) | ||
ast (~> 2.4.1) | ||
racc | ||
racc (1.7.3) | ||
rainbow (3.1.1) | ||
rake (13.2.1) | ||
regexp_parser (2.9.2) | ||
rexml (3.2.8) | ||
rspec (3.13.0) | ||
rspec-core (~> 3.13.0) | ||
rspec-expectations (~> 3.13.0) | ||
rspec-mocks (~> 3.13.0) | ||
rspec-core (3.13.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-expectations (3.13.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-mocks (3.13.1) | ||
diff-lcs (>= 1.2.0, < 2.0) | ||
rspec-support (~> 3.13.0) | ||
rspec-support (3.13.1) | ||
rubocop (1.65.0) | ||
json (~> 2.3) | ||
language_server-protocol (>= 3.17.0) | ||
parallel (~> 1.10) | ||
parser (>= 3.3.0.2) | ||
rainbow (>= 2.2.2, < 4.0) | ||
regexp_parser (>= 2.4, < 3.0) | ||
rexml (>= 3.2.5, < 4.0) | ||
rubocop-ast (>= 1.31.1, < 2.0) | ||
ruby-progressbar (~> 1.7) | ||
unicode-display_width (>= 2.4.0, < 3.0) | ||
rubocop-ast (1.31.3) | ||
parser (>= 3.3.1.0) | ||
ruby-progressbar (1.13.0) | ||
unicode-display_width (2.5.0) | ||
|
||
PLATFORMS | ||
arm64-darwin-23 | ||
ruby | ||
|
||
DEPENDENCIES | ||
ffi (~> 1.9, >= 1.9.10) | ||
rake (~> 13.0) | ||
rspec (~> 3.0) | ||
rubocop (~> 1.21) | ||
|
||
BUNDLED WITH | ||
2.5.16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
require "bundler/gem_tasks" | ||
require "rubocop/rake_task" | ||
require 'rspec/core/rake_task' | ||
|
||
RSpec::Core::RakeTask.new | ||
|
||
RuboCop::RakeTask.new | ||
|
||
task default: :rubocop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative 'lib/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = 'infisical-sdk' | ||
spec.version = InfisicalSDK::VERSION | ||
spec.authors = ['Infisical Inc.'] | ||
spec.email = ['[email protected]'] | ||
|
||
spec.summary = 'Ruby SDK for interacting with the Infisical platform.' | ||
spec.description = 'The official Infisical Ruby SDK.' | ||
spec.homepage = 'https://infisical.com' | ||
spec.required_ruby_version = '>= 2.7' | ||
|
||
spec.metadata['homepage_uri'] = spec.homepage | ||
spec.metadata['source_code_uri'] = 'https://github.com/infisical/sdk' | ||
spec.metadata['changelog_uri'] = 'https://infisical.com/docs/changelog/overview' | ||
|
||
# Specify which files should be added to the gem when it is released. | ||
# The `git ls-files -z` loads the files in the RubyGem that have been added into git. | ||
spec.files = Dir.chdir(__dir__) do | ||
`git ls-files -z`.split("\x0").reject do |f| | ||
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git Gemfile]) | ||
end | ||
end | ||
|
||
spec.files += Dir.glob('lib/linux-x64/**/*') | ||
spec.files += Dir.glob('lib/macos-x64/**/*') | ||
spec.files += Dir.glob('lib/windows-x64/**/*') | ||
spec.files += Dir.glob('lib/macos-arm64/**/*') | ||
spec.files += Dir.glob('lib/schemas.rb') | ||
|
||
spec.bindir = 'exe' | ||
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } | ||
spec.require_paths = ['lib'] | ||
|
||
# Uncomment to register a new dependency of your gem | ||
# spec.add_dependency "example-gem", "~> 1.0" | ||
spec.add_dependency 'dry-struct', '~> 1.6' | ||
spec.add_dependency 'dry-types', '~> 1.7' | ||
spec.add_dependency 'ffi', '~> 1.15' | ||
spec.add_dependency 'json', '~> 2.6' | ||
spec.add_dependency 'rake', '~> 13.0' | ||
spec.add_dependency 'rubocop', '~> 1.21' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'json' | ||
require 'dry-types' | ||
|
||
require_relative 'schemas' | ||
require_relative 'infisical_lib' | ||
require_relative 'infisical_error' | ||
|
||
module InfisicalSDK | ||
class InfisicalSettings | ||
attr_accessor :api_url, :identity_url | ||
|
||
def initialize(api_url, identity_url) | ||
# if api_url.nil? || identity_url.nil? | ||
# raise ArgumentError, "api_url and identity_url cannot be nil" | ||
# end | ||
|
||
@api_url = api_url | ||
@identity_url = identity_url | ||
end | ||
end | ||
|
||
class InfisicalClient | ||
attr_reader :infisical | ||
|
||
def initialize(infisical_settings) | ||
client_settings = ClientSettings.new() | ||
|
||
@infisical = InfisicalLib | ||
@handle = @infisical.init(client_settings.to_dynamic.compact.to_json) | ||
|
||
# @command_runner = CommandRunner.new(@infisical, @handle) | ||
# @project_client = ProjectsClient.new(@command_runner) | ||
# @secrets_client = SecretsClient.new(@command_runner) | ||
end | ||
|
||
def free_mem | ||
@infisical.free_mem(@handle) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
module InfisicalSDK | ||
class InfisicalError < StandardError | ||
def initialize(message = 'Failed to get get response') | ||
super(message) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
require "ffi" | ||
|
||
module InfisicalSDK | ||
module InfisicalLib | ||
extend FFI::Library | ||
|
||
def self.mac_with_intel? | ||
`uname -m`.strip == 'x86_64' | ||
end | ||
|
||
ffi_lib case RUBY_PLATFORM | ||
when /darwin/ | ||
local_file = if mac_with_intel? | ||
File.expand_path('macos-x64/libinfisical_c.dylib', __dir__) | ||
else | ||
File.expand_path('macos-arm64/libinfisical_c.dylib', __dir__) | ||
end | ||
File.exist?(local_file) ? local_file : File.expand_path('../../../../target/debug/libinfisical_c.dylib', __dir__) | ||
when /linux/ | ||
local_file = File.expand_path('linux-x64/libinfisical_c.so', __dir__) | ||
File.exist?(local_file) ? local_file : File.expand_path('../../../../target/debug/libinfisical_c.so', __dir__) | ||
when /mswin|mingw/ | ||
local_file = File.expand_path('windows-x64/infisical_c.dll', __dir__) | ||
File.exist?(local_file) ? local_file : File.expand_path('../../../../target/debug/infisical_c.dll', __dir__) | ||
else | ||
raise "Unsupported platform: #{RUBY_PLATFORM}" | ||
end | ||
|
||
attach_function :init, [:string], :pointer | ||
attach_function :run_command, %i[string pointer], :string | ||
attach_function :free_mem, [:pointer], :void | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module InfisicalSDK | ||
VERSION = '0.2.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters