Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
foremanFS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Hörnquist
foremanFS
Commits
2645817f
Commit
2645817f
authored
4 years ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Interface based.
parent
d8e60d08
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
fetch/fetch.go
+35
-10
35 additions, 10 deletions
fetch/fetch.go
file/file.go
+0
-1
0 additions, 1 deletion
file/file.go
with
35 additions
and
11 deletions
fetch/fetch.go
+
35
−
10
View file @
2645817f
...
...
@@ -26,7 +26,7 @@ var client *http.Client
// echo curl --user "hugo:$(pass lysator/hugo)" -k https://chapman.lysator.liu.se/api/hosts
type
Host
struct
{
Data
Resul
tRecord
Data
Hos
tRecord
}
func
Init
(
pw
string
)
{
...
...
@@ -41,8 +41,8 @@ func Init(pw string) {
client
=
&
http
.
Client
{
Transport
:
tr
}
var
m
Message
fff
(
"hosts"
,
&
m
)
var
m
Host
Message
fff
_pages
(
"hosts"
,
&
m
)
for
_
,
record
:=
range
m
.
Results
{
Hosts
[
record
.
Name
]
=
Host
{
record
}
...
...
@@ -69,13 +69,19 @@ func fff (url string, message interface{}) {
decoder
:=
json
.
NewDecoder
(
resp
.
Body
)
err
=
decoder
.
Decode
(
&
message
)
err
=
decoder
.
Decode
(
message
)
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
}
func
fff_pages
(
url
string
,
message
IsMessage
)
{
fff
(
url
,
&
message
)
log
.
Printf
(
"message = %+v"
,
message
.
GetMessage
())
}
func
GetClassList
(
host
Resul
tRecord
)
[]
string
{
func
GetClassList
(
host
Hos
tRecord
)
[]
string
{
var
record
[]
Puppetclass
if
val
,
ok
:=
hostClasses
[
host
.
Id
];
ok
{
...
...
@@ -83,7 +89,7 @@ func GetClassList(host ResultRecord) []string {
}
else
{
url
:=
fmt
.
Sprintf
(
"hosts/%d/puppetclasses"
,
int
(
host
.
Id
))
var
m
PuppetclassMessage
fff
(
url
,
&
m
)
fff
_pages
(
url
,
&
m
)
for
_
,
values
:=
range
m
.
Results
{
record
=
append
(
record
,
values
...
)
...
...
@@ -98,7 +104,7 @@ func GetClassList(host ResultRecord) []string {
return
str
}
type
Resul
tRecord
struct
{
type
Hos
tRecord
struct
{
Ip
string
// "130.236.254.139",
Ip6
string
// "2001:6b0:17:f0a0::8b",
Environment_id
float64
// 1,
...
...
@@ -199,13 +205,28 @@ type ResultRecord struct {
Hostgroup_title
string
// "Analysator/System"
}
type
IsMessage
interface
{
GetMessage
()
Message
// TODO
// MergeMessage(Message) Message
}
type
Message
struct
{
Total
,
Subtotal
,
Page
/*, Per_page*/
float64
Results
[]
ResultRecord
Total
,
Subtotal
,
Page
,
Per_page
float64
// search
// sort { by, order null }
}
type
HostMessage
struct
{
Message
Results
[]
HostRecord
}
func
(
m
HostMessage
)
GetMessage
()
Message
{
return
m
.
Message
}
type
Puppetclass
struct
{
Id
float64
Name
string
// "profiles::localtime"
...
...
@@ -214,6 +235,10 @@ type Puppetclass struct {
}
type
PuppetclassMessage
struct
{
Total
,
Subtotal
,
Page
,
Per_page
float64
Message
Results
map
[
string
][]
Puppetclass
}
func
(
m
PuppetclassMessage
)
GetMessage
()
Message
{
return
m
.
Message
}
This diff is collapsed.
Click to expand it.
file/file.go
+
0
−
1
View file @
2645817f
...
...
@@ -8,7 +8,6 @@ import (
)
type
Data
struct
{
// record ResultRecord
Hostname
string
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment