Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions cmd/plugin/artifactory/main.go
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)
}
46 changes: 46 additions & 0 deletions docs/plugins/artifactory.md
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.
45 changes: 45 additions & 0 deletions docs/plugins/artifactory.zh.md
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` 字段,所有示例参数均为必填项。
5 changes: 5 additions & 0 deletions internal/pkg/plugin/artifactory/artifactory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package artifactory

var defaultDeploymentList = []string{
"artifactory",
}
32 changes: 32 additions & 0 deletions internal/pkg/plugin/artifactory/create.go
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),
}

// 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
}
26 changes: 26 additions & 0 deletions internal/pkg/plugin/artifactory/delete.go
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
}
25 changes: 25 additions & 0 deletions internal/pkg/plugin/artifactory/read.go
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
}
28 changes: 28 additions & 0 deletions internal/pkg/plugin/artifactory/update.go
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
}
4 changes: 4 additions & 0 deletions internal/pkg/show/config/embed_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 33 additions & 0 deletions internal/pkg/show/config/plugins/artifactory.yaml
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