Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
fen
@fenneh
Did another run just to ensure it wasn't my terminal, so vanilla powershell, not using env variables and same behavior
Dalmiro Granas
@Dalmirog
image.png
@kneumei sneak peak of what I'm working on. Its a console that will fill the database with all the test data necessary for the tests to run. Its the final piece before I can share a usable dev guide :tada:
@fenneh I'm gonna ping you privately for that issue. Sorry for the delay!
Andrew Savinykh
@andrewsav-datacom
$varset = (Get-OctopusVariableSet -LibrarySetName "MySet")
$varset.Variables[1].Scope.roles.Add("test-test")
$varset | Update-OctopusResource
@Dalmirog I'm trying to manipulate scope of a variable
the above does not seem to work
(nothing changes in the OD)
How to do this correctly?
Andrew Savinykh
@andrewsav-datacom
Right, so all this "Friendly" adapters are not updated back
This is confusing because if you add role on the machine - it works
but that's because the roles property just assigned straight from underlying resources
feels a tad inconsistent
Dalmiro Granas
@Dalmirog

Hi @andrewsav-datacom not infront of the laptop now so I can't test or type too much.

You should be adding to role to $varset.resource.variables.[...]

and then do the $varset | update-octopusresource

I'll write more about this tomorrow morning : )

Andrew Savinykh
@AndrewSav
yeah, I figured that out...
thanks
Dalmiro Granas
@Dalmirog
@AndrewSav I'm gonna try think of a way to avoid user running into that pitfal during the weekend. Ideas are more than welcome :)
image.png

been working on this console project to load all the data needed for the tests to run this week. Like I mentioned earlier, this + a nice doc are the missing pieces to finally share a dev guide of the project so others can contribute to it.

^ That screenshot is the first try of running all the tests with the data generated by the console. I still haven't made the console create channels, deployments or releases, so 100/141 is not a bad first result.

Gonna work the rest of the week on improving those numbers, which will probable lead into refactoring lots of tests and writing brand new ones. Gonna try to tame the scope-creep inside of me as much as I can to ship this fast

Dalmiro Granas
@Dalmirog
image.png
All tests passing with data generated by this new console. The console takes about 60s to run and create the entire infrastructure+releases+deployments. The previous method which involved importing an Octopus export took 5-6min and was quite error prone. Most of those 5-6min was the migrator deciding what to do with the existing resources. This new console simply nukes everything and re-creates it.
Dalmiro Granas
@Dalmirog
image.png

Full Cake build:

  • Restore
  • Build
  • Create Octopus instance (optional)
  • FIll up with data (optional)
  • Run tests (optional)
  • Remove Octopus instance (optional)

Took it from 7-8min to 2:50 :tada:

Dalmiro Granas
@Dalmirog

:tada: We have on official first draft of the contributing guide :tada:

https://github.com/Dalmirog/OctoPosh/blob/master/CONTRIBUTING.md

Still a WIP of cours

ping @kneumei who asked about this weeks ago
Kyle Neumeier
@kneumei
Thanks @Dalmirog
Dalmiro Granas
@Dalmirog

All feedback about it is welcome.

I still haven explained the whole Cake.Build process, but that's because I'm still working on it.

KSchiss
@KSchiss
Newbie question: I would like to use Get-OctopusMachine to output a list of machines (their Display Name) in any given environment to the screen in a single file column.
Dalmiro Granas
@Dalmirog

So just their names and nothing else?

You want the output on the console screen or on a file?

KSchiss
@KSchiss
just the display name, output to screen or file, whatever is easier :)
I swear i did this before, but maybe I used octo.exe... i can't remember
Dalmiro Granas
@Dalmirog
Get-OctopusMachine | select -ExpandProperty Name
or depending on your connection, this could be a bit faster: Get-OctopusMachine -ResourceOnly | select -ExpandProperty Name
KSchiss
@KSchiss
How cool is that.... thank you sir!
Dalmiro Granas
@Dalmirog
No problem!
James Dawson
@JamesDawson
Hi @Dalmirog thanks for your efforts on this project. I'm feeling the pain creating mock domain objects in my pester tests... just wondering what your thoughts were on adding some cmdlets to simplify this? Is that a PR you'd be interested in?
Dalmiro Granas
@Dalmirog
Hi @JamesDawson . Exactly how are you trying to create and use these objects in your pester tests?
Dalmiro Granas
@Dalmirog
If you want to ping me the pester test and try to explain what are you trying to assert
James Dawson
@JamesDawson
As some background, I'm automating a process for updating variable sets with various logic (which I want test coverage for). The tests themselves aren't the problem, it's just the verbose nature of using powershell to create the .NET objects needed when mocking-out calls that would otherwise get their data from the Octopus server (e.g. Get-OctopusVariableSet). Here's a gist of doing it for a variableset object, it's not complete but it will give you the idea: https://gist.github.com/JamesDawson/54a09171911403e4bb68c8bd292031e7 Whilst I could write a bunch of functions to do this, it just struck me that it would be way more efficient to write all the instantiation code in C#... unless I'm missing something and there is already an easier way?
Dalmiro Granas
@Dalmirog

This snippet should work

https://gist.github.com/Dalmirog/e642cab7c157d9497b20202aa4baeb33

In your code I can see you are creating some objects from the Octoposh namespace. You should never do that, as the Octoposh objects are just translations of the actual Octopus objects for the human eyes.

If you want to create/update/delete anything in Octopus, you need to use Octopus objects.

See how in line 13 I'm passing -resourceOnly? That tells the cmdlet to return the actual Octopus resource, instead of the Octoposh object. Later on I add the variable (again an Octopus object, this time of the type Octopus.client.model.variableResource) to the Octopus resource, and finally I pass the variable set Octopus object ($variableSet) to Update-OctopusResource
I realize that the meaning behind the -resourceOnly parameter is super importante and a bit obscure atm. I've been trying to write documentation about it for ages but I always forget. I'll try to get it done this week.
I even have a github issue open for it #157
James Dawson
@JamesDawson
Thanks for the detailed reply @Dalmirog . I had realised the difference between the OctoPosh and Octopus objects, I currently use the .Resource property when updating the server. However, I hadn't noticed the Get-OctopusResourceModel cmdlet which will simplify creating my mock objects if I change my script to use -ResourceOnly throughout. Many thanks for the pointer.
Dalmiro Granas
@Dalmirog
Glad I could help @JamesDawson :)
James Dawson
@JamesDawson
Hi @Dalmirog , I got something going though not quite how I intended, but its working well enough... I've sent a PR with some minor tweaks to Get-OctopusResourceModel that made life easier when using it to create the test data objects I was talking about above... see what you think.
KSchiss
@KSchiss
image.png
Hello @Dalmirog - have another newbie question for you. I'm using your syntax to move some machines from one environment to the other, and it doesn't seem to like Environments with spaces in them. I have tried putting quotes in a few places, but the script errors at the Get-OctopusEnvironment statement . (See above) Any suggestions?
Dalmiro Granas
@Dalmirog
@JamesDawson I'll be reviewing it sometime this week. I'm doing a big refactor with some help of a teammate that knows a ton more about C# than I do :)