Skip to content

Commit

Permalink
feat: add new datasource Web
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Jan 22, 2024
1 parent b31d71f commit 7f5b237
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 1 deletion.
3 changes: 3 additions & 0 deletions api/base/v1alpha1/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
DatasourceTypeOSS DatasourceType = "oss"
DatasourceTypeRDMA DatasourceType = "RDMA"
DatasourceTypePostgreSQL DatasourceType = "postgresql"
DatasourceTypeWeb DatasourceType = "web"
DatasourceTypeUnknown DatasourceType = "unknown"
)

Expand All @@ -42,6 +43,8 @@ func (ds DatasourceSpec) Type() DatasourceType {
return DatasourceTypeRDMA
case ds.PostgreSQL != nil:
return DatasourceTypePostgreSQL
case ds.Web != nil:
return DatasourceTypeWeb
default:
return DatasourceTypeUnknown
}
Expand Down
8 changes: 8 additions & 0 deletions api/base/v1alpha1/datasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ type DatasourceSpec struct {

// PostgreSQL defines info for PostgreSQL
PostgreSQL *PostgreSQL `json:"postgresql,omitempty"`

// Web defines info for web pages
Web *Web `json:"web,omitempty"`
}

type RDMA struct {
Expand Down Expand Up @@ -85,6 +88,11 @@ const (
PGSSLPASSWORD = "PGSSLPASSWORD"
)

// Web defines a
type Web struct {
// TODO: define more fields later
}

// DatasourceStatus defines the observed state of Datasource
type DatasourceStatus struct {
// ConditionedStatus is the current status
Expand Down
20 changes: 20 additions & 0 deletions api/base/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions config/crd/bases/arcadia.kubeagi.k8s.com.cn_datasources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ spec:
required:
- path
type: object
web:
description: Web defines info for web pages
type: object
required:
- endpoint
type: object
Expand Down
6 changes: 6 additions & 0 deletions controllers/base/datasource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,12 @@ func (r *DatasourceReconciler) Checkdatasource(ctx context.Context, logger logr.
if err != nil {
return r.UpdateStatus(ctx, instance, err)
}
case arcadiav1alpha1.DatasourceTypeWeb:
ds, err = datasource.NewWeb(ctx)
if err != nil {
return r.UpdateStatus(ctx, instance, err)
}
info = instance.Spec.Web.DeepCopy()
default:
ds, err = datasource.NewUnknown(ctx, r.Client)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/arcadia/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: arcadia
description: A Helm chart(KubeBB Component) for KubeAGI Arcadia
type: application
version: 0.2.17
version: 0.2.18
appVersion: "0.1.0"

keywords:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ spec:
required:
- path
type: object
web:
description: Web defines info for web pages
type: object
required:
- endpoint
type: object
Expand Down
59 changes: 59 additions & 0 deletions pkg/datasource/web.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
Copyright 2024 KubeAGI.
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 datasource

import (
"context"
"io"
)

var _ Datasource = (*Web)(nil)

type Web struct {
}

func NewWeb(ctx context.Context) (*Web, error) {
return &Web{}, nil
}

func (w *Web) Stat(ctx context.Context, info any) error {
return nil
}

func (w *Web) Remove(ctx context.Context, info any) error {
// TODO implement me
panic("implement me")
}

func (w *Web) ReadFile(ctx context.Context, info any) (io.ReadCloser, error) {
// TODO implement me
panic("implement me")
}

func (w *Web) StatFile(ctx context.Context, info any) (any, error) {
// TODO implement me
panic("implement me")
}

func (w *Web) GetTags(ctx context.Context, info any) (map[string]string, error) {
// TODO implement me
panic("implement me")
}

func (w *Web) ListObjects(ctx context.Context, source string, info any) (any, error) {
// TODO implement me
panic("implement me")
}

0 comments on commit 7f5b237

Please sign in to comment.