How to specify Dapr component locations with Sidekick? - .net-6.0

I'm trying to get started with Sidekick for Dapr, and am having trouble telling Sidekick where the dapr components are.
By default it's going to %USERPROFILE%.dapr\components, but I'd rather it go to a folder local to the solution.
Looking at the code it appears that adding the following to the appsettings.json should work, but it isn't picked up.
"DaprSidekick": {
"RuntimeDirectory": "dapr",
"ComponentsDirectory": "C:\\Dev\\DaprPOC\\components",
}
However the components folder invariably becomes %USERPROFILE%\.dapr\components
Any help on how I specify the component locations with Sidekick?

When you set "RuntimeDirectory": "dapr" Sidekick will automatically look for component files in the dapr/components subdirectory in your solution. Try removing the ComponentsDirectory entry so it returns to defaults, and try a directory structure like this:
|-- MyProject
| |-- MyProject.csproj
| |-- dapr
| | |-- config.yaml
| | |-- components
| | | |-- my_component.yaml
The Dapr Sidecar should then load my_component.yaml.

You can also manually add the components directory in the dependency injection:
services.AddDaprSidekick(configuration, p => p.Sidecar =
new DaprSidecarOptions() { AppId = "daprservice", ComponentsDirectory = "C:\\Dev\\DaprPOC\\components" });

Related

Using scc as code counter, how to ignore multiple adjacent subfolders and recursively other folders

I am trying to use code counter software scc https://nicedoc.io/boyter/scc#user-content-sloc-cloc-and-code-scc
My folder is a typical Django project
--|
|-- core (has subfolder: migrations)
|-- app1 (has subfolder: migrations)
|-- app2 (has subfolder: migrations)
|-- static
|-- staticfiles
The above is greatly simplified
I tried scc -M static . which works great as it properly ignores the static folder
But I want to ignore both the static and staticfiles and also the migrations subfolders inside app1 and app2.
How do I do the above?
I don't quite understand the documentation inside the scc in order to pull this off.
This works for me
Thanks to #jhnc
scc --not-match="(static.*|migrations|.css|LICENSE|.gitignore|anyotherfoldername)" .

Package Vue frontend in Go binary

I am trying to serve my frontend using the Gin framework. It is a small project which would make maintenance easier having it as a single binary.
The project structure looks like this:
Project
|
+-- backend
| |
| +-- backend (binary)
|
+-- frontend
| |
| +-- dist
| |
| +-- package.json
|
+-- Procfile
|
+-- .gitlab-ci.yml
Currently I am serving the fronend like this:
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false)))
For local dev this works fine and I did not have any issues. If I deploy this with my gitlab-ci pipeline it fails as I do not upload the ../frontend/dist directory. I looked at the pkgr library which should help me achieve my goal.
My issue is I can not get it to work with the Gin framework. Current snippet:
test := pkger.Dir("../frontend/dist")
r.Use(static.Serve("/", static.LocalFile("../frontend/dist", false))) <- compiles but does not serve frontend
r.Use(static.Serve("/", static.LocalFile(test, false))) <- Does not compile
Is there an easier way to achieve my goal?
The problem is when you deploy the project to Heroku (I supposed you are using Heroku because of the tag you are using) it compiles the Go to a binary.
The binary is running in the root folder of the project and ../frontend is not in the same path as the development enviroment anymore.
Something like this:
Project
|
+-- backend
| |
| +-- backend (binary)
|
+-- frontend
| |
| +-- dist
| |
| +-- package.json
|
+-- Procfile
|
+-- .gitlab-ci.yml
|
+-- project binary <---- here
So the correct path is ./frontend/ (see one dot)
You can set an environment variable to set the correct path.
As you are using Vue, you can set for the development environment a dev-server with a proxy pointing to backend. Then when building for production you can make Vue compiles to a specific folder that is hardcoded and served by the backend.

Some tips with Go and Gogland

Hi all. I'm very new with Go and Gogland. I have a project
I choose "Run kind" as Package - to run not only main file but a project. Why it cannot find main package??
How to import util.myprinter package to main.go to use it??
Please, help me
First, the general structure of your Go workspace seems to be wrong. You need to make it look more like this:
D:
|-- go_projects
| |-- bin
| |-- pkg
| |-- src
| | |-- FirstSteps
| | | |-- main.go
| | | +-- util
| | | +-- myprinter.go
| | |-- SecondProject
| | |-- ThirdProject
...
Second your import statement seems to be empty, I have no idea how GoLand works but if you want to use whatever is in your myprinter.go file, you will need to import the util package, assuming that the myprinter.go file declares its package as util at the top.
// FirstSteps/main.go
package main
import (
"FirstSteps/util"
)
func main() {
util.MyPrinterFunc()
}
And of course to be able to use anything from util there first must be something...
// FirstSteps/util/myprinter.go
package util
func MyPrinterFunc() {
// do stuff...
}
Edit: I'm sorry, I didn't actually answer your question initially. You're getting the error Cannot find package 'main' because of the wrong workspace setup I already mentioned. The Package path tells GoLand where the package you want to run is relative to the $GOPATH/src directory. So after you've setup your wrokspace correctly, you should set the Package path to FirstSteps since that package's absolute path will be $GOPATH/src/FirstSteps. If, later, you want to run the util package you would specify Package path as FirstSteps/util for GoLand to be able to find it.

Can't create unittests IntelliJ

I am not able to select my testfolder in IntelliJ.
For some reason it wasn't there when I created this project, so I added it manually. After I did that, I went to project structure --> modules, where I marked it as a test.
I am simply not allowed to leave my source directory, when creating a testcase.
See image:
The problem doesn't occure when I create a new project, where the testfolder is set automaticly.
It seems that you have wrong project structure.
It should be as follows:
project-name
|-- pom.xml
|-- src
|-- main
| |-- java
| |-- resources
|-- test
|-- java
|-- resources
And don't mark the test directory as a test source root. You should mark the test/java (subdirectory under the test folder) instead:

Rails 3.1 asset pipeline vendor/assets folder organization

I'm using the jQuery Tools scrollable library in my Rails 3.1 site with the various assets placed in the vendor/assets folder and it works great.
My question is regarding the best way to organize the various files under vendor/assets. What is the recommended way to organize vendor/assets subfolders? Currently I have this structure:
vendor/assets/
|-- images/
| |-- scrollable/
| <various button/gradient images>
|-- javascripts/
| |-- scrollable/
| jquery.tools.min.js
|-- stylesheets/
| |-- scrollable/
| scrollable-buttons.css
| scrollable-horizontal.css
This is a fairly un-DRY what to do this. I feel that all of the 'scrollable' items should be under one folder.
What is the recommended way to do this without having to manipulate the asset pipeline load paths?
Thanks!
You could organise them this way, which is slightly better in that it keeps stuff related to the plugin in one directory:
vendor/assets/scrollable
|-- images/
| |-- <various button/gradient images>
|-- javascripts/
| |-- jquery.tools.min.js
|-- stylesheets/
| |-- scrollable-buttons.css
| scrollable-horizontal.css
I am pretty sure this will work as rails globs all directories under assets/.

Resources