Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new option should_infer_types to optionally not infer the type of the secret #72

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/arkana.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ def self.run(arguments)
salt: salt,
current_flavor: config.current_flavor,
environments: config.environments,
inference_secret_type: config.inference_secret_types,
)
global_secrets = Encoder.encode!(
keys: config.global_secrets,
salt: salt,
current_flavor: config.current_flavor,
environments: config.environments,
inference_secret_type: config.inference_secret_types,
)
rescue StandardError => e
# TODO: Improve this by creating an Env/Debug helper
Expand Down
4 changes: 2 additions & 2 deletions lib/arkana/encoder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module Encoder
# Fetches values of each key from ENV, and encodes them using the given salt.
#
# @return [Secret[]] an array of Secret objects, which contain their keys and encoded values.
def self.encode!(keys:, salt:, current_flavor:, environments:)
def self.encode!(keys:, salt:, current_flavor:, environments:, inference_secret_type:)
keys.map do |key|
secret = find_secret!(key: key, current_flavor: current_flavor)
encoded_value = encode(secret, salt.raw)
secret_type = Type.new(string_value: secret)
secret_type = inference_secret_type ? Type.new(string_value: secret) : Type.default_string
protocol_key = protocol_key(key: key, environments: environments)
Secret.new(key: key, protocol_key: protocol_key, encoded_value: encoded_value, type: secret_type)
end
Expand Down
2 changes: 2 additions & 0 deletions lib/arkana/models/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Config
attr_reader :kotlin_jvm_toolchain_version
# @returns [boolean]
attr_reader :is_kotlin_multiplatform_module
# @returns [boolean]
attr_reader :inference_secret_types
cepages marked this conversation as resolved.
Show resolved Hide resolved

# @returns [string]
attr_accessor :current_flavor
Expand Down
4 changes: 4 additions & 0 deletions lib/arkana/models/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ def self.new(string_value:)
STRING
end
end

def self.default_string
cepages marked this conversation as resolved.
Show resolved Hide resolved
return STRING
end
end
2 changes: 1 addition & 1 deletion spec/encoder_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe Encoder do
subject { described_class.encode!(keys: keys, salt: salt, current_flavor: current_flavor, environments: environments) }
subject { described_class.encode!(keys: keys, salt: salt, current_flavor: current_flavor, environments: environments, inference_secret_type: inference_secret_type) }

let(:salt) { SaltGenerator.generate }
let(:environments) { [] }
Expand Down
1 change: 1 addition & 0 deletions template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ kotlin_sources_path: 'java' # Optional. The path for the generated Kotlin classe
should_generate_gradle_build_file: true # Optional. Whether a build.gradle file should be generated, when running the Kotlin generator. One of: true, false. Defaults to true.
is_kotlin_multiplatform_module: true # Optional. Whether the generated Kotlin module is a multiplatform module. One of: true, false. Defaults to false.
kotlin_jvm_toolchain_version: 11 # Optional. The kotlin JVM toolchain JDK version to be used in the generated build.gradle file. Defaults to 11.
inference_value_types: true # Optional. Whether if arkana inferences the types of the values. If false the type will always be String. Defaults to true.
cepages marked this conversation as resolved.
Show resolved Hide resolved
environments: # Optional. List of environments that will be used to generate secret keys when you have keys that are different between environments (e.g. debug/staging/prod). Defaults to empty.
- Debug
- Release
Expand Down
Loading