Skip to content

Commit

Permalink
Uses v character in github release tag but not in package and updates…
Browse files Browse the repository at this point in the history
… the readme
  • Loading branch information
georgeshanti committed Sep 4, 2023
1 parent b7621b6 commit ee0cb7a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and publish the Java SDK
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*' # 0.0.1 - this syntax of tags is supported
- 'v[0-9]+.[0-9]+.[0-9]+*' # 0.0.1 - this syntax of tags is supported

jobs:
build-and-publish-java-sdk:
Expand Down
70 changes: 18 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,71 +7,33 @@ The CommandK SDK enables users to fetch secrets programmatically, either directl
```gradle
repositories {
maven {
url = uri("https://maven.pkg.github.com/commandk-dev/java-sdk")
credentials {
username = "<GITHUB_USERNAME>"
password = "<GITHUB_ACCESS_TOKEN>"
}
url = uri("https://mvn.cmdk.sh")
}
mavenCentral()
}
dependencies {
implementation 'dev.commandk:java-sdk:v0.0.4'
implementation 'dev.commandk:java-sdk:0.1.0:all'
}
```

### Maven users
In your `settings.xml` file usually located at `~/.m2/settings.xml` add this repository:
```xml
<settings>

<activeProfiles>
<activeProfile>github</activeProfile>
</activeProfiles>

<profiles>
<profile>
<id>github</id>
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/commandk-dev/java-sdk/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

<servers>
<server>
<id>github</id>
<username>username</username>
<password>access_token</password>
</server>
</servers>
</settings>
```
And in your project's `pom.xml` file add:
In your project's `pom.xml` file add the repository and dependency:
```xml
<project>

<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/commandk-dev/java-sdk</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>commandk</id>
<url>https://mvn.cmdk.sh</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>dev.commandk</groupId>
<artifactId>java-sdk</artifactId>
<version>v0.0.4</version>
<version>0.1.0</version>
<classifier>all</classifier>
</dependency>
</dependencies>
Expand All @@ -93,7 +55,7 @@ public class Main {
// The host and access token need to be provided to the client somehow.
// One of the ways the client tries to access it is by looking them up in the
// system properties with the `commandk.host` and `commandk.apiToken` properties.
System.setProperty("commandk.host", "https://api.<org_name>.commandk.dev");
System.setProperty("commandk.host", "https://api.commandk.dev");
System.setProperty("commandk.apiToken", "<api_token>");

// With the default configuration, the client will pick up the credentials from
Expand All @@ -103,7 +65,8 @@ public class Main {
// To fetch secrets of an app we need to specify the app id and the environment id
List<RenderedAppSecret> renderedAppSecrets = commandKClient.getRenderedAppSecrets(
"<app_id>",
"<environment_id>"
"<environment>", // staging, production, sandbox, development,
List.of()
);

// And it's ready to be consumed
Expand Down Expand Up @@ -132,12 +95,14 @@ The default configuration is what the example above uses. It will look up the ho
3.2 At the location provided in the java system property `commandk.configFile`

*In our example the client finds the credentials we set in the java system properties.*
> **NOTE** If you are using an on-prem installation of commandk, your host value would look like this `https://api.<installation-name>.commandk.dev`
> For the value of `host`, refer to the Customer Information Sheet that would have been shared by the CommandK team for your installation. Usually, if you access your dashboard at `app.<name>.commandk.dev`, then the host for your commandk installation would be `https://api.<name>.commandk.dev`
#### Using the configuration file
Instead of setting the credentials directly in the system properties you could also load them up from a file.
1. Create a file at `~/commandk.config`
```
host: https://api.<company>.commandk.dev
host: https://api.commandk.dev
apiToken: <api_token>
```
2. Set the environment variable
Expand All @@ -156,7 +121,7 @@ or like in the example set the system property in the application
// The host and access token need to be provided to the client somehow.
// One of the ways the client tries to access it is by looking them up in the
// system properties with the `commandk.host` and `commandk.apiToken` properties.
System.setProperty("commandk.host", "https://api.<org_name>.commandk.dev");
System.setProperty("commandk.host", "https://api.commandk.dev");
System.setProperty("commandk.apiToken", "<api_token>");

// with this
Expand All @@ -170,7 +135,7 @@ class CustomCredentialsProvider implements CommandKCredentialsProvider {

@Override
public CommandKCredentials resolveCredentials() {
return new CommandKCredentials("https://api.<org_name>.commandk.dev", "<api_token>");
return new CommandKCredentials("https://api.commandk.dev", "<api_token>");
}
}
```
Expand Down Expand Up @@ -200,7 +165,8 @@ public class Main {
// To fetch secrets of an app we need to specify the app id and the environment id
List<RenderedAppSecret> renderedAppSecrets = commandKClient.getRenderedAppSecrets(
"<app_id>",
"<environment_id>"
"<environment>",
List.of()
);

// And it's ready to be consumed
Expand All @@ -214,7 +180,7 @@ class CredentialProviderExample implements CommandKCredentialsProvider {

@Override
public CommandKCredentials resolveCredentials() {
return new CommandKCredentials("https://api.<org_name>.commandk.dev", "<api_token>");
return new CommandKCredentials("https://api.commandk.dev", "<api_token>");
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ publishing {
create<MavenPublication>("main") {
groupId = "dev.commandk"
artifactId = "java-sdk"
version = System.getenv("VERSION_TAG") ?: version
version = System.getenv("VERSION_TAG")?.replace("v", "") ?: version

from(components["java"])
}
Expand Down

0 comments on commit ee0cb7a

Please sign in to comment.