forked from rancher/fleet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
96b2c6a
commit b32e77c
Showing
28 changed files
with
737 additions
and
361 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package agentconfig | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/rancher/fleet/modules/cli/pkg/client" | ||
|
||
"github.com/rancher/fleet/pkg/config" | ||
|
||
"k8s.io/apimachinery/pkg/runtime" | ||
|
||
"github.com/rancher/wrangler/pkg/yaml" | ||
) | ||
|
||
type Options struct { | ||
Labels map[string]string | ||
} | ||
|
||
func AgentConfig(output io.Writer, cg *client.Getter, opts *Options) error { | ||
if opts == nil { | ||
opts = &Options{} | ||
} | ||
|
||
objs, err := configMap(cg.Namespace, opts.Labels) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
data, err := yaml.Export(objs...) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
_, err = output.Write(data) | ||
return err | ||
} | ||
|
||
func configMap(namespace string, clusterLabels map[string]string) ([]runtime.Object, error) { | ||
cm, err := config.ToConfigMap(namespace, config.AgentConfigName, &config.Config{ | ||
Labels: clusterLabels, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
cm.Name = "fleet-agent" | ||
return []runtime.Object{ | ||
cm, | ||
}, nil | ||
} |
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 was deleted.
Oops, something went wrong.
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,28 @@ | ||
package cmds | ||
|
||
import ( | ||
"github.com/rancher/fleet/modules/cli/agentconfig" | ||
"github.com/rancher/fleet/modules/cli/pkg/command" | ||
"github.com/rancher/fleet/modules/cli/pkg/writer" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewAgentConfig() *cobra.Command { | ||
return command.Command(&AgentConfig{}, cobra.Command{ | ||
Short: "Generate cluster specific agent config", | ||
}) | ||
} | ||
|
||
type AgentConfig struct { | ||
OutputArgs | ||
|
||
Labels map[string]string `usage:"Labels to apply to the new cluster on register" short:"l"` | ||
} | ||
|
||
func (a *AgentConfig) Run(cmd *cobra.Command, args []string) error { | ||
opts := &agentconfig.Options{ | ||
Labels: a.Labels, | ||
} | ||
|
||
return agentconfig.AgentConfig(writer.New(a.Output), Client, opts) | ||
} |
Oops, something went wrong.