Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CreateHost variables to accept interface instead of string #16

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
25 changes: 25 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
description = "A Nix-flake-based Go 1.22 development environment";

inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.*.tar.gz";

outputs = { self, nixpkgs }:
let
goVersion = 22; # Change this to update the whole stack

supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
});
in
{
overlays.default = final: prev: {
go = final."go_1_${toString goVersion}";
};

devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [
# go (version is specified by overlay)
go

# goimports, godoc, etc.
gotools

# https://github.com/golangci/golangci-lint
golangci-lint
];
};
});
};
}
2 changes: 1 addition & 1 deletion iapi/hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (server *Server) GetHost(hostname string) ([]HostStruct, error) {
}

// CreateHost ...
func (server *Server) CreateHost(hostname, address, address6 string, checkCommand string, variables map[string]string, templates []string, groups []string) ([]HostStruct, error) {
func (server *Server) CreateHost(hostname, address, address6 string, checkCommand string, variables map[string]interface{}, templates []string, groups []string) ([]HostStruct, error) {

var newAttrs HostAttrs
newAttrs.Address = address
Expand Down
3 changes: 2 additions & 1 deletion iapi/hosts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ func TestCreateHostWithVariables(t *testing.T) {
IPAddress := "127.0.0.3"
CheckCommand := "hostalive"

variables := make(map[string]string)
variables := make(map[string]interface{})

variables["vars.os"] = "Linux"
variables["vars.creator"] = "Terraform"
variables["vars.urls"] = []string{"test-url1.example.com", "test-url2.example.com"}

_, err := Icinga2_Server.CreateHost(hostname, IPAddress, "", CheckCommand, variables, nil, nil)
if err != nil {
Expand Down