-
Notifications
You must be signed in to change notification settings - Fork 198
feat: add artifactory plugin #898
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
Merged
IronCore864
merged 3 commits into
devstream-io:main
from
steinliber:feat-plugin-artifactory
Jul 26, 2022
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,39 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "github.com/devstream-io/devstream/internal/pkg/plugin/artifactory" | ||
| "github.com/devstream-io/devstream/pkg/util/log" | ||
| ) | ||
|
|
||
| // NAME is the name of this DevStream plugin. | ||
| const NAME = "artifactory" | ||
|
|
||
| // Plugin is the type used by DevStream core. It's a string. | ||
| type Plugin string | ||
|
|
||
| // Create implements the create of artifactory. | ||
| func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) { | ||
| return artifactory.Create(options) | ||
| } | ||
|
|
||
| // Update implements the update of artifactory. | ||
| func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) { | ||
| return artifactory.Update(options) | ||
| } | ||
|
|
||
| // Delete implements the delete of artifactory. | ||
| func (p Plugin) Delete(options map[string]interface{}) (bool, error) { | ||
| return artifactory.Delete(options) | ||
| } | ||
|
|
||
| // Read implements the read of artifactory. | ||
| func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) { | ||
| return artifactory.Read(options) | ||
| } | ||
|
|
||
| // DevStreamPlugin is the exported variable used by the DevStream core. | ||
| var DevStreamPlugin Plugin | ||
|
|
||
| func main() { | ||
| log.Infof("%T: %s is a plugin for DevStream. Use it with DevStream.\n", DevStreamPlugin, NAME) | ||
| } |
This file contains hidden or 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,46 @@ | ||
| # artifactory Plugin | ||
|
|
||
| This plugin installs [artifactory](https://jfrog.com/artifactory/) in an existing Kubernetes cluster using the Helm chart. | ||
|
|
||
| ## Usage | ||
|
|
||
| ### Test/Local Dev Environment | ||
|
|
||
| If you want to **test the plugin locally**, The following `values_yaml` configuration can be used | ||
|
|
||
| ```yaml | ||
| values_yaml: | | ||
| artifactory: | ||
| service: | ||
| type: NodePort | ||
| nodePort: 30002 | ||
| nginx: | ||
| enabled: false | ||
| ``` | ||
|
|
||
| In this configuration | ||
| - Postgresql dependencies are automatically created. | ||
| - local disks on machines in the cluster are defaulted used for data mounting. | ||
| - Using `nodePort` to expose service, You can access `artifactory` by domain `http://{{k8s node IP}}:30002`. The default account name and password are admin/password (please replace the default account password in the production environment). | ||
|
|
||
| ### Production Environment | ||
|
|
||
| #### External Storage | ||
|
|
||
| - PostgreSQL: Set the `database.url` to Postgresql's address. More info can be found in [Config](https://www.jfrog.com/confluence/display/JFROG/Configuring+the+Database). | ||
|
|
||
| #### Disk Storage | ||
|
|
||
| You can set `customVolumes` and `customVolumeMounts` for this service. More info can be found in [Config](https://www.jfrog.com/confluence/display/JFROG/Configuring+the+Filestore). | ||
|
|
||
| #### Network Config | ||
|
|
||
| This plugin support`Ingress`, `ClusterIP`, `NodePort` and `LoadBalancer` , You can give choice to your needs. | ||
|
|
||
| ### Config | ||
|
|
||
| ```yaml | ||
| --8<-- "artifactory.yaml" | ||
| ``` | ||
|
|
||
| Currently, except for `values_yaml`, all the parameters in the example above are mandatory. | ||
This file contains hidden or 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,45 @@ | ||
| # artifactory 插件 | ||
|
|
||
| 这个插件使用 helm 在已有的 k8s 集群上安装 [artifactory](https://jfrog.com/artifactory/)。 | ||
|
|
||
| ## 使用方法 | ||
|
|
||
| ### 测试环境 | ||
|
|
||
| 如果你想在**本地测试插件**, 可以使用如下 `values_yaml` 配置。 | ||
|
|
||
| ```yaml | ||
| values_yaml: | | ||
| artifactory: | ||
| service: | ||
| type: NodePort | ||
| nodePort: 30002 | ||
| nginx: | ||
| enabled: false | ||
| ``` | ||
|
|
||
| 在该配置下 | ||
| - helm 会自动创建依赖的 Postgresql; | ||
| - 数据挂载的磁盘默认会使用集群上机器的本地磁盘; | ||
| - 通过 `NodePort` 对外暴露服务,可使用 `http://{{k8s 节点ip}}:30002` 域名来访问,默认账号名密码为 admin/password (生产环境请替换默认账号密码)。 | ||
|
|
||
| ### 生产环境 | ||
|
|
||
| #### 外部存储 | ||
|
|
||
| - PostgreSQL:设置 `database.url` 来设置数据库地址,具体配置可参考 [Config](https://www.jfrog.com/confluence/display/JFROG/Configuring+the+Database) 中的选项。 | ||
|
|
||
| #### 磁盘存储 | ||
|
|
||
| 可以设置 `customVolumes` 和 `customVolumeMounts` 来配置挂载磁盘,具体配置可参考 [Config](https://www.jfrog.com/confluence/display/JFROG/Configuring+the+Filestore)。 | ||
|
|
||
| #### 网络层配置 | ||
| 该插件支持 `Ingress`, `ClusterIP`, `NodePort`, `LoadBalancer` 对外暴露的模式,可以基于需求进行选择。 | ||
|
|
||
| ### 配置 | ||
|
|
||
| ```yaml | ||
| --8<-- "artifactory.yaml" | ||
| ``` | ||
|
|
||
| 目前除了 `values_yaml` 字段,所有示例参数均为必填项。 |
This file contains hidden or 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 artifactory | ||
|
|
||
| var defaultDeploymentList = []string{ | ||
| "artifactory", | ||
| } |
This file contains hidden or 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,32 @@ | ||
| package artifactory | ||
|
|
||
| import ( | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller" | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" | ||
| "github.com/devstream-io/devstream/pkg/util/log" | ||
| ) | ||
|
|
||
| func Create(options map[string]interface{}) (map[string]interface{}, error) { | ||
| // 1. config install operations | ||
| runner := &plugininstaller.Runner{ | ||
| PreExecuteOperations: []plugininstaller.MutableOperation{ | ||
| helm.Validate, | ||
| }, | ||
| ExecuteOperations: []plugininstaller.BaseOperation{ | ||
| helm.DealWithNsWhenInstall, | ||
| helm.InstallOrUpdate, | ||
| }, | ||
| TermateOperations: []plugininstaller.BaseOperation{ | ||
| helm.DealWithNsWhenInterruption, | ||
| }, | ||
| GetStatusOperation: helm.GetPluginStaticStateWrapper(defaultDeploymentList), | ||
aFlyBird0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| // 2. execute installer get status and error | ||
| status, err := runner.Execute(plugininstaller.RawOptions(options)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| log.Debugf("Return map: %v", status) | ||
| return status, nil | ||
| } | ||
This file contains hidden or 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 artifactory | ||
|
|
||
| import ( | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller" | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" | ||
| ) | ||
|
|
||
| func Delete(options map[string]interface{}) (bool, error) { | ||
| // 1. config delete operations | ||
| runner := &plugininstaller.Runner{ | ||
| PreExecuteOperations: []plugininstaller.MutableOperation{ | ||
| helm.Validate, | ||
| }, | ||
| ExecuteOperations: []plugininstaller.BaseOperation{ | ||
| helm.Delete, | ||
| helm.DealWithNsWhenInterruption, | ||
| }, | ||
| } | ||
| _, err := runner.Execute(plugininstaller.RawOptions(options)) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
|
|
||
| // 2. return ture if all process success | ||
| return true, nil | ||
| } |
This file contains hidden or 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,25 @@ | ||
| package artifactory | ||
|
|
||
| import ( | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller" | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" | ||
| "github.com/devstream-io/devstream/pkg/util/log" | ||
| ) | ||
|
|
||
| func Read(options map[string]interface{}) (map[string]interface{}, error) { | ||
| // 1. config read operations | ||
| runner := &plugininstaller.Runner{ | ||
| PreExecuteOperations: []plugininstaller.MutableOperation{ | ||
| helm.Validate, | ||
| }, | ||
| GetStatusOperation: helm.GetPluginAllState, | ||
| } | ||
|
|
||
| status, err := runner.Execute(plugininstaller.RawOptions(options)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| log.Debugf("Return map: %v", status) | ||
| return status, nil | ||
| } |
This file contains hidden or 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,28 @@ | ||
| package artifactory | ||
|
|
||
| import ( | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller" | ||
| "github.com/devstream-io/devstream/internal/pkg/plugininstaller/helm" | ||
| "github.com/devstream-io/devstream/pkg/util/log" | ||
| ) | ||
|
|
||
| func Update(options map[string]interface{}) (map[string]interface{}, error) { | ||
| // 1. config update operations | ||
| runner := &plugininstaller.Runner{ | ||
| PreExecuteOperations: []plugininstaller.MutableOperation{ | ||
| helm.Validate, | ||
| }, | ||
| ExecuteOperations: []plugininstaller.BaseOperation{ | ||
| helm.InstallOrUpdate, | ||
| }, | ||
| GetStatusOperation: helm.GetPluginStaticStateWrapper(defaultDeploymentList), | ||
| } | ||
|
|
||
| // 2. execute update get status and error | ||
| status, err := runner.Execute(plugininstaller.RawOptions(options)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| log.Debugf("Return map: %v", status) | ||
| return status, nil | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,33 @@ | ||
| tools: | ||
| # name of the tool | ||
| - name: artifactory | ||
| # id of the tool instance | ||
| instanceID: default | ||
| # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool. | ||
| dependsOn: [ ] | ||
| # options for the plugin | ||
| options: | ||
| create_namespace: true | ||
| repo: | ||
| name: jfrog | ||
| # url of the Helm repo, use self host helm config beacuse official helm does'nt support namespace config | ||
| url: https://charts.jfrog.io | ||
| # Helm chart information | ||
| chart: | ||
| # name of the chart | ||
| chart_name: jfrog/artifactory | ||
| # k8s namespace where Harbor will be installed | ||
| namespace: artifactory | ||
| # release name of the chart | ||
| release_name: artifactory | ||
| # whether to wait for the release to be deployed or not | ||
| wait: true | ||
| # the time to wait for any individual Kubernetes operation (like Jobs for hooks). This defaults to 5m0s | ||
| timeout: 10m | ||
| # whether to perform a CRD upgrade during installation | ||
| upgradeCRDs: true | ||
| # values_yaml: | | ||
| # artifactory: | ||
| # service: | ||
| # type: NodePort | ||
IronCore864 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.