-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from projectsyn/collect-ocp-and-additional-facts
Collect OCP OAuth route and additional facts
- Loading branch information
Showing
9 changed files
with
165 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package agent | ||
package facts | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
pkg/agent/factsopenshift_test.go → pkg/agent/facts/factsopenshift_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package agent | ||
package facts | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"encoding/json" | ||
"flag" | ||
"fmt" | ||
|
||
"k8s.io/client-go/kubernetes" | ||
"sigs.k8s.io/controller-runtime/pkg/client/config" | ||
|
||
"github.com/projectsyn/steward/pkg/agent/facts" | ||
) | ||
|
||
func main() { | ||
ns := flag.String("namespace", "syn", "namespace in which steward is running") | ||
additionalFactsConfigMap := flag.String("additional-facts-config-map", "additional-facts", "configmap containing additional facts to be added to the dynamic facts") | ||
ocpOAuthRouteNamespace := flag.String("ocp-oauth-route-namespace", "openshift-authentication", "Namespace for the OpenShift OAuth route") | ||
ocpOAuthRouteName := flag.String("ocp-oauth-route-name", "oauth-openshift", "Name of the OpenShift OAuth route") | ||
|
||
flag.Parse() | ||
|
||
cfg := config.GetConfigOrDie() | ||
|
||
client, err := kubernetes.NewForConfig(cfg) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
c := facts.FactCollector{ | ||
Client: client, | ||
|
||
OAuthRouteNamespace: *ocpOAuthRouteNamespace, | ||
OAuthRouteName: *ocpOAuthRouteName, | ||
|
||
AdditionalFactsConfigMapNamespace: *ns, | ||
AdditionalFactsConfigMapName: *additionalFactsConfigMap, | ||
} | ||
|
||
fcts, err := c.FetchDynamicFacts(context.Background()) | ||
if err != nil { | ||
panic(err) | ||
} | ||
out, err := json.MarshalIndent(fcts, "", "\t") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(string(out)) | ||
} |