Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Methanar
Sep 26, 2013

by the sex ghost
I want to marshal json into a struct. Given the following json, I've come up with the following struct. But the keys set for tags could actually be anything, not restricted to name or aggregatedBy. How do I represent this in my struct?

code:
[
  {
    "target": "sumSeries(https_metric.*)",
    "tags": {
      "name": "sumSeries(https_metric.*)",
      "aggregatedBy": "sum"
    },
    "datapoints": [
      [
         null,
        1630946310
      ],
      [
        10,
        1630946320
      ]
    ]
  }
]
code:
type graphiteResults []struct {
	Target string `json:"target"`
	Tags   struct {
		Name         string `json:"name"`
		AggregatedBy string `json:"aggregatedBy"`
	} `json:"tags"`
	Datapoints [][]interface{} `json:"datapoints"`
}
Is this what I want?

code:
type graphiteResults[]struct {
	Target string `json:"target"`
	Tags   map[string]interface{} `json:"tags"`
	Datapoints [][]interface{} `json:"datapoints"`
}

Methanar fucked around with this message at 18:40 on Sep 6, 2021

Adbot
ADBOT LOVES YOU

Methanar
Sep 26, 2013

by the sex ghost
So the existence of tags at all is optional. But if it does exist, it's a map of strings with values of also strings.

code:
type graphiteResults[]struct {
	Target string `json:"target"`
	Tags   map[string]interface{} `json:"tags"`
	Datapoints [][]interface{} `json:"datapoints"`
}

Methanar
Sep 26, 2013

by the sex ghost
I discovered today that some internal tool that interacts with MAAS to provision hardware is actually poorly written and can't handle hardware profiles with > 2 disks. Also it's hardcoded to expect a satadom disk as your boot partition and our latest hardware shipment doesn't actually have one of those. Unfortunately, I need this to work 2 weeks ago as this is blocking a trainwreck, zero-notice, suddenly-my-problem project I have that is more than a week overdue now; because I've been dealing with constant interruptions with being an acting team lead and project manager for like 6 other people because the senior-most engineer of the team left and the real manager is ¯\_(ツ)_/¯

So I went down a rabbit hole of setting myself up with a dev environment for the tool, trying to understand how it works (the relevant code was literally in a file named `todo.go` to give you a sense of how half-written this thing is. The official MAAS api docs are god awful too.

Between all of that and the half-written api client this tool is using, it's wasted like 5 hours of my time to get set up and to make changes to provision all non-boot partition disks into one big LVM as a fix. Except it doesn't work. I ended up having to read the real MAAS server's unit tests to figure out what the gently caress it actually wanted as parameters for my create PV and create LV calls because the docs just don't tell you. I'm still having type errors I don't fully understand because my http client doesn't make any sense and finally threw my hands up in frustration for the night.

honestly I don't even know if making it all one big ext4 LVM is even a good idea, it might not be because we're running databases and elasticsearch on this eventually and ???

Overall pretty disappointed in myself right now for taking so long to still have not actually fixed the problem.

programming sucks. I hate reading about people who claim to do this for fun. It's not fun. Computers shouldn't exist.

Methanar fucked around with this message at 03:23 on Jun 21, 2022

Methanar
Sep 26, 2013

by the sex ghost

Jabor posted:

that's okay I'll just make them all interface{}

actual lol for some reason

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply