Skip to content

Commit

Permalink
Introduce oci plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
zrdzn committed Nov 7, 2024
1 parent 895af30 commit ba5d87c
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 4 deletions.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.reposilite.packages


interface PackageRepository {


}

This file was deleted.

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023 dzikoysk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.reposilite.packages.oci

import com.reposilite.journalist.Journalist
import com.reposilite.journalist.Logger
import com.reposilite.packages.oci.api.ManifestResponse
import com.reposilite.packages.oci.api.SaveManifestRequest
import com.reposilite.plugin.api.Facade
import com.reposilite.shared.ErrorResponse
import com.reposilite.storage.StorageProvider
import com.reposilite.storage.api.toLocation
import panda.std.Result
import panda.std.asSuccess

class OciFacade(
private val journalist: Journalist,
private val storageProvider: StorageProvider
) : Journalist, Facade {

fun saveManifest(saveManifestRequest: SaveManifestRequest): Result<ManifestResponse, ErrorResponse> {
storageProvider.putFile("oci/manifest.json".toLocation(), saveManifestRequest.toString().toByteArray().inputStream())
return saveManifestRequest.let { ManifestResponse(it.schemaVersion, it.mediaType, it.config, it.layers) }.asSuccess()
}

override fun getLogger(): Logger =
journalist.logger

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2023 dzikoysk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.reposilite.packages.oci.api

data class SaveManifestRequest(
val schemaVersion: Int,
val mediaType: String,
val config: ManifestConfig,
val layers: List<ManifestLayer>,
)

data class ManifestResponse(
val schemaVersion: Int,
val mediaType: String,
val config: ManifestConfig,
val layers: List<ManifestLayer>,
)

data class ManifestConfig(
val mediaType: String,
val size: Int,
val digest: String,
)

data class ManifestLayer(
val mediaType: String,
val size: Int,
val digest: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2023 dzikoysk
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.reposilite.packages.oci.application

import com.reposilite.packages.oci.OciFacade
import com.reposilite.plugin.api.Plugin
import com.reposilite.plugin.api.ReposilitePlugin

@Plugin(
name = "oci",
dependencies = ["failure", "local-configuration", "shared-configuration", "statistics", "authentication", "access-token", "storage"]
)
internal class OciPlugin : ReposilitePlugin() {

override fun initialize(): OciFacade {
val ociFacade = OciFacade(this)

return ociFacade
}

}

0 comments on commit ba5d87c

Please sign in to comment.