-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate the repository to Open Feature (#2)
* migrate the repository to Open Feature Signed-off-by: Nicky Bondarenko <[email protected]> --------- Signed-off-by: Nicky Bondarenko <[email protected]>
- Loading branch information
1 parent
74c467d
commit c9eca67
Showing
59 changed files
with
3,293 additions
and
0 deletions.
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,133 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = false | ||
max_line_length = 100 | ||
tab_width = 4 | ||
ij_continuation_indent_size = 8 | ||
ij_formatter_off_tag = @formatter:off | ||
ij_formatter_on_tag = @formatter:on | ||
ij_formatter_tags_enabled = false | ||
ij_smart_tabs = false | ||
ij_visual_guides = none | ||
ij_wrap_on_typing = false | ||
|
||
[{*.kt,*.kts}] | ||
ij_kotlin_align_in_columns_case_branch = false | ||
ij_kotlin_align_multiline_binary_operation = false | ||
ij_kotlin_align_multiline_extends_list = false | ||
ij_kotlin_align_multiline_method_parentheses = false | ||
ij_kotlin_align_multiline_parameters = true | ||
ij_kotlin_align_multiline_parameters_in_calls = false | ||
ij_kotlin_allow_trailing_comma = false | ||
ij_kotlin_allow_trailing_comma_on_call_site = false | ||
ij_kotlin_assignment_wrap = normal | ||
ij_kotlin_blank_lines_after_class_header = 0 | ||
ij_kotlin_blank_lines_around_block_when_branches = 0 | ||
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1 | ||
ij_kotlin_block_comment_add_space = false | ||
ij_kotlin_block_comment_at_first_column = true | ||
ij_kotlin_call_parameters_new_line_after_left_paren = true | ||
ij_kotlin_call_parameters_right_paren_on_new_line = true | ||
ij_kotlin_call_parameters_wrap = on_every_item | ||
ij_kotlin_catch_on_new_line = false | ||
ij_kotlin_class_annotation_wrap = split_into_lines | ||
ij_kotlin_code_style_defaults = KOTLIN_OFFICIAL | ||
ij_kotlin_continuation_indent_for_chained_calls = false | ||
ij_kotlin_continuation_indent_for_expression_bodies = false | ||
ij_kotlin_continuation_indent_in_argument_lists = false | ||
ij_kotlin_continuation_indent_in_elvis = false | ||
ij_kotlin_continuation_indent_in_if_conditions = false | ||
ij_kotlin_continuation_indent_in_parameter_lists = false | ||
ij_kotlin_continuation_indent_in_supertype_lists = false | ||
ij_kotlin_else_on_new_line = false | ||
ij_kotlin_enum_constants_wrap = off | ||
ij_kotlin_extends_list_wrap = normal | ||
ij_kotlin_field_annotation_wrap = split_into_lines | ||
ij_kotlin_finally_on_new_line = false | ||
ij_kotlin_if_rparen_on_new_line = true | ||
ij_kotlin_import_nested_classes = false | ||
ij_kotlin_imports_layout = *,java.**,javax.**,kotlin.**,^ | ||
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true | ||
ij_kotlin_keep_blank_lines_before_right_brace = 2 | ||
ij_kotlin_keep_blank_lines_in_code = 2 | ||
ij_kotlin_keep_blank_lines_in_declarations = 2 | ||
ij_kotlin_keep_first_column_comment = true | ||
ij_kotlin_keep_indents_on_empty_lines = false | ||
ij_kotlin_keep_line_breaks = true | ||
ij_kotlin_lbrace_on_next_line = false | ||
ij_kotlin_line_comment_add_space = false | ||
ij_kotlin_line_comment_add_space_on_reformat = false | ||
ij_kotlin_line_comment_at_first_column = true | ||
ij_kotlin_method_annotation_wrap = split_into_lines | ||
ij_kotlin_method_call_chain_wrap = normal | ||
ij_kotlin_method_parameters_new_line_after_left_paren = true | ||
ij_kotlin_method_parameters_right_paren_on_new_line = true | ||
ij_kotlin_method_parameters_wrap = on_every_item | ||
ij_kotlin_name_count_to_use_star_import = 5 | ||
ij_kotlin_name_count_to_use_star_import_for_members = 3 | ||
ij_kotlin_packages_to_use_import_on_demand = unset | ||
ij_kotlin_parameter_annotation_wrap = off | ||
ij_kotlin_space_after_comma = true | ||
ij_kotlin_space_after_extend_colon = true | ||
ij_kotlin_space_after_type_colon = true | ||
ij_kotlin_space_before_catch_parentheses = true | ||
ij_kotlin_space_before_comma = false | ||
ij_kotlin_space_before_extend_colon = true | ||
ij_kotlin_space_before_for_parentheses = true | ||
ij_kotlin_space_before_if_parentheses = true | ||
ij_kotlin_space_before_lambda_arrow = true | ||
ij_kotlin_space_before_type_colon = false | ||
ij_kotlin_space_before_when_parentheses = true | ||
ij_kotlin_space_before_while_parentheses = true | ||
ij_kotlin_spaces_around_additive_operators = true | ||
ij_kotlin_spaces_around_assignment_operators = true | ||
ij_kotlin_spaces_around_equality_operators = true | ||
ij_kotlin_spaces_around_function_type_arrow = true | ||
ij_kotlin_spaces_around_logical_operators = true | ||
ij_kotlin_spaces_around_multiplicative_operators = true | ||
ij_kotlin_spaces_around_range = false | ||
ij_kotlin_spaces_around_relational_operators = true | ||
ij_kotlin_spaces_around_unary_operator = false | ||
ij_kotlin_spaces_around_when_arrow = true | ||
ij_kotlin_use_custom_formatting_for_modifiers = true | ||
ij_kotlin_variable_annotation_wrap = off | ||
ij_kotlin_while_on_new_line = false | ||
ij_kotlin_wrap_elvis_expressions = 1 | ||
ij_kotlin_wrap_expression_body_functions = 1 | ||
ij_kotlin_wrap_first_method_in_call_chain = false | ||
|
||
|
||
# Copied from internal settings | ||
[*.kt] | ||
continuation_indent_size = 4 | ||
ktlint_standard_annotation = disabled # Annotations don't have to be on separate lines | ||
ktlint_standard_annotation-spacing = disabled # It is ok with a comment between annotation and declaration | ||
ktlint_standard_argument-list-wrapping = disabled # It is ok to have multiple args on one line | ||
ktlint_standard_spacing-between-declarations-with-annotations = disabled # No need for empty line between these | ||
ktlint_standard_spacing-between-declarations-with-comments = disabled # No need for empty line between these | ||
ktlint_standard_trailing-comma-on-call-site = disabled # Trailing commas are ok | ||
ktlint_standard_trailing-comma-on-declaration-site = disabled # Trailing commas are ok | ||
|
||
# There is a bug in ktlint making multiline typealias indent in the wrong way: | ||
# https://github.com/pinterest/ktlint/issues/1788 - enable this one this is fixed. | ||
ktlint_standard_indent = disabled | ||
|
||
ktlint_experimental_class-naming = enabled | ||
ktlint_experimental_fun-keyword-spacing = enabled | ||
ktlint_experimental_function-type-reference-spacing = enabled | ||
ktlint_experimental_nullable-type-spacing = enabled | ||
ktlint_experimental_spacing-between-function-name-and-opening-parenthesis = enabled | ||
ktlint_experimental_unnecessary-parentheses-before-trailing-lambda = enabled | ||
|
||
# Setting max line for Kotlin files, exactly as Detekt config (120 by default) to insure IDE and ktlint formatter | ||
# format the code that is valid for Detekt, avoiding mismatch. | ||
max_line_length=120 | ||
|
||
# Ignore max line for kotlin test files, the same as Detekt. | ||
[**/{test,androidTest}/**/*.kt] | ||
max_line_length=off |
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,3 @@ | ||
# Code of Conduct | ||
|
||
Please refer to the [OpenFeature community page](https://openfeature.dev/community/#code-of-conduct) for more information on Code of Conduct. |
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,18 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
Tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Run checks | ||
run: ./gradlew check --no-daemon --stacktrace |
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 @@ | ||
/build/ |
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,17 @@ | ||
## Getting Started | ||
|
||
OpenFeature is not keen on vendor-specific stuff in this library, but if there are changes that need to happen in the spec to enable vendor-specific stuff in user code or other extension points, check out [the spec](https://github.com/open-feature/spec). | ||
|
||
## Formatting | ||
|
||
This repo uses [ktlint](https://github.com/JLLeitschuh/ktlint-gradle) for formatting. | ||
|
||
Please consider adding a pre-commit hook for formatting using | ||
|
||
``` | ||
./gradlew addKtlintCheckGitPreCommitHook | ||
``` | ||
Manual formatting is done by invoking | ||
``` | ||
./gradlew ktlintFormat | ||
``` |
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,10 @@ | ||
# Owners | ||
|
||
- See [CONTRIBUTING.md](CONTRIBUTING.md) for general contribution guidelines. | ||
|
||
## Core Developers | ||
|
||
- Fabrizio Demaria (fabriziodemaria, Spotify) | ||
- Nicklas Lundin (nicklasl, Spotify) | ||
- Vahid Torkaman (vahidlazio, Spotify) | ||
- Nicky Bondarenko (nickybondarenko, Spotify) |
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 @@ | ||
/build |
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,74 @@ | ||
// ktlint-disable max-line-length | ||
plugins { | ||
id("com.android.library") | ||
id("org.jetbrains.kotlin.android") | ||
id("maven-publish") | ||
id("org.jlleitschuh.gradle.ktlint") | ||
kotlin("plugin.serialization") version "1.8.10" | ||
} | ||
|
||
android { | ||
namespace = "dev.openfeature.sdk" | ||
compileSdk = 33 | ||
|
||
defaultConfig { | ||
minSdk = 21 | ||
version = "0.0.1" | ||
|
||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
|
||
buildTypes { | ||
getByName("release") { | ||
isMinifyEnabled = false | ||
proguardFiles( | ||
getDefaultProguardFile("proguard-android-optimize.txt"), | ||
"proguard-rules.pro" | ||
) | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_11.toString() | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.2") | ||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1") | ||
testImplementation("junit:junit:4.13.2") | ||
testImplementation("org.mockito.kotlin:mockito-kotlin:5.0.0") | ||
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.2") | ||
} | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
register<MavenPublication>("release") { | ||
groupId = "dev.openfeature" | ||
artifactId = "kotlin-sdk" | ||
version = "0.0.1-SNAPSHOT" | ||
|
||
from(components["release"]) | ||
artifact(androidSourcesJar.get()) | ||
|
||
pom { | ||
name.set("OpenfeatureSDK") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
val androidSourcesJar by tasks.registering(Jar::class) { | ||
archiveClassifier.set("sources") | ||
from(android.sourceSets.getByName("main").java.srcDirs) | ||
} | ||
|
||
// Assembling should be performed before publishing package | ||
tasks.named("publish") { | ||
dependsOn("assemble") | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle.kts. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
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,3 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest> | ||
</manifest> |
11 changes: 11 additions & 0 deletions
11
OpenFeature/src/main/java/dev/openfeature/sdk/BaseEvaluation.kt
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 @@ | ||
package dev.openfeature.sdk | ||
|
||
import dev.openfeature.sdk.exceptions.ErrorCode | ||
|
||
interface BaseEvaluation<T> { | ||
val value: T | ||
val variant: String? | ||
val reason: String? | ||
val errorCode: ErrorCode? | ||
val errorMessage: String? | ||
} |
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 @@ | ||
package dev.openfeature.sdk | ||
|
||
interface Client : Features { | ||
val metadata: ClientMetadata | ||
val hooks: List<Hook<*>> | ||
|
||
fun addHooks(hooks: List<Hook<*>>) | ||
} |
5 changes: 5 additions & 0 deletions
5
OpenFeature/src/main/java/dev/openfeature/sdk/ClientMetadata.kt
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 @@ | ||
package dev.openfeature.sdk | ||
|
||
interface ClientMetadata { | ||
val name: String? | ||
} |
10 changes: 10 additions & 0 deletions
10
OpenFeature/src/main/java/dev/openfeature/sdk/EvaluationContext.kt
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,10 @@ | ||
package dev.openfeature.sdk | ||
|
||
interface EvaluationContext : Structure { | ||
fun getTargetingKey(): String | ||
fun setTargetingKey(targetingKey: String) | ||
|
||
// Make sure these are implemented for correct object comparisons | ||
override fun hashCode(): Int | ||
override fun equals(other: Any?): Boolean | ||
} |
26 changes: 26 additions & 0 deletions
26
OpenFeature/src/main/java/dev/openfeature/sdk/FeatureProvider.kt
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,26 @@ | ||
package dev.openfeature.sdk | ||
|
||
interface FeatureProvider { | ||
val hooks: List<Hook<*>> | ||
val metadata: ProviderMetadata | ||
|
||
// Called by OpenFeatureAPI whenever the new Provider is registered | ||
fun initialize(initialContext: EvaluationContext?) | ||
|
||
// called when the lifecycle of the OpenFeatureClient is over | ||
// to release resources/threads. | ||
fun shutdown() | ||
|
||
// Called by OpenFeatureAPI whenever a new EvaluationContext is set by the application | ||
fun onContextSet(oldContext: EvaluationContext?, newContext: EvaluationContext) | ||
fun getBooleanEvaluation( | ||
key: String, | ||
defaultValue: Boolean, | ||
context: EvaluationContext? | ||
): ProviderEvaluation<Boolean> | ||
|
||
fun getStringEvaluation(key: String, defaultValue: String, context: EvaluationContext?): ProviderEvaluation<String> | ||
fun getIntegerEvaluation(key: String, defaultValue: Int, context: EvaluationContext?): ProviderEvaluation<Int> | ||
fun getDoubleEvaluation(key: String, defaultValue: Double, context: EvaluationContext?): ProviderEvaluation<Double> | ||
fun getObjectEvaluation(key: String, defaultValue: Value, context: EvaluationContext?): ProviderEvaluation<Value> | ||
} |
Oops, something went wrong.