From 001a7beda4af4cb8d69e6b941504908f086eee33 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Fri, 11 Feb 2022 19:18:28 -0500 Subject: [PATCH 1/4] draft new tables --- confluence/plugin.go | 3 + confluence/table_confluence_content.go | 4 +- .../table_confluence_content_body_storage.go | 4 +- .../table_confluence_content_body_view.go | 4 +- confluence/table_confluence_content_label.go | 130 ++++++++++++++++++ .../table_confluence_content_metadata.go | 58 ++++++++ .../table_confluence_content_version.go | 85 ++++++++++++ confluence/table_confluence_space.go | 4 +- go.mod | 3 +- go.sum | 11 +- 10 files changed, 293 insertions(+), 13 deletions(-) create mode 100644 confluence/table_confluence_content_label.go create mode 100644 confluence/table_confluence_content_metadata.go create mode 100644 confluence/table_confluence_content_version.go diff --git a/confluence/plugin.go b/confluence/plugin.go index f821e95..790191f 100644 --- a/confluence/plugin.go +++ b/confluence/plugin.go @@ -19,6 +19,9 @@ func Plugin(ctx context.Context) *plugin.Plugin { "confluence_content": tableConfluenceContent(), "confluence_content_body_storage": tableConfluenceContentBodyStorage(), "confluence_content_body_view": tableConfluenceContentBodyView(), + "confluence_content_label": tableConfluenceContentLabel(), + "confluence_content_metadata": tableConfluenceContentMetadata(), + "confluence_content_version": tableConfluenceContentVersion(), "confluence_space": tableConfluenceSpace(), }, } diff --git a/confluence/table_confluence_content.go b/confluence/table_confluence_content.go index 168ff02..b685238 100644 --- a/confluence/table_confluence_content.go +++ b/confluence/table_confluence_content.go @@ -3,7 +3,7 @@ package confluence import ( "context" - "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin" @@ -83,7 +83,7 @@ func listContent(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData startAt := 0 - options := &confluence.GetContentOptionsScheme{ + options := &model.GetContentOptionsScheme{ Expand: []string{"childTypes.all", "body.storage", "body.view", "space", "version"}, } diff --git a/confluence/table_confluence_content_body_storage.go b/confluence/table_confluence_content_body_storage.go index 99d1a5a..d4d5d24 100644 --- a/confluence/table_confluence_content_body_storage.go +++ b/confluence/table_confluence_content_body_storage.go @@ -3,7 +3,7 @@ package confluence import ( "context" - "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin" @@ -52,7 +52,7 @@ func listContentBodyStorage(ctx context.Context, d *plugin.QueryData, h *plugin. logger := plugin.Logger(ctx) logger.Trace("listContentBody") - content := h.Item.(*confluence.ContentScheme) + content := h.Item.(*model.ContentScheme) c := contentBody{ ID: content.ID, Representation: content.Body.Storage.Representation, diff --git a/confluence/table_confluence_content_body_view.go b/confluence/table_confluence_content_body_view.go index df559bc..9050f72 100644 --- a/confluence/table_confluence_content_body_view.go +++ b/confluence/table_confluence_content_body_view.go @@ -3,7 +3,7 @@ package confluence import ( "context" - "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin" @@ -45,7 +45,7 @@ func listContentBodyView(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd logger := plugin.Logger(ctx) logger.Trace("listContentBody") - content := h.Item.(*confluence.ContentScheme) + content := h.Item.(*model.ContentScheme) c := contentBody{ ID: content.ID, Representation: content.Body.View.Representation, diff --git a/confluence/table_confluence_content_label.go b/confluence/table_confluence_content_label.go new file mode 100644 index 0000000..ea1a6b6 --- /dev/null +++ b/confluence/table_confluence_content_label.go @@ -0,0 +1,130 @@ +package confluence + +import ( + "context" + + // "github.com/ctreminiom/go-atlassian/confluence" + + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" + // "github.com/turbot/steampipe-plugin-sdk/plugin/transform" +) + +//// TABLE DEFINITION + +func tableConfluenceContentLabel() *plugin.Table { + return &plugin.Table{ + Name: "confluence_content_label", + Description: "Confluence Content Label.", + // List: &plugin.ListConfig{ + // Hydrate: listContentLabel, + // }, + Get: &plugin.GetConfig{ + KeyColumns: plugin.SingleColumn("id"), + Hydrate: getContentLabel, + }, + Columns: []*plugin.Column{ + { + Name: "id", + Type: proto.ColumnType_STRING, + Description: "Automatically assigned when the label is created", + }, + { + Name: "prefix", + Type: proto.ColumnType_STRING, + Description: "The label prefix", + }, + { + Name: "name", + Type: proto.ColumnType_STRING, + Description: "The label name", + }, + { + Name: "label", + Type: proto.ColumnType_STRING, + Description: "The label", + }, + }, + } +} + +//// LIST FUNCTIONS + +// func listContentLabel(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { +// logger := plugin.Logger(ctx) +// logger.Trace("listContentLabel") +// +// instance, err := connect(ctx, d) +// if err != nil { +// return nil, err +// } +// +// var maxResults int +// limit := d.QueryContext.Limit +// if limit != nil { +// if *limit < int64(100) { +// maxResults = int(*limit) +// } +// } else { +// maxResults = 100 +// } +// +// startAt := 0 +// +// pagesLeft := true +// for pagesLeft { +// labels, _, err := instance.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults) +// if err != nil { +// return nil, err +// } +// for _, label := range labels.Results { +// d.StreamListItem(ctx, label) +// if plugin.IsCancelled(ctx) { +// return nil, nil +// } +// } +// if labels.Size < labels.Limit { +// pagesLeft = false +// } +// startAt += maxResults +// } +// return nil, nil +// } + +//// HYDRATE FUNCTIONS + +func getContentLabel(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + logger := plugin.Logger(ctx) + logger.Trace("getContentLabel") + + instance, err := connect(ctx, d) + if err != nil { + return nil, err + } + + var maxResults int + limit := d.QueryContext.Limit + if limit != nil { + if *limit < int64(100) { + maxResults = int(*limit) + } + } else { + maxResults = 100 + } + + startAt := 0 + + quals := d.KeyColumnQuals + logger.Warn("getContentLabel", "quals", quals) + // id := quals["id"].GetStringValue() + // logger.Warn("getContentLabel", "id", id) + contentID := quals["contentid"].GetStringValue() + prefix := quals["prefix"].GetStringValue() + + content, _, err := instance.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults) + if err != nil { + return nil, err + } + + return content, nil +} diff --git a/confluence/table_confluence_content_metadata.go b/confluence/table_confluence_content_metadata.go new file mode 100644 index 0000000..f5ba177 --- /dev/null +++ b/confluence/table_confluence_content_metadata.go @@ -0,0 +1,58 @@ +package confluence + +import ( + "context" + + // "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" +) + +//// TABLE DEFINITION +func tableConfluenceContentMetadata() *plugin.Table { + return &plugin.Table{ + Name: "confluence_content_metadata_currentuser", + Description: "Information about the current user in relation to the content, including when they last viewed it, modified it, contributed to it, or added it as a favorite.", + List: &plugin.ListConfig{ + ParentHydrate: listContent, + Hydrate: listContentMetadata, + }, + Columns: []*plugin.Column{ + { + Name: "id", + Type: proto.ColumnType_STRING, + Description: "The ID of the content.", + }, + { + Name: "metadata", + Type: proto.ColumnType_JSON, + Description: "The representation type of the content.", + }, + }, + } +} + + +// structs +type metadata struct { + ID string `json:"id,omitempty"` + Metadata *model.MetadataScheme `json:"metadata,omitempty"` +} + + +//// LIST FUNCTIONS +func listContentMetadata(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + logger := plugin.Logger(ctx) + logger.Trace("listContentMetadataCurrentUser") + + content := h.Item.(*model.ContentScheme) + c := metadata{ + ID: content.ID, + Metadata: content.Metadata, + } + d.StreamListItem(ctx, c) + + return nil, nil +} diff --git a/confluence/table_confluence_content_version.go b/confluence/table_confluence_content_version.go new file mode 100644 index 0000000..7679c4a --- /dev/null +++ b/confluence/table_confluence_content_version.go @@ -0,0 +1,85 @@ +package confluence + +import ( + "context" + + // "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" + + "github.com/turbot/steampipe-plugin-sdk/grpc/proto" + "github.com/turbot/steampipe-plugin-sdk/plugin" +) + +//// TABLE DEFINITION + +func tableConfluenceContentVersion() *plugin.Table { + return &plugin.Table{ + Name: "confluence_content_version", + Description: "Confluence Content Version.", + List: &plugin.ListConfig{ + ParentHydrate: listContent, + Hydrate: listContentVersion, + }, + Columns: []*plugin.Column{ + { + Name: "id", + Type: proto.ColumnType_STRING, + Description: "The ID of the content.", + }, + { + Name: "by", + Type: proto.ColumnType_STRING, + Description: "The representation type of the content.", + }, + { + Name: "number", + Type: proto.ColumnType_INT, + Description: "The content body.", + }, + { + Name: "when", + Type: proto.ColumnType_STRING, + Description: "The content body.", + }, + { + Name: "message", + Type: proto.ColumnType_STRING, + Description: "The content body.", + }, + { + Name: "minor_edit", + Type: proto.ColumnType_BOOL, + Description: "The content body.", + }, + }, + } +} + +type contentVersion struct { + ID string `json:"id,omitempty"` + By *model.ContentUserScheme `json:"by,omitempty"` + Number int `json:"number,omitempty"` + When string `json:"when,omitempty"` + Message string `json:"message,omitempty"` + MinorEdit bool `json:"minorEdit,omitempty"` +} + +//// LIST FUNCTIONS + +func listContentVersion(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + logger := plugin.Logger(ctx) + logger.Trace("listContentVersion") + + content := h.Item.(*model.ContentScheme) + c := contentVersion { + ID: content.ID, + By: content.Version.By, + Number: content.Version.Number, + When: content.Version.When, + Message: content.Version.Message, + MinorEdit: content.Version.MinorEdit, + } + d.StreamListItem(ctx, c) + + return nil, nil +} diff --git a/confluence/table_confluence_space.go b/confluence/table_confluence_space.go index 4b80f5d..ac023d4 100644 --- a/confluence/table_confluence_space.go +++ b/confluence/table_confluence_space.go @@ -3,7 +3,7 @@ package confluence import ( "context" - "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin" @@ -75,7 +75,7 @@ func listSpace(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) startAt := 0 - options := &confluence.GetSpacesOptionScheme{ + options := &model.GetSpacesOptionScheme{ SpaceKeys: nil, } diff --git a/go.mod b/go.mod index 8183751..457aa0c 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ellisvalentiner/steampipe-plugin-confluence go 1.17 require ( - github.com/ctreminiom/go-atlassian v1.3.0 + github.com/ctreminiom/go-atlassian v1.4.2 github.com/turbot/steampipe-plugin-sdk v1.8.2 ) @@ -26,6 +26,7 @@ require ( github.com/hashicorp/hcl/v2 v2.9.1 // indirect github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect github.com/iancoleman/strcase v0.1.2 // indirect + github.com/imdario/mergo v0.3.12 // indirect github.com/mattn/go-colorable v0.1.4 // indirect github.com/mattn/go-isatty v0.0.10 // indirect github.com/mattn/go-runewidth v0.0.7 // indirect diff --git a/go.sum b/go.sum index 114ae79..6d68761 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/ctreminiom/go-atlassian v1.3.0 h1:eMAGFsGbcSa7bgtPZwNMLIJLIirnae9izF/V2BOpGrM= -github.com/ctreminiom/go-atlassian v1.3.0/go.mod h1:8AdwRcpti9RsjS249GnBZDHLu5dZfRiHs4+Mp7Ozv3A= +github.com/ctreminiom/go-atlassian v1.4.2 h1:XYHMWJCXO6DATg3i7HiCWD2UP4B07p44btFhHHPLdio= +github.com/ctreminiom/go-atlassian v1.4.2/go.mod h1:PE4NtsNrzNNfMwOuOvij8ri5DvmB2fi5VFARmSFxaQw= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -77,7 +77,6 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.1.4/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.15.0 h1:qMuK0wxsoW4D0ddCCYwPSTm4KQv1X1ke3WmPWZ0Mvsk= @@ -92,7 +91,8 @@ github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb h1:b5rjCoWHc7eqmAS github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/iancoleman/strcase v0.1.2 h1:gnomlvw9tnV3ITTAxzKSgTF+8kFWcU/f+TgttpXGz1U= github.com/iancoleman/strcase v0.1.2/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE= -github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/jhump/protoreflect v1.6.0 h1:h5jfMVslIg6l29nsMs0D8Wj17RDVdNYti0vDN/PZZoE= github.com/jhump/protoreflect v1.6.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= @@ -139,6 +139,9 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tkrajina/go-reflector v0.5.4 h1:dS9aJEa/eYNQU/fwsb5CSiATOxcNyA/gG/A7a582D5s= github.com/tkrajina/go-reflector v0.5.4/go.mod h1:9PyLgEOzc78ey/JmQQHbW8cQJ1oucLlNQsg8yFvkVk8= github.com/turbot/go-kit v0.3.0 h1:o4zZIO1ovdmJ2bHWOdXnnt8jJMIDGqYSkZvBREzFeMQ= From 0478ea4b7ccf33e675937e02e53b22e7da07f8a6 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Sun, 13 Feb 2022 17:42:43 -0500 Subject: [PATCH 2/4] add drafts of new tables --- confluence/table_confluence_content.go | 5 +- confluence/table_confluence_content_label.go | 146 ++++++++++++------ .../table_confluence_content_metadata.go | 15 +- .../table_confluence_content_version.go | 27 ++-- go.mod | 2 +- go.sum | 4 +- 6 files changed, 122 insertions(+), 77 deletions(-) diff --git a/confluence/table_confluence_content.go b/confluence/table_confluence_content.go index b685238..d1b5b0c 100644 --- a/confluence/table_confluence_content.go +++ b/confluence/table_confluence_content.go @@ -83,8 +83,11 @@ func listContent(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData startAt := 0 + quals := d.KeyColumnQuals options := &model.GetContentOptionsScheme{ - Expand: []string{"childTypes.all", "body.storage", "body.view", "space", "version"}, + Expand: []string{"childTypes.all", "body.storage", "body.view", "space", "version"}, + SpaceKey: quals["space_key"].GetStringValue(), + // Status: quals["status"].GetStringValue(), } pagesLeft := true diff --git a/confluence/table_confluence_content_label.go b/confluence/table_confluence_content_label.go index ea1a6b6..6a6f0d7 100644 --- a/confluence/table_confluence_content_label.go +++ b/confluence/table_confluence_content_label.go @@ -3,11 +3,10 @@ package confluence import ( "context" - // "github.com/ctreminiom/go-atlassian/confluence" + model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" "github.com/turbot/steampipe-plugin-sdk/plugin" - // "github.com/turbot/steampipe-plugin-sdk/plugin/transform" ) //// TABLE DEFINITION @@ -16,9 +15,10 @@ func tableConfluenceContentLabel() *plugin.Table { return &plugin.Table{ Name: "confluence_content_label", Description: "Confluence Content Label.", - // List: &plugin.ListConfig{ - // Hydrate: listContentLabel, - // }, + List: &plugin.ListConfig{ + ParentHydrate: listContent, + Hydrate: listContentLabel, + }, Get: &plugin.GetConfig{ KeyColumns: plugin.SingleColumn("id"), Hydrate: getContentLabel, @@ -29,6 +29,21 @@ func tableConfluenceContentLabel() *plugin.Table { Type: proto.ColumnType_STRING, Description: "Automatically assigned when the label is created", }, + { + Name: "content_id", + Type: proto.ColumnType_STRING, + Description: "Automatically assigned when the content is created", + }, + { + Name: "title", + Type: proto.ColumnType_STRING, + Description: "The content title", + }, + { + Name: "space_key", + Type: proto.ColumnType_STRING, + Description: "The space containing the content", + }, { Name: "prefix", Type: proto.ColumnType_STRING, @@ -48,48 +63,62 @@ func tableConfluenceContentLabel() *plugin.Table { } } +type contentLabel struct { + ID string `json:"id,omitempty"` + ContentID string `json:"contentId,omitempty"` + Title string `json:"title,omitempty"` + SpaceKey string `json:"spaceKey,omitempty"` + Prefix string `json:"prefix,omitempty"` + Name string `json:"name,omitempty"` + Label string `json:"label,omitempty"` +} + //// LIST FUNCTIONS -// func listContentLabel(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { -// logger := plugin.Logger(ctx) -// logger.Trace("listContentLabel") -// -// instance, err := connect(ctx, d) -// if err != nil { -// return nil, err -// } -// -// var maxResults int -// limit := d.QueryContext.Limit -// if limit != nil { -// if *limit < int64(100) { -// maxResults = int(*limit) -// } -// } else { -// maxResults = 100 -// } -// -// startAt := 0 -// -// pagesLeft := true -// for pagesLeft { -// labels, _, err := instance.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults) -// if err != nil { -// return nil, err -// } -// for _, label := range labels.Results { -// d.StreamListItem(ctx, label) -// if plugin.IsCancelled(ctx) { -// return nil, nil -// } -// } -// if labels.Size < labels.Limit { -// pagesLeft = false -// } -// startAt += maxResults -// } -// return nil, nil -// } +func listContentLabel(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + logger := plugin.Logger(ctx) + logger.Trace("listContentLabel") + + instance, err := connect(ctx, d) + if err != nil { + return nil, err + } + + var maxResults int + limit := d.QueryContext.Limit + if limit != nil { + if *limit < int64(100) { + maxResults = int(*limit) + } + } else { + maxResults = 100 + } + + startAt := 0 + content := h.Item.(*model.ContentScheme) + quals := d.KeyColumnQuals + prefix := quals["prefix"].GetStringValue() + labels, _, err := instance.Content.Label.Gets(context.Background(), content.ID, prefix, startAt, maxResults) + if err != nil { + return nil, err + } + for _, label := range labels.Results { + row := contentLabel{ + ID: label.ID, + ContentID: content.ID, + Title: content.Title, + SpaceKey: content.Space.Key, + Prefix: label.Prefix, + Name: label.Name, + Label: label.Label, + } + d.StreamListItem(ctx, row) + if plugin.IsCancelled(ctx) { + return nil, nil + } + } + return nil, nil +} //// HYDRATE FUNCTIONS @@ -114,17 +143,34 @@ func getContentLabel(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrate startAt := 0 + content := h.Item.(*model.ContentScheme) quals := d.KeyColumnQuals logger.Warn("getContentLabel", "quals", quals) - // id := quals["id"].GetStringValue() - // logger.Warn("getContentLabel", "id", id) - contentID := quals["contentid"].GetStringValue() + contentID := quals["content_id"].GetStringValue() prefix := quals["prefix"].GetStringValue() - content, _, err := instance.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults) + labels, _, err := instance.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults) if err != nil { return nil, err } + var rows []contentLabel + + for _, label := range labels.Results { + row := contentLabel{ + ID: label.ID, + ContentID: content.ID, + Title: content.Title, + SpaceKey: content.Space.Key, + Prefix: label.Prefix, + Name: label.Name, + Label: label.Label, + } + // d.StreamListItem(ctx, row) + if plugin.IsCancelled(ctx) { + return nil, nil + } + rows = append(rows, row) + } - return content, nil + return rows, nil } diff --git a/confluence/table_confluence_content_metadata.go b/confluence/table_confluence_content_metadata.go index f5ba177..42b3f14 100644 --- a/confluence/table_confluence_content_metadata.go +++ b/confluence/table_confluence_content_metadata.go @@ -3,7 +3,6 @@ package confluence import ( "context" - // "github.com/ctreminiom/go-atlassian/confluence" model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" @@ -13,7 +12,7 @@ import ( //// TABLE DEFINITION func tableConfluenceContentMetadata() *plugin.Table { return &plugin.Table{ - Name: "confluence_content_metadata_currentuser", + Name: "confluence_content_metadata", Description: "Information about the current user in relation to the content, including when they last viewed it, modified it, contributed to it, or added it as a favorite.", List: &plugin.ListConfig{ ParentHydrate: listContent, @@ -34,23 +33,21 @@ func tableConfluenceContentMetadata() *plugin.Table { } } - // structs type metadata struct { - ID string `json:"id,omitempty"` - Metadata *model.MetadataScheme `json:"metadata,omitempty"` + ID string `json:"id,omitempty"` + Metadata *model.MetadataScheme `json:"metadata,omitempty"` } - //// LIST FUNCTIONS func listContentMetadata(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { logger := plugin.Logger(ctx) - logger.Trace("listContentMetadataCurrentUser") + logger.Trace("listContentMetadata") content := h.Item.(*model.ContentScheme) c := metadata{ - ID: content.ID, - Metadata: content.Metadata, + ID: content.ID, + Metadata: content.Metadata, } d.StreamListItem(ctx, c) diff --git a/confluence/table_confluence_content_version.go b/confluence/table_confluence_content_version.go index 7679c4a..00608aa 100644 --- a/confluence/table_confluence_content_version.go +++ b/confluence/table_confluence_content_version.go @@ -3,7 +3,6 @@ package confluence import ( "context" - // "github.com/ctreminiom/go-atlassian/confluence" model "github.com/ctreminiom/go-atlassian/pkg/infra/models" "github.com/turbot/steampipe-plugin-sdk/grpc/proto" @@ -56,12 +55,12 @@ func tableConfluenceContentVersion() *plugin.Table { } type contentVersion struct { - ID string `json:"id,omitempty"` - By *model.ContentUserScheme `json:"by,omitempty"` - Number int `json:"number,omitempty"` - When string `json:"when,omitempty"` - Message string `json:"message,omitempty"` - MinorEdit bool `json:"minorEdit,omitempty"` + ID string `json:"id,omitempty"` + By *model.ContentUserScheme `json:"by,omitempty"` + Number int `json:"number,omitempty"` + When string `json:"when,omitempty"` + Message string `json:"message,omitempty"` + MinorEdit bool `json:"minorEdit,omitempty"` } //// LIST FUNCTIONS @@ -71,13 +70,13 @@ func listContentVersion(ctx context.Context, d *plugin.QueryData, h *plugin.Hydr logger.Trace("listContentVersion") content := h.Item.(*model.ContentScheme) - c := contentVersion { - ID: content.ID, - By: content.Version.By, - Number: content.Version.Number, - When: content.Version.When, - Message: content.Version.Message, - MinorEdit: content.Version.MinorEdit, + c := contentVersion{ + ID: content.ID, + By: content.Version.By, + Number: content.Version.Number, + When: content.Version.When, + Message: content.Version.Message, + MinorEdit: content.Version.MinorEdit, } d.StreamListItem(ctx, c) diff --git a/go.mod b/go.mod index 457aa0c..54cab18 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.17 require ( github.com/ctreminiom/go-atlassian v1.4.2 - github.com/turbot/steampipe-plugin-sdk v1.8.2 + github.com/turbot/steampipe-plugin-sdk v1.8.3 ) require ( diff --git a/go.sum b/go.sum index 6d68761..cd52db8 100644 --- a/go.sum +++ b/go.sum @@ -146,8 +146,8 @@ github.com/tkrajina/go-reflector v0.5.4 h1:dS9aJEa/eYNQU/fwsb5CSiATOxcNyA/gG/A7a github.com/tkrajina/go-reflector v0.5.4/go.mod h1:9PyLgEOzc78ey/JmQQHbW8cQJ1oucLlNQsg8yFvkVk8= github.com/turbot/go-kit v0.3.0 h1:o4zZIO1ovdmJ2bHWOdXnnt8jJMIDGqYSkZvBREzFeMQ= github.com/turbot/go-kit v0.3.0/go.mod h1:SBdPRngbEfYubiR81iAVtO43oPkg1+ASr+XxvgbH7/k= -github.com/turbot/steampipe-plugin-sdk v1.8.2 h1:ng/UNCI1mS8/iYwj42MdHU/hGkU2XBH0HR0W3IB3nw4= -github.com/turbot/steampipe-plugin-sdk v1.8.2/go.mod h1:76H3wr6KB6t+kDS38EEOZAsw61Ie/q7/IV9X0kv5NjI= +github.com/turbot/steampipe-plugin-sdk v1.8.3 h1:P6Bxp9GWbUhXaR5Rq/tFuFvuhe/hFFKCiDxzxv4OH9A= +github.com/turbot/steampipe-plugin-sdk v1.8.3/go.mod h1:76H3wr6KB6t+kDS38EEOZAsw61Ie/q7/IV9X0kv5NjI= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/tagparser v0.1.1/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= From 983ade3a491bc17eb8502c45c1e84a92108ff443 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Sun, 17 Apr 2022 09:51:27 -0400 Subject: [PATCH 3/4] feat: add content label and version tables --- confluence/plugin.go | 1 - confluence/table_confluence_content.go | 48 ++++--- .../table_confluence_content_body_storage.go | 4 +- .../table_confluence_content_body_view.go | 4 +- confluence/table_confluence_content_label.go | 90 +------------ .../table_confluence_content_metadata.go | 55 -------- .../table_confluence_content_version.go | 124 ++++++++++++++---- confluence/table_confluence_space.go | 18 +-- docs/tables/confluence_content_label.md | 42 ++++++ docs/tables/confluence_content_version.md | 38 ++++++ go.mod | 3 +- go.sum | 11 +- 12 files changed, 226 insertions(+), 212 deletions(-) delete mode 100644 confluence/table_confluence_content_metadata.go create mode 100644 docs/tables/confluence_content_label.md create mode 100644 docs/tables/confluence_content_version.md diff --git a/confluence/plugin.go b/confluence/plugin.go index 790191f..b2efdd4 100644 --- a/confluence/plugin.go +++ b/confluence/plugin.go @@ -20,7 +20,6 @@ func Plugin(ctx context.Context) *plugin.Plugin { "confluence_content_body_storage": tableConfluenceContentBodyStorage(), "confluence_content_body_view": tableConfluenceContentBodyView(), "confluence_content_label": tableConfluenceContentLabel(), - "confluence_content_metadata": tableConfluenceContentMetadata(), "confluence_content_version": tableConfluenceContentVersion(), "confluence_space": tableConfluenceSpace(), }, diff --git a/confluence/table_confluence_content.go b/confluence/table_confluence_content.go index d1b5b0c..56105e6 100644 --- a/confluence/table_confluence_content.go +++ b/confluence/table_confluence_content.go @@ -64,48 +64,46 @@ func tableConfluenceContent() *plugin.Table { func listContent(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error) { logger := plugin.Logger(ctx) - logger.Trace("listContent") + logger.Trace("List confluence content") instance, err := connect(ctx, d) if err != nil { return nil, err } - var maxResults int - limit := d.QueryContext.Limit - if limit != nil { - if *limit < int64(100) { - maxResults = int(*limit) - } + var limit int + if d.QueryContext.Limit != nil { + limit = int(limit) } else { - maxResults = 100 + limit = 1000 } - - startAt := 0 - quals := d.KeyColumnQuals options := &model.GetContentOptionsScheme{ - Expand: []string{"childTypes.all", "body.storage", "body.view", "space", "version"}, + Expand: []string{"childTypes.all", "body.storage", "body.view", "metadata.labels", "space", "version"}, SpaceKey: quals["space_key"].GetStringValue(), - // Status: quals["status"].GetStringValue(), } + startAt := 0 + pageSize := 25 pagesLeft := true for pagesLeft { - page, _, err := instance.Content.Gets(context.Background(), options, startAt, maxResults) + page, response, err := instance.Content.Gets(context.Background(), options, startAt, pageSize) if err != nil { - return nil, err - } - for _, content := range page.Results { - d.StreamListItem(ctx, content) - if plugin.IsCancelled(ctx) { - return nil, nil + logger.Warn("Encountered error", "error", err, "Response", response) + return nil, nil + } else { + logger.Trace("Adding content items", "start", page.Start, "size", page.Size, "links", page.Links) + for _, content := range page.Results { + d.StreamListItem(ctx, content) + if plugin.IsCancelled(ctx) { + return nil, nil + } } + if page.Size < page.Limit || limit <= page.Size { + pagesLeft = false + } + startAt += pageSize } - if page.Size < page.Limit { - pagesLeft = false - } - startAt += maxResults } return nil, nil } @@ -114,7 +112,7 @@ func listContent(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData func getContent(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { logger := plugin.Logger(ctx) - logger.Trace("getContent") + logger.Trace("Get confluence content") instance, err := connect(ctx, d) if err != nil { diff --git a/confluence/table_confluence_content_body_storage.go b/confluence/table_confluence_content_body_storage.go index d4d5d24..dc09802 100644 --- a/confluence/table_confluence_content_body_storage.go +++ b/confluence/table_confluence_content_body_storage.go @@ -53,12 +53,12 @@ func listContentBodyStorage(ctx context.Context, d *plugin.QueryData, h *plugin. logger.Trace("listContentBody") content := h.Item.(*model.ContentScheme) - c := contentBody{ + row := contentBody{ ID: content.ID, Representation: content.Body.Storage.Representation, Value: content.Body.Storage.Value, } - d.StreamListItem(ctx, c) + d.StreamListItem(ctx, row) return nil, nil } diff --git a/confluence/table_confluence_content_body_view.go b/confluence/table_confluence_content_body_view.go index 9050f72..82f9a52 100644 --- a/confluence/table_confluence_content_body_view.go +++ b/confluence/table_confluence_content_body_view.go @@ -46,12 +46,12 @@ func listContentBodyView(ctx context.Context, d *plugin.QueryData, h *plugin.Hyd logger.Trace("listContentBody") content := h.Item.(*model.ContentScheme) - c := contentBody{ + row := contentBody{ ID: content.ID, Representation: content.Body.View.Representation, Value: content.Body.View.Value, } - d.StreamListItem(ctx, c) + d.StreamListItem(ctx, row) return nil, nil } diff --git a/confluence/table_confluence_content_label.go b/confluence/table_confluence_content_label.go index 6a6f0d7..ae5a6fc 100644 --- a/confluence/table_confluence_content_label.go +++ b/confluence/table_confluence_content_label.go @@ -19,10 +19,6 @@ func tableConfluenceContentLabel() *plugin.Table { ParentHydrate: listContent, Hydrate: listContentLabel, }, - Get: &plugin.GetConfig{ - KeyColumns: plugin.SingleColumn("id"), - Hydrate: getContentLabel, - }, Columns: []*plugin.Column{ { Name: "id", @@ -73,36 +69,13 @@ type contentLabel struct { Label string `json:"label,omitempty"` } -//// LIST FUNCTIONS - +// LIST FUNCTIONS func listContentLabel(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { logger := plugin.Logger(ctx) logger.Trace("listContentLabel") - instance, err := connect(ctx, d) - if err != nil { - return nil, err - } - - var maxResults int - limit := d.QueryContext.Limit - if limit != nil { - if *limit < int64(100) { - maxResults = int(*limit) - } - } else { - maxResults = 100 - } - - startAt := 0 content := h.Item.(*model.ContentScheme) - quals := d.KeyColumnQuals - prefix := quals["prefix"].GetStringValue() - labels, _, err := instance.Content.Label.Gets(context.Background(), content.ID, prefix, startAt, maxResults) - if err != nil { - return nil, err - } - for _, label := range labels.Results { + for _, label := range content.Metadata.Labels.Results { row := contentLabel{ ID: label.ID, ContentID: content.ID, @@ -113,64 +86,7 @@ func listContentLabel(ctx context.Context, d *plugin.QueryData, h *plugin.Hydrat Label: label.Label, } d.StreamListItem(ctx, row) - if plugin.IsCancelled(ctx) { - return nil, nil - } - } - return nil, nil -} - -//// HYDRATE FUNCTIONS - -func getContentLabel(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { - logger := plugin.Logger(ctx) - logger.Trace("getContentLabel") - - instance, err := connect(ctx, d) - if err != nil { - return nil, err - } - - var maxResults int - limit := d.QueryContext.Limit - if limit != nil { - if *limit < int64(100) { - maxResults = int(*limit) - } - } else { - maxResults = 100 } - startAt := 0 - - content := h.Item.(*model.ContentScheme) - quals := d.KeyColumnQuals - logger.Warn("getContentLabel", "quals", quals) - contentID := quals["content_id"].GetStringValue() - prefix := quals["prefix"].GetStringValue() - - labels, _, err := instance.Content.Label.Gets(context.Background(), contentID, prefix, startAt, maxResults) - if err != nil { - return nil, err - } - var rows []contentLabel - - for _, label := range labels.Results { - row := contentLabel{ - ID: label.ID, - ContentID: content.ID, - Title: content.Title, - SpaceKey: content.Space.Key, - Prefix: label.Prefix, - Name: label.Name, - Label: label.Label, - } - // d.StreamListItem(ctx, row) - if plugin.IsCancelled(ctx) { - return nil, nil - } - rows = append(rows, row) - } - - return rows, nil + return nil, nil } diff --git a/confluence/table_confluence_content_metadata.go b/confluence/table_confluence_content_metadata.go deleted file mode 100644 index 42b3f14..0000000 --- a/confluence/table_confluence_content_metadata.go +++ /dev/null @@ -1,55 +0,0 @@ -package confluence - -import ( - "context" - - model "github.com/ctreminiom/go-atlassian/pkg/infra/models" - - "github.com/turbot/steampipe-plugin-sdk/grpc/proto" - "github.com/turbot/steampipe-plugin-sdk/plugin" -) - -//// TABLE DEFINITION -func tableConfluenceContentMetadata() *plugin.Table { - return &plugin.Table{ - Name: "confluence_content_metadata", - Description: "Information about the current user in relation to the content, including when they last viewed it, modified it, contributed to it, or added it as a favorite.", - List: &plugin.ListConfig{ - ParentHydrate: listContent, - Hydrate: listContentMetadata, - }, - Columns: []*plugin.Column{ - { - Name: "id", - Type: proto.ColumnType_STRING, - Description: "The ID of the content.", - }, - { - Name: "metadata", - Type: proto.ColumnType_JSON, - Description: "The representation type of the content.", - }, - }, - } -} - -// structs -type metadata struct { - ID string `json:"id,omitempty"` - Metadata *model.MetadataScheme `json:"metadata,omitempty"` -} - -//// LIST FUNCTIONS -func listContentMetadata(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { - logger := plugin.Logger(ctx) - logger.Trace("listContentMetadata") - - content := h.Item.(*model.ContentScheme) - c := metadata{ - ID: content.ID, - Metadata: content.Metadata, - } - d.StreamListItem(ctx, c) - - return nil, nil -} diff --git a/confluence/table_confluence_content_version.go b/confluence/table_confluence_content_version.go index 00608aa..c53aa14 100644 --- a/confluence/table_confluence_content_version.go +++ b/confluence/table_confluence_content_version.go @@ -19,48 +19,76 @@ func tableConfluenceContentVersion() *plugin.Table { ParentHydrate: listContent, Hydrate: listContentVersion, }, + Get: &plugin.GetConfig{ + KeyColumns: plugin.SingleColumn("id"), + Hydrate: getContentVersion, + }, Columns: []*plugin.Column{ { Name: "id", Type: proto.ColumnType_STRING, Description: "The ID of the content.", }, - { - Name: "by", - Type: proto.ColumnType_STRING, - Description: "The representation type of the content.", - }, { Name: "number", Type: proto.ColumnType_INT, - Description: "The content body.", + Description: "The content version number.", }, { Name: "when", Type: proto.ColumnType_STRING, - Description: "The content body.", + Description: "When the content version was published.", }, { Name: "message", Type: proto.ColumnType_STRING, - Description: "The content body.", + Description: "The content version message.", }, { Name: "minor_edit", Type: proto.ColumnType_BOOL, - Description: "The content body.", + Description: "Whether the version corresponds to a minor edit.", + }, + { + Name: "username", + Type: proto.ColumnType_STRING, + Description: "The username for the content version's author.", + }, + { + Name: "userKey", + Type: proto.ColumnType_STRING, + Description: "The user key for the content version's author.", + }, + { + Name: "accountId", + Type: proto.ColumnType_STRING, + Description: "The account ID for the content version's author.", + }, + { + Name: "email", + Type: proto.ColumnType_STRING, + Description: "The email for the content version's author.", + }, + { + Name: "displayName", + Type: proto.ColumnType_STRING, + Description: "The display name for the content version's author.", }, }, } } type contentVersion struct { - ID string `json:"id,omitempty"` - By *model.ContentUserScheme `json:"by,omitempty"` - Number int `json:"number,omitempty"` - When string `json:"when,omitempty"` - Message string `json:"message,omitempty"` - MinorEdit bool `json:"minorEdit,omitempty"` + ID string `json:"id,omitempty"` + Number int `json:"number,omitempty"` + When string `json:"when,omitempty"` + Message string `json:"message,omitempty"` + MinorEdit bool `json:"minorEdit,omitempty"` + Username string `json:"username,omitempty"` + UserKey string `json:"userKey,omitempty"` + AccountID string `json:"accountId,omitempty"` + Email string `json:"email,omitempty"` + DisplayName string `json:"displayName,omitempty"` } //// LIST FUNCTIONS @@ -70,15 +98,65 @@ func listContentVersion(ctx context.Context, d *plugin.QueryData, h *plugin.Hydr logger.Trace("listContentVersion") content := h.Item.(*model.ContentScheme) - c := contentVersion{ - ID: content.ID, - By: content.Version.By, - Number: content.Version.Number, - When: content.Version.When, - Message: content.Version.Message, - MinorEdit: content.Version.MinorEdit, + row := contentVersion{ + ID: content.ID, + Number: content.Version.Number, + When: content.Version.When, + Message: content.Version.Message, + MinorEdit: content.Version.MinorEdit, + Username: content.Version.By.Username, + UserKey: content.Version.By.UserKey, + AccountID: content.Version.By.AccountID, + Email: content.Version.By.Email, + DisplayName: content.Version.By.DisplayName, } - d.StreamListItem(ctx, c) + d.StreamListItem(ctx, row) return nil, nil } + +//// HYDRATE FUNCTIONS + +func getContentVersion(ctx context.Context, d *plugin.QueryData, h *plugin.HydrateData) (interface{}, error) { + logger := plugin.Logger(ctx) + logger.Trace("Get confluence content") + + instance, err := connect(ctx, d) + if err != nil { + return nil, err + } + + quals := d.KeyColumnQuals + logger.Warn("getContent", "quals", quals) + id := quals["id"].GetStringValue() + logger.Warn("getContent", "id", id) + + expand := []string{} + start := 0 + limit := 50 + versions, _, err := instance.Content.Version.Gets(context.Background(), id, expand, start, limit) + if err != nil { + return nil, err + } + var rows []contentVersion + for _, version := range versions.Results { + row := contentVersion{ + ID: id, + Number: version.Number, + When: version.When, + Message: version.Message, + MinorEdit: version.MinorEdit, + Username: version.By.Username, + UserKey: version.By.UserKey, + AccountID: version.By.AccountID, + Email: version.By.Email, + DisplayName: version.By.DisplayName, + } + if plugin.IsCancelled(ctx) { + return nil, nil + } + rows = append(rows, row) + } + + return rows, nil +} diff --git a/confluence/table_confluence_space.go b/confluence/table_confluence_space.go index ac023d4..f01b19e 100644 --- a/confluence/table_confluence_space.go +++ b/confluence/table_confluence_space.go @@ -63,25 +63,19 @@ func listSpace(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) return nil, err } - var maxResults int - limit := d.QueryContext.Limit - if limit != nil { - if *limit < int64(100) { - maxResults = int(*limit) - } - } else { - maxResults = 100 - } - startAt := 0 + pageSize := 25 + quals := d.KeyColumnQuals options := &model.GetSpacesOptionScheme{ SpaceKeys: nil, + // Type: quals["type"].GetStringValue(), + Status: quals["status"].GetStringValue(), } pagesLeft := true for pagesLeft { - page, _, err := instance.Space.Gets(context.Background(), options, startAt, maxResults) + page, _, err := instance.Space.Gets(context.Background(), options, startAt, pageSize) if err != nil { return nil, err } @@ -94,7 +88,7 @@ func listSpace(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) if page.Size < page.Limit { pagesLeft = false } - startAt += maxResults + startAt += pageSize } return nil, nil } diff --git a/docs/tables/confluence_content_label.md b/docs/tables/confluence_content_label.md new file mode 100644 index 0000000..0fd9c59 --- /dev/null +++ b/docs/tables/confluence_content_label.md @@ -0,0 +1,42 @@ +# Table: confluence_content_label + +Content labels in a Confluence instance. + +## Examples + +### Get basic info about the labels + +```sql +select + id, + content_id, + title, + space_key, + prefix, + name, + label +from + confluence_content_label; +``` + +### Get the count of content by label + +```sql +select + label, + count(*) +from + confluence_content_label +group by label; +``` + +### Get labels with `documentation` in the name + +```sql +select + * +from + confluence_content_label +where + name ilike '%documentation%'; +``` diff --git a/docs/tables/confluence_content_version.md b/docs/tables/confluence_content_version.md new file mode 100644 index 0000000..4341b7b --- /dev/null +++ b/docs/tables/confluence_content_version.md @@ -0,0 +1,38 @@ +# Table: confluence_content_version + +Content versions in a Confluence instance. + +## Examples + +### Get basic info about the version + +```sql +select + * +from + confluence_content_version; +``` + +### Get the count of content by label + +```sql +select + label, + count(*) +from + confluence_content_version +group by label; +``` + +### Get the 50 oldest pages + +```sql +select + title, + space_key, + "when" +from confluence_content_version +join confluence_content using (id) +order by "when" asc +limit 50; +``` diff --git a/go.mod b/go.mod index 54cab18..cb53645 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/ellisvalentiner/steampipe-plugin-confluence go 1.17 require ( - github.com/ctreminiom/go-atlassian v1.4.2 + github.com/ctreminiom/go-atlassian v1.4.3 github.com/turbot/steampipe-plugin-sdk v1.8.3 ) @@ -20,6 +20,7 @@ require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/golang/glog v1.0.0 // indirect github.com/golang/protobuf v1.5.2 // indirect + github.com/google/uuid v1.3.0 // indirect github.com/hashicorp/go-hclog v0.15.0 // indirect github.com/hashicorp/go-plugin v1.4.1 // indirect github.com/hashicorp/go-version v1.3.0 // indirect diff --git a/go.sum b/go.sum index cd52db8..fc96d7e 100644 --- a/go.sum +++ b/go.sum @@ -22,8 +22,8 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/ctreminiom/go-atlassian v1.4.2 h1:XYHMWJCXO6DATg3i7HiCWD2UP4B07p44btFhHHPLdio= -github.com/ctreminiom/go-atlassian v1.4.2/go.mod h1:PE4NtsNrzNNfMwOuOvij8ri5DvmB2fi5VFARmSFxaQw= +github.com/ctreminiom/go-atlassian v1.4.3 h1:EaMe33TeoT90HGo0q33LQ3zgNuvyLmh6xvXldgKmkWs= +github.com/ctreminiom/go-atlassian v1.4.3/go.mod h1:44eEvm7NA+rKWCyB83RHpbOn6vsdiA21wngF50a8254= github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -77,6 +77,8 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-hclog v0.15.0 h1:qMuK0wxsoW4D0ddCCYwPSTm4KQv1X1ke3WmPWZ0Mvsk= @@ -137,9 +139,10 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tkrajina/go-reflector v0.5.4 h1:dS9aJEa/eYNQU/fwsb5CSiATOxcNyA/gG/A7a582D5s= From 6d48d5ba4ca253a93c211f16af32aa130aed1967 Mon Sep 17 00:00:00 2001 From: Ellis Valentiner Date: Sun, 17 Apr 2022 09:59:47 -0400 Subject: [PATCH 4/4] chore: upgrade golangci-lint --- .github/workflows/golangci-lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index afd3cf9..ae9756d 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -12,10 +12,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v3 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.29