TEAM - Sharebear

Introducing team Sharebear, a single man team ready to add some light to the extravaganza.

Members:

I made a quick start hacking on some code tonight https://gitlab.com/sharebear/terraform-provider-fpp hopefully after one more evening I can have something worthy of a small video.

Note: I followed the topic name format from the blog post, not from team pebkac

Build log #1

I forgot to add a bit of a log of progress from last night. I burned too many hours frustrated that I couldn’t get terraform plan to work for my first resource. When cleaning up the code to try and ask for help, things suddenly started working, resulting in the following bug report https://github.com/hashicorp/terraform-plugin-sdk/issues/653

Once that was cracked it was fairly smooth sailing to get the plan + apply working as intended for a very simple hard-coded config.

Next steps are to build out the other parameters to the resource so that I can remove the hardcoded config.

Build log #2

I had another session last night, started to flesh out the first resource definition. A little slow progress but I think I’m over the worst. I think my main problem last night is that I’m inexperienced with golang and the sdk.

A few impressions after this session;

  • I’m very uncertain how defensive I should write the code that interacts with the state/config. On the one hand the schema defines things need to be of the correct type, presence and other validations which, if I understand correctly will be validated before create/update are called, meaning that adding nil checks, type checks, validating casts, list length checks all feel like they would be a lot of pointless boilerplate, but writing code without them feels very unsafe. Fine for this little hobby project though.

  • I’m currently attempting to work test-driven for implmenting the unflatten function, which is ok but there is lots of important functionality defined in the schema (defaulting & validation) that isn’t currently covered. Maybe there’s a helper for reading some state and running defaulting + validations to write more meaningful tests of the functionality, I didn’t look around too hard last night.

  • SchemaValidateFunc is deprecated but the built in validation helpers haven’t been ported over to SchemaValidateDiagFunc. What is the best practice here when you just need a simple helper, use the provided validators (such as validation.IntAtLeast) or write your own against the new function signature?

  • (Resource) API design is hard. The underlying API I’m integrating against has inconsistencies, for some features it uses decimal RGB components, for others it uses hex-string that needs to be a multiple of 6 chars long. Currently I simply exposed the hex string directly, wondering if I should split that up into a list of 6 char strings to make the API easier to use.

  • Default validation of required fields is missing the field name in the error message, that doesn’t strike me as a useful default

    Error: Required attribute is not set
    
    on main.tf line 12, in resource "fpp_channel_testing" "main":
    12: resource "fpp_channel_testing" "main" {
    
  • It’s not obvious where to go for support with provider development. Both the Gitter and the forum here appear to be more focussed on end user support than help developing providers.

I’ll try and put together an initial progess video over the next couple of days.

2 Likes

Progress video #1

Apologies, in the video I said that the colours didn’t looks so good on the tree, but on review it does look better than my previous test where I didn’t use the whole range of colours.

Also, aware I need bigger text on later videos…

3 Likes

Build log #3

Quick update on last night’s progress, I added support for a couple of the other test modes, will try and make a video later today. Then I spent the rest of my time analysing how the file upload works in Falcon Player, deciding how to design a resource API around this, and some research of how to perform mulipart uploads in golang.

A big problem I have here is that the Falcon Player “API” doesn’t expose any hash of the file so determining when the file has changed could be problematic without downloading the file for every run.

Build log #4

I just did a very quick-n-dirty file upload resource, then noticed that due to updates in Falcon Player since I was last playing with it, I only need one more resource to make a lot more interesting video (my opinion :wink: ) .

This is incredible @sharebear

1 Like

Build log #5

Cutting some corners to get a good demo together but also getting quicker at implementing resources. I just added a status resource to allow primitive control of the “player”, and implemented my first resource import function.

Not directly related I stumbled upon the fact that Falcon Player has started work on a formal API which would give me more useful information to confirm whether sequence files had been changed.

Decided to drop any progress video for now, will try and get the formal entry video together during the weekend instead.

Official entry video

Credits:

Holiday lighting software:

My code (I hope to find time to clean it up soon):

8 Likes

This is awesome, now I need to find some rgb christmas lights for next year :smiley:

1 Like

Same! 2021 December Goalz

1 Like