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

add support for m1 macs #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

russell
Copy link

@russell russell commented Jun 17, 2022

To support M1 we need to also build for the arm64 architecture.

I have tested building the golang binary locally and it works great on M1

To support M1 we need to also build for the `arm64` architecture.
@ghost
Copy link

ghost commented Nov 26, 2022

@russell How did you build for the M1? Mind adding instructions to this PR?

@ghost ghost mentioned this pull request Nov 26, 2022
@russell
Copy link
Author

russell commented Nov 28, 2022

I built it on an M1, i can't remember the command, i followed the readme

but if you are on a different computer, something like this should work to cross compile

GOOS=darwin GOARCH=arm64 go install ./cmd/kubectl-tap

@ghost
Copy link

ghost commented Dec 2, 2022

@russell It worked, thanks! That was easy 😄

@ecarvalho-olisipo
Copy link

ecarvalho-olisipo commented Feb 17, 2023

@said-acn Haven't you experienced this issue on go generate:

go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
go: go.mod file not found in current directory or any parent directory.
	'go get' is no longer supported outside a module.
	To build and install a command, use 'go install' with a version,
	like 'go install example.com/cmd@latest'
	For more information, see https://golang.org/doc/go-get-install-deprecation
	or run 'go help get' or 'go help install'.
/Users/ECH31/projects/tools/kubetap
WARN [runner] The linter 'interfacer' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.
WARN [runner] The linter 'scopelint' is deprecated (since v1.39.0) due to: The repository of the linter has been deprecated by the owner.  Replaced by exportloopref.
WARN [runner] The linter 'golint' is deprecated (since v1.41.0) due to: The repository of the linter has been archived by the owner.  Replaced by revive.
WARN [runner] The linter 'varcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
WARN [runner] The linter 'structcheck' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
WARN [runner] The linter 'deadcode' is deprecated (since v1.49.0) due to: The owner seems to have abandoned the linter.  Replaced by unused.
WARN [runner] The linter 'maligned' is deprecated (since v1.38.0) due to: The repository of the linter has been archived by the owner.  Replaced by govet 'fieldalignment'.
WARN [runner] The linter 'ifshort' is deprecated (since v1.48.0) due to: The repository of the linter has been deprecated by the owner.
WARN [runner] The linter 'nosnakecase' is deprecated (since v1.48.1) due to: The repository of the linter has been deprecated by the owner.  Replaced by revive(var-naming).
cmd/kubectl-tap/main.go:7: File is not `gofmt`-ed with `-s` (gofmt)
//      http://www.apache.org/licenses/LICENSE-2.0
cmd/kubectl-tap/mitmproxy.go:7: File is not `gofmt`-ed with `-s` (gofmt)
//      http://www.apache.org/licenses/LICENSE-2.0
cmd/kubectl-tap/tap.go:7: File is not `gofmt`-ed with `-s` (gofmt)
//      http://www.apache.org/licenses/LICENSE-2.0
cmd/kubectl-tap/tap.go:53:2: G101: Potential hardcoded credentials (gosec)
	kubetapWebPortName           = "kubetap-web"
	^
