Skip to content

Commit

Permalink
Merge pull request #157 from ikesyo/update-docs-for-cachemode-and-sci…
Browse files Browse the repository at this point in the history
…pio-s3-storage-v2

Update documentation to follow changes in CacheMode and scipio-s3-storage v2
  • Loading branch information
ikesyo authored Nov 8, 2024
2 parents 578ce98 + 0744d4c commit 43b504b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
7 changes: 3 additions & 4 deletions Sources/scipio/scipio.docc/build-pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,15 @@ Otherwise, on your build script, you can use remote cache storage or your custom
```swift
import ScipioS3Storage

let s3Storage: some CacheStorage = ScipioS3Storage.S3Storage(...)
let s3Storage: some CacheStorage = ScipioS3Storage.S3Storage(config: ...)
let runner = Runner(
mode: .prepareDependencies,
options: .init(
baseBuildOptions: .init(
buildConfiguration: .release,
isSimulatorSupported: true
),
cacheStorage: .custom(myStorage, [.consumer])
cacheMode: .storage(s3Storage, [.consumer])
)
)
```
Expand All @@ -246,11 +246,10 @@ You can also implement your custom cache storage by implementing `CacheStorage`

There are two cache actors `consumer` and `producer`.

You can specify it by a second argument of `.custom` cache storage.
You can specify it by a second argument of `.storage` cache mode.

`consumer` is an actor who can fetch cache from the cache storage.

`producer` is an actor who attempt to save cache to the cache storage.

When build artifacts are built, then it try to save them.

47 changes: 25 additions & 22 deletions Sources/scipio/scipio.docc/using-s3-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,55 @@ Here is a sample implementation.
```swift
import ScipioS3Storage

let config = S3StorageConfig(
authenticationMode: authorized(
accessKeyID: "MY_ACCESS_ID",
secretAccessKey: "MY_SECRET",
region: "ap-northeast-1",
endpoint: awsEndpoint,
shouldPublishObject: true
)
let config = AuthorizedConfiguration(
bucket: "my-bucket",
region: "ap-northeast-1",
shouldPublishObject: true,
accessKeyID: "MY_ACCESS_ID",
secretAccessKey: "MY_SECRET"
)

let s3Storage = S3Storage(config: config)
let s3Storage = S3Storage(config: .authorized(config))
let runner = Runner(
mode: .prepareDependencies,
options: .init(
baseBuildOptions: .init(
buildConfiguration: .release,
isSimulatorSupported: true
),
cacheStorage: .custom(s3Storage, [.consumer])
cacheMode: .storage(s3Storage, [.consumer, .producer])
)
)
```

## Configuration

You can configure cache storage by `S3StorageConfig`.
You can configure cache storage by `S3StorageConfig` and `AuthorizedConfiguration`.

### Authentication Mode
### Configuration Type

You can choose authentication mode from `authorized` and `usePublicURL`.
You can choose configuration type from `authorized` and `publicURL`.

#### authorized

`authorized` mode requires access key ID and secret access key.
`authorized` type is associated with `AuthorizedConfiguration` which requires the followings:

Generally, cache producer (e.g. CI job) should use this mode.
- bucket
- region
- access key ID
- secret access key

#### usePublicURL
Generally, cache producer (e.g. CI job) should use this type.

`usePubicURL` mode doesn't require any credentials.
##### shouldPublishObject

In this mode, cache system will fetch caches by public URLs.
It's useful that developers just using caches should use this mode.
If you set `AuthorizedConfiguration.shouldPublishObject` to `true`, caches will be published with public URLs when producing caches.

You have to set `true` when producing caches when non-authorized consumers use caches.

### shouldPublishObject
#### publicURL

If you set `shouldPublishObject` to `true`, caches will be published with public URLs when producing caches.
`publicURL` type doesn't require any credentials.

You have to set `true` when producing caches when non-authorized consumers use caches.
In this type, cache system will fetch caches by public URLs.
It's useful that developers just using caches should use this mode.

0 comments on commit 43b504b

Please sign in to comment.