Git Product home page Git Product logo

turbot / steampipe-plugin-sdk Goto Github PK

View Code? Open in Web Editor NEW
31.0 10.0 16.0 2.6 MB

Steampipe Plugin SDK is a simple abstraction layer to write a Steampipe plugin. Plugins automatically work across all engine types including the Steampipe CLI, Postgres FDW, SQLite extension and the export CLI.

Home Page: https://hub.steampipe.io/plugins

License: Apache License 2.0

Makefile 0.02% Go 99.28% HCL 0.66% Shell 0.04%
steampipe steampipe-plugin postgresql postgresql-fdw sql hacktoberfest etl sqlite sqlite-extension zero-etl

steampipe-plugin-sdk's Introduction

Steampipe Plugin SDK

This SDK makes it easy to write Steampipe plugins.

Getting Started

Compiling this SDK

To compile the SDK repo, you must install protoc.

brew install protoc
brew install protoc-gen-go-grpc

Open Source & Contributing

This repository is published under the Apache 2.0 license. Please see our code of conduct. We look forward to collaborating with you!

Steampipe is a product produced from this open source software, exclusively by Turbot HQ, Inc. It is distributed under our commercial terms. Others are allowed to make their own distribution of the software, but they cannot use any of the Turbot trademarks, cloud services, etc. You can learn more in our Open Source FAQ.

Get Involved

Join #steampipe on Slack โ†’

Want to help but don't know where to start? Pick up one of the help wanted issues:

steampipe-plugin-sdk's People

Contributors

aminvielledebatatbedrock avatar binaek avatar cbruno10 avatar daniel-garcia avatar dependabot[bot] avatar e-gineer avatar etienne-carriere avatar graza-io avatar johnsmyth avatar judell avatar kaidaguerre avatar misraved avatar pdecat avatar pskrbasu avatar subhajit97 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

steampipe-plugin-sdk's Issues

v0.2.4-rc.1

At present, we do not handle the list of qual values passed to a list call for an in clause, so if the list call has required key columns it fails

Tables with no list config defined hang indefinitely if you query without any qualifiers

Issue

If you have a table with just a get config (no list config) and do select * from <table>, the terminal will sit forever saying Loading results.

Expected Outcome

As the table has no list config defined, I would expect immediate failure with some kind of appropriate message.

Actual Outcome

The terminal will sit forever saying Loading results and you need to terminate the steampipe process from another session.

Env

CLI: 0.1.2
OS: macOS Big Sur 11.2
Terminal: iTerm 3.4.3 / zsh

tidy up DisplayProfileData

		s := ""
		for _, b := range b.Bytes() {
			if b == '\n' {
				log.Printf("[WARN] %s\n", s)
				s = ""
			} else {
				s += string(b)
			}
		}```

Add transform to get a field value from two different paths

There are few AWS resources in which the output of GET and LIST API calls differ (The type of struct differs for them).

Can we have a transform through which we can mention 2 paths to get the value ("Path1", "Path2")
If the value is not found in Path1 the transform should try to retrieve it from Path2

For example in aws_dynamodb_backup table

{
	Name:        "backup_status",
	Description: "Current status of the backup. Backup can be in one of the following states: CREATING, ACTIVE, DELETED",
	Type:        proto.ColumnType_STRING,
	Transform:   transform.GetValue("BackupStatus", "BackupDetails.BackupStatus,"),
}

LIST CALL STRUCT BackupSummary

// Contains details for the backup.
type BackupSummary struct {
	_ struct{} `type:"structure"`
	BackupArn *string `min:"37" type:"string"`
	BackupCreationDateTime *time.Time `type:"timestamp"`
	BackupExpiryDateTime *time.Time `type:"timestamp"`
	BackupName *string `min:"3" type:"string"`
	BackupSizeBytes *int64 `type:"long"`
	BackupStatus *string `type:"string" enum:"BackupStatus"`
	BackupType *string `type:"string" enum:"BackupType"`
	TableArn *string `type:"string"`
	TableId *string `type:"string"`
	TableName *string `min:"3" type:"string"`
}

GET CALL STRUCT BackupDescription

type BackupDescription struct {
	_ struct{} `type:"structure"`

	// Contains the details of the backup created for the table.
	BackupDetails *BackupDetails `type:"structure"`

	// Contains the details of the table when the backup was created.
	SourceTableDetails *SourceTableDetails `type:"structure"`

	// Contains the details of the features enabled on the table when the backup
	// was created. For example, LSIs, GSIs, streams, TTL.
	SourceTableFeatureDetails *SourceTableFeatureDetails `type:"structure"`
}

// Contains the details of the backup created for the table.
type BackupDetails struct {
	_ struct{} `type:"structure"`
	BackupArn *string `min:"37" type:"string" required:"true"`
	BackupCreationDateTime *time.Time `type:"timestamp" required:"true"`
	BackupExpiryDateTime *time.Time `type:"timestamp"`
	BackupName *string `min:"3" type:"string" required:"true"`
	BackupSizeBytes *int64 `type:"long"`
	BackupStatus *string `type:"string" required:"true" enum:"BackupStatus"`
	BackupType *string `type:"string" required:"true" enum:"BackupType"`
}

// Contains the details of the table when the backup was created.
type SourceTableDetails struct {
	_ struct{} `type:"structure"`
	BillingMode *string `type:"string" enum:"BillingMode"`
	ItemCount *int64 `type:"long"`
	KeySchema []*KeySchemaElement `min:"1" type:"list" required:"true"`
	ProvisionedThroughput *ProvisionedThroughput `type:"structure" required:"true"`
	TableArn *string `type:"string"`
	TableCreationDateTime *time.Time `type:"timestamp" required:"true"`
	TableId *string `type:"string" required:"true"`
	TableName *string `min:"3" type:"string" required:"true"`
	TableSizeBytes *int64 `type:"long"`
}

Transform `ToLower` not converting string to lowercase

branch: issue-13

	{
		Name:        "resource_group",
		Description: ColumnDescriptionResourceGroup,
		Type:        proto.ColumnType_STRING,
		Transform:   transform.FromField("ResourceGroup").Transform(transform.ToLower),
	},
> select resource_group from azure.azure_storage_table;
+----------------+
| RESOURCE_GROUP |
+----------------+
| Lalit_test     |
+----------------+
> 

Add a URI column type(?)

@e-gineer

e-gineer commented on 13 Nov 2020

I think we should consider having a specific column type for URIs.

It could be combined with https://github.com/petere/pguri

It would be used by things like github > organization > url

Handle cancellation of streams

when streaming results, we must handle cancellation

We need to consider the full cancellation journey - from steampipe > postgres > fdw > plugin

Legacy get calls failing

The hydrate item is not being populated for legacy get calls, causing them to fail when trying to cast the item

Add support for connection config

Add support for HCL format connection config - this will parsed by steampipe and sent to the plugin instance

The plugin will define a connection config schema which will be used to validate and parse the connection config

Add INET column type

We currently define ColumnType_CIDR and ColumnType_IPADDR which are validated to be a cidr and an IP address respectively. Add ColumnType_INET which may be either

In azure.azure_firewall table seeing few keys are missing for json object when passing it directly using transform.FromField

Slack conversation thread
https://turbothq.slack.com/archives/C01AC8JQNHH/p1610017247038000

		{
			Name:        "ip_configurations",
			Description: "A collection of IP configuration of the Azure Firewall resource",
			Type:        proto.ColumnType_JSON,
			Transform:   transform.FromField("AzureFirewall.AzureFirewallPropertiesFormat.IPConfigurations"),
		},

Test column using transform

			{
				Name:        "test_column",
				Description: "A list of AKAs (also-known-as) that uniquely identify this resource",
				Type:        proto.ColumnType_JSON,
				Transform:   transform.From(testFunction),
			},

Here in field test_column we are getting all the properties but not in the field ip_configurations
missing keys for ip_configurations

    "PrivateIPAddress": "10.0.0.4",
    "ProvisioningState": "Succeeded",

steampipe query --output json "select name, test_column, ip_configurations from azure.azure_firewall"

[
 {
  "ip_configurations": [
   {
    "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbot_rg/providers/Microsoft.Network/azureFirewalls/test_firewall/azureFirewallIpConfigurations/test_pi",
    "name": "test_pi",
    "properties": {
     "publicIPAddress": {
      "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbot_rg/providers/Microsoft.Network/publicIPAddresses/test_pi"
     },
     "subnet": {
      "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbot_rg/providers/Microsoft.Network/virtualNetworks/testvn/subnets/AzureFirewallSubnet"
     }
    }
   }
  ],
  "name": "test_firewall",
  "test_column": [
   {
    "PrivateIPAddress": "10.0.0.4",
    "ProvisioningState": "Succeeded",
    "PublicIPAddress": {
     "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbot_rg/providers/Microsoft.Network/publicIPAddresses/test_pi"
    },
    "Subnet": {
     "id": "/subscriptions/d7245080-b4ae-4fe5-b6fa-2e71b3dae6c8/resourceGroups/turbot_rg/providers/Microsoft.Network/virtualNetworks/testvn/subnets/AzureFirewallSubnet"
    }
   }
  ]
 },
]

Test transform function

func testFunction(ctx context.Context, d *transform.TransformData) (interface{}, error) {
	data := d.HydrateItem.(firewallInfo)

	var output []map[string]interface{}
	for _, firewall := range *data.AzureFirewall.AzureFirewallPropertiesFormat.IPConfigurations {
		output = append(output, map[string]interface{}{
			"PrivateIPAddress":  firewall.AzureFirewallIPConfigurationPropertiesFormat.PrivateIPAddress,
			"Subnet":            firewall.AzureFirewallIPConfigurationPropertiesFormat.Subnet,
			"PublicIPAddress":   firewall.AzureFirewallIPConfigurationPropertiesFormat.PublicIPAddress,
			"ProvisioningState": firewall.AzureFirewallIPConfigurationPropertiesFormat.ProvisioningState,
		})
	}
	return output, nil
}

Struct for IPConfigurations

type AzureFirewallIPConfigurationPropertiesFormat struct {
	// PrivateIPAddress - READ-ONLY; The Firewall Internal Load Balancer IP to be used as the next hop in User Defined Routes.
	PrivateIPAddress *string `json:"privateIPAddress,omitempty"`
	// Subnet - Reference to the subnet resource. This resource must be named 'AzureFirewallSubnet' or 'AzureFirewallManagementSubnet'.
	Subnet *SubResource `json:"subnet,omitempty"`
	// PublicIPAddress - Reference to the PublicIP resource. This field is a mandatory input if subnet is not null.
	PublicIPAddress *SubResource `json:"publicIPAddress,omitempty"`
	// ProvisioningState - READ-ONLY; The provisioning state of the Azure firewall IP configuration resource. Possible values include: 'Succeeded', 'Updating', 'Deleting', 'Failed'
	ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
}

Branch name
azure-firewall-test on https://github.com/turbotio/steampipe-plugin-azure repo

Update error wording when no connection config schema is provided

currently, if connection config is declared, but there is no connection config schema defined for the plugin, we get the rather unhelpful error:

 failed to refresh connections: plugin steampipe-plugin-aws does not define a connection config schema

Update to:

failed to refresh connections: connection config has been set for connection 'aws1', but plugin 'steampipe-plugin-aws' does 
not define connection config schema

Ensure errors from Get functions are returned and acted upon

If a Get function returns an error, under some circumstances it is ignored (as the error is streamed, but the rowdata channel is closed so the error channel is never read)

Instead, return error syncronously from get calls to ensure they are always reported

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.