cmd/kubectl-tap/mitmproxy.go:183:1: calculated cyclomatic complexity for function createMitmproxyConfigMap is 12, max is 10 (cyclop)
func createMitmproxyConfigMap(configmapClient corev1.ConfigMapInterface, proxyOpts ProxyOptions) error {
^
cmd/kubectl-tap/tap.go:132:1: calculated cyclomatic complexity for function NewListCommand is 12, max is 10 (cyclop)
func NewListCommand(client kubernetes.Interface, viper *viper.Viper) func(*cobra.Command, []string) error {
^
cmd/kubectl-tap/tap.go:182:1: calculated cyclomatic complexity for function NewTapCommand is 48, max is 10 (cyclop)
func NewTapCommand(client kubernetes.Interface, config *rest.Config, viper *viper.Viper) func(*cobra.Command, []string) error { //nolint: gocyclo
^
cmd/kubectl-tap/tap.go:495:1: calculated cyclomatic complexity for function NewUntapCommand is 17, max is 10 (cyclop)
func NewUntapCommand(client kubernetes.Interface, viper *viper.Viper) func(*cobra.Command, []string) error {
^
cmd/kubectl-tap/tap.go:631:1: calculated cyclomatic complexity for function tapSvc is 11, max is 10 (cyclop)
func tapSvc(svcClient corev1.ServiceInterface, svcName string, targetPort int32) error {
^
cmd/kubectl-tap/main.go:116:10: Aliases, SuggestFor, ValidArgs, ValidArgsFunction, Args, ArgAliases, BashCompletionFunction, Deprecated, Hidden, Annotations, Version, PersistentPreRun, PersistentPreRunE, PreRun, PreRunE, RunE, PostRun, PostRunE, PersistentPostRun, PersistentPostRunE, SilenceErrors, DisableFlagParsing, DisableAutoGenTag, DisableFlagsInUseLine, DisableSuggestions, SuggestionsMinimumDistance, TraverseChildren, FParseErrWhitelist are missing in Command (exhaustruct)
	return &cobra.Command{
	        ^
cmd/kubectl-tap/main.go:151:10: Aliases, SuggestFor, Long, ValidArgs, ValidArgsFunction, ArgAliases, BashCompletionFunction, Deprecated, Hidden, Annotations, Version, PersistentPreRun, PersistentPreRunE, PreRun, Run, PostRun, PostRunE, PersistentPostRun, PersistentPostRunE, SilenceErrors, SilenceUsage, DisableFlagParsing, DisableAutoGenTag, DisableFlagsInUseLine, DisableSuggestions, SuggestionsMinimumDistance, TraverseChildren, FParseErrWhitelist are missing in Command (exhaustruct)
	return &cobra.Command{
	        ^
cmd/kubectl-tap/main.go:162:10: Aliases, SuggestFor, Long, ValidArgs, ValidArgsFunction, ArgAliases, BashCompletionFunction, Deprecated, Hidden, Annotations, Version, PersistentPreRun, PersistentPreRunE, PreRun, PreRunE, Run, PostRun, PostRunE, PersistentPostRun, PersistentPostRunE, SilenceErrors, SilenceUsage, DisableFlagParsing, DisableAutoGenTag, DisableFlagsInUseLine, DisableSuggestions, SuggestionsMinimumDistance, TraverseChildren, FParseErrWhitelist are missing in Command (exhaustruct)
	return &cobra.Command{
	        ^
cmd/kubectl-tap/main.go:172:10: Aliases, SuggestFor, Long, Example, ValidArgs, ValidArgsFunction, Args, ArgAliases, BashCompletionFunction, Deprecated, Hidden, Annotations, Version, PersistentPreRun, PersistentPreRunE, PreRun, PreRunE, Run, PostRun, PostRunE, PersistentPostRun, PersistentPostRunE, SilenceErrors, SilenceUsage, DisableFlagParsing, DisableAutoGenTag, DisableFlagsInUseLine, DisableSuggestions, SuggestionsMinimumDistance, TraverseChildren, FParseErrWhitelist are missing in Command (exhaustruct)
	return &cobra.Command{
	        ^
cmd/kubectl-tap/main.go:180:10: Aliases, SuggestFor, Long, Example, ValidArgs, ValidArgsFunction, Args, ArgAliases, BashCompletionFunction, Deprecated, Hidden, Annotations, Version, PersistentPreRun, PersistentPreRunE, PreRun, PreRunE, RunE, PostRun, PostRunE, PersistentPostRun, PersistentPostRunE, SilenceErrors, SilenceUsage, DisableFlagParsing, DisableAutoGenTag, DisableFlagsInUseLine, DisableSuggestions, SuggestionsMinimumDistance, TraverseChildren, FParseErrWhitelist are missing in Command (exhaustruct)
	return &cobra.Command{
	        ^
cmd/kubectl-tap/mitmproxy.go:44:33: Image, Command, Args, WorkingDir, EnvFrom, Env, Resources, VolumeDevices, LivenessProbe, StartupProbe, Lifecycle, TerminationMessagePath, TerminationMessagePolicy, SecurityContext, Stdin, StdinOnce, TTY are missing in Container (exhaustruct)
var MitmproxySidecarContainer = v1.Container{
                                ^
cmd/kubectl-tap/mitmproxy.go:61:19: FailureThreshold is missing in Probe (exhaustruct)
	ReadinessProbe: &v1.Probe{
	                 ^
cmd/kubectl-tap/mitmproxy.go:62:12: Exec, TCPSocket are missing in Handler (exhaustruct)
		Handler: v1.Handler{
		         ^
cmd/kubectl-tap/mitmproxy.go:63:14: Host, HTTPHeaders are missing in HTTPGetAction (exhaustruct)
			HTTPGet: &v1.HTTPGetAction{
			          ^
cmd/kubectl-tap/mitmproxy.go:126:17: HostPath, EmptyDir, GCEPersistentDisk, AWSElasticBlockStore, GitRepo, Secret, NFS, ISCSI, Glusterfs, PersistentVolumeClaim, RBD, FlexVolume, Cinder, CephFS, Flocker, DownwardAPI, FC, AzureFile, VsphereVolume, Quobyte, AzureDisk, PhotonPersistentDisk, Projected, PortworxVolume, ScaleIO, StorageOS, CSI, Ephemeral are missing in VolumeSource (exhaustruct)
		VolumeSource: v1.VolumeSource{
		              ^
cmd/kubectl-tap/mitmproxy.go:127:16: Items, DefaultMode, Optional are missing in ConfigMapVolumeSource (exhaustruct)
			ConfigMap: &v1.ConfigMapVolumeSource{
			            ^
cmd/kubectl-tap/mitmproxy.go:137:17: HostPath, GCEPersistentDisk, AWSElasticBlockStore, GitRepo, Secret, NFS, ISCSI, Glusterfs, PersistentVolumeClaim, RBD, FlexVolume, Cinder, CephFS, Flocker, DownwardAPI, FC, AzureFile, ConfigMap, VsphereVolume, Quobyte, AzureDisk, PhotonPersistentDisk, Projected, PortworxVolume, ScaleIO, StorageOS, CSI, Ephemeral are missing in VolumeSource (exhaustruct)
		VolumeSource: v1.VolumeSource{
		              ^
cmd/kubectl-tap/mitmproxy.go:138:15: Medium, SizeLimit are missing in EmptyDirVolumeSource (exhaustruct)
			EmptyDir: &v1.EmptyDirVolumeSource{},
			           ^
cmd/kubectl-tap/mitmproxy.go:211:8: TypeMeta, Immutable, Data are missing in ConfigMap (exhaustruct)
	cm := v1.ConfigMap{
	      ^
cmd/kubectl-tap/mitmproxy.go:212:15: GenerateName, SelfLink, UID, ResourceVersion, Generation, CreationTimestamp, DeletionTimestamp, DeletionGracePeriodSeconds, Labels, OwnerReferences, Finalizers, ClusterName, ManagedFields are missing in ObjectMeta (exhaustruct)
		ObjectMeta: metav1.ObjectMeta{
		            ^
cmd/kubectl-tap/mitmproxy.go:225:58: TypeMeta, DryRun, FieldManager are missing in CreateOptions (exhaustruct)
	ccm, err := configmapClient.Create(context.TODO(), &cm, metav1.CreateOptions{})
	                                                        ^
cmd/kubectl-tap/mitmproxy.go:244:51: TypeMeta, LabelSelector, FieldSelector, Watch, AllowWatchBookmarks, ResourceVersion, ResourceVersionMatch, TimeoutSeconds, Limit, Continue are missing in ListOptions (exhaustruct)
	cms, err := configmapClient.List(context.TODO(), metav1.ListOptions{})
	                                                 ^
cmd/kubectl-tap/mitmproxy.go:263:73: TypeMeta, GracePeriodSeconds, Preconditions, OrphanDependents, PropagationPolicy, DryRun are missing in DeleteOptions (exhaustruct)
	return configmapClient.Delete(context.TODO(), targetConfigMapNames[0], metav1.DeleteOptions{})
	                                                                       ^
cmd/kubectl-tap/tap.go:146:77: TypeMeta, LabelSelector, FieldSelector, Watch, AllowWatchBookmarks, ResourceVersion, ResourceVersionMatch, TimeoutSeconds, Limit, Continue are missing in ListOptions (exhaustruct)
		services, err := client.CoreV1().Services(namespace).List(context.TODO(), metav1.ListOptions{})
		                                                                          ^
cmd/kubectl-tap/tap.go:217:16: Protocol, UpstreamPort, Image, dplName are missing in ProxyOptions (exhaustruct)
		proxyOpts := ProxyOptions{
		             ^
cmd/kubectl-tap/tap.go:242:96: TypeMeta, ResourceVersion are missing in GetOptions (exhaustruct)
		targetService, err := client.CoreV1().Services(namespace).Get(context.TODO(), targetSvcName, metav1.GetOptions{})
		                                                                                             ^
cmd/kubectl-tap/tap.go:330:67: TypeMeta, DryRun, FieldManager are missing in UpdateOptions (exhaustruct)
			_, updateErr := deploymentsClient.Update(context.TODO(), &dpl, metav1.UpdateOptions{})
			                                                               ^
cmd/kubectl-tap/tap.go:448:5: CheckRedirect, Jar, Timeout are missing in Client (exhaustruct)
			&http.Client{Transport: transport},
			 ^
cmd/kubectl-tap/tap.go:450:5: Opaque, User, RawPath, OmitHost, ForceQuery, RawQuery, Fragment, RawFragment are missing in URL (exhaustruct)
			&url.URL{
			 ^
cmd/kubectl-tap/tap.go:513:96: TypeMeta, ResourceVersion are missing in GetOptions (exhaustruct)
		targetService, err := client.CoreV1().Services(namespace).Get(context.TODO(), targetSvcName, metav1.GetOptions{})
		                                                                                             ^
cmd/kubectl-tap/tap.go:525:33: Protocol, UpstreamHTTPS, UpstreamPort, Mode, Image are missing in ProxyOptions (exhaustruct)
		proxy := NewMitmproxy(client, ProxyOptions{
		                              ^
cmd/kubectl-tap/tap.go:540:74: TypeMeta, ResourceVersion are missing in GetOptions (exhaustruct)
			deployment, getErr := deploymentsClient.Get(context.TODO(), dpl.Name, metav1.GetOptions{})
			                                                                      ^
cmd/kubectl-tap/tap.go:563:73: TypeMeta, DryRun, FieldManager are missing in UpdateOptions (exhaustruct)
			_, updateErr := deploymentsClient.Update(context.TODO(), deployment, metav1.UpdateOptions{})
			                                                                     ^
cmd/kubectl-tap/tap.go:593:54: TypeMeta, FieldSelector, Watch, AllowWatchBookmarks, ResourceVersion, ResourceVersionMatch, TimeoutSeconds, Limit, Continue are missing in ListOptions (exhaustruct)
	dpls, err := deploymentsClient.List(context.TODO(), metav1.ListOptions{
	                                                    ^
cmd/kubectl-tap/tap.go:611:46: TypeMeta, LabelSelector, FieldSelector, Watch, AllowWatchBookmarks, ResourceVersion, ResourceVersionMatch, TimeoutSeconds, Limit, Continue are missing in ListOptions (exhaustruct)
	pods, err := podClient.List(context.TODO(), metav1.ListOptions{})
	                                            ^
cmd/kubectl-tap/tap.go:664:19: Protocol, AppProtocol, NodePort are missing in ServicePort (exhaustruct)
		proxySvcPort := v1.ServicePort{
		                ^
cmd/kubectl-tap/tap.go:684:57: TypeMeta, DryRun, FieldManager are missing in UpdateOptions (exhaustruct)
		_, updateErr := svcClient.Update(context.TODO(), svc, metav1.UpdateOptions{})
		                                                      ^
cmd/kubectl-tap/mitmproxy.go:96:1: NewMitmproxy returns interface (github.com/soluble-ai/kubetap/cmd/kubectl-tap.Tap) (ireturn)
func NewMitmproxy(c kubernetes.Interface, p ProxyOptions) Tap {
^
cmd/kubectl-tap/tap.go:117:21: json(camel): got 'upstream_https' want 'upstreamHttps' (tagliatelle)
	UpstreamHTTPS bool `json:"upstream_https"`
	                   ^
cmd/kubectl-tap/tap.go:119:22: json(camel): got 'upstream_port' want 'upstreamPort' (tagliatelle)
	UpstreamPort string `json:"upstream_port"`
	                    ^
cmd/kubectl-tap/mitmproxy.go:249:6: variable name 'cm' is too short for the scope of its usage (varnamelen)
	for _, cm := range cms.Items {
	    ^
cmd/kubectl-tap/tap.go:615:6: variable name 'p' is too short for the scope of its usage (varnamelen)
	var p v1.Pod
	    ^
cmd/kubectl-tap/tap.go:456:3: variable name 'fw' is too short for the scope of its usage (varnamelen)
		fw, err := portforward.New(dialer,
		^
cmd/kubectl-tap/tap.go:703:7: variable name 'sp' is too short for the scope of its usage (varnamelen)
		for _, sp := range svc.Spec.Ports {
		    ^
cmd/kubectl-tap/tap.go:378:3: variable name 's' is too short for the scope of its usage (varnamelen)
		s := make(chan struct{})
		^
cmd/kubectl-tap/tap.go:673:7: variable name 'sp' is too short for the scope of its usage (varnamelen)
		for _, sp := range svc.Spec.Ports {
		    ^
cmd/kubectl-tap/main.go:115:17: parameter name 'e' is too short for the scope of its usage (varnamelen)
func NewRootCmd(e Exiter) *cobra.Command {
                ^
cmd/kubectl-tap/tap.go:225:32: directive `// nolint: exhaustive` should be written without leading space as `//nolint: exhaustive` (nolintlint)
			switch Protocol(protocol) { // nolint: exhaustive
			                            ^
cmd/kubectl-tap/tap.go:292:31: directive `// nolint: exhaustive` should be written without leading space as `//nolint: exhaustive` (nolintlint)
		switch Protocol(protocol) { // nolint: exhaustive
		                            ^
build.go:5: running "golangci-lint": exit status 1

Also M1, btw

@pennytextures
Copy link

pennytextures commented Mar 31, 2023

@ecarvalho-olisipo

You can disable the linter by editing .golandci.yaml and setting "enable-all" to false, then it builds fine.

I'm not a go developer, so it confused me for longer than I care to admit that it deposits the built binary into your GOPATH bin dir, so it'll generate ${GOPATH}/bin/kubectl-tap

@davidlanouette
Copy link

@said-acn asked:

@russell How did you build for the M1? Mind adding instructions to this PR?

goreleaser release --clean --snapshot should build all the versions for you locally. It's basically a dry-run, and doesn't bump versions, or publish any changes. But you can check locally what would be build (look in the dist/ dir.)

@davidlanouette
Copy link

This PR works correctly for me. Can someone that can merge give it a second look and possibly merge it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